Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
neozhu authored Nov 26, 2024
1 parent 40ec2c3 commit c7bd43e
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/CleanAspire.Api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src

# Copy the project files and restore dependencies
COPY ["src/CleanAspire.Api/CleanAspire.Api.csproj", "src/CleanAspire.Api/"]
COPY ["src/CleanAspire.Application/CleanAspire.Application.csproj", "src/CleanAspire.Application/"]
COPY ["src/CleanAspire.Domain/CleanAspire.Domain.csproj", "src/CleanAspire.Domain/"]
COPY ["src/CleanAspire.Infrastructure/CleanAspire.Infrastructure.csproj", "src/CleanAspire.Infrastructure/"]
COPY ["src/CleanAspire.ServiceDefaults/CleanAspire.ServiceDefaults.csproj", "src/CleanAspire.ServiceDefaults/"]
COPY ["src/Migrators/Migrators.MSSQL/Migrators.MSSQL.csproj", "src/Migrators/Migrators.MSSQL/"]
COPY ["src/Migrators/Migrators.PostgreSQL/Migrators.PostgreSQL.csproj", "src/Migrators/Migrators.PostgreSQL/"]
COPY ["src/Migrators/Migrators.SQLite/Migrators.SQLite.csproj", "src/Migrators/Migrators.SQLite/"]
RUN dotnet restore "src/CleanAspire.Api/CleanAspire.Api.csproj"
COPY ["CleanAspire.Api.csproj", "./"]
COPY ["../CleanAspire.Application/CleanAspire.Application.csproj", "../CleanAspire.Application/"]
COPY ["../CleanAspire.Domain/CleanAspire.Domain.csproj", "../CleanAspire.Domain/"]
COPY ["../CleanAspire.Infrastructure/CleanAspire.Infrastructure.csproj", "../CleanAspire.Infrastructure/"]
COPY ["../CleanAspire.ServiceDefaults/CleanAspire.ServiceDefaults.csproj", "../CleanAspire.ServiceDefaults/"]
COPY ["../Migrators/Migrators.MSSQL/Migrators.MSSQL.csproj", "../Migrators/Migrators.MSSQL/"]
COPY ["../Migrators/Migrators.PostgreSQL/Migrators.PostgreSQL.csproj", "../Migrators/Migrators.PostgreSQL/"]
COPY ["../Migrators/Migrators.SQLite/Migrators.SQLite.csproj", "../Migrators/Migrators.SQLite/"]
RUN dotnet restore "CleanAspire.Api.csproj"

# Copy the entire source code and build the application in Release mode
COPY . .
WORKDIR /src/src/CleanAspire.Api
COPY .. .
WORKDIR /src
RUN dotnet publish -c Release -o /app/publish

# Stage 2: Create the runtime image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app
ARG ENVIRONMENT=Development
ARG ENVIRONMENT=Development

# Copy the build output from the previous stage
COPY --from=build /app/publish .

# Expose port 80 for HTTP traffic
EXPOSE 443
# Expose ports 80 and 443 for HTTP and HTTPS traffic
EXPOSE 80 443

# Start the application
# Create a self-signed certificate
RUN dotnet dev-certs https -ep /https/aspnetapp.pfx -p password

# Start the application with HTTPS support
ENTRYPOINT ["dotnet", "CleanAspire.Api.dll", "--environment", "$ENVIRONMENT", "--urls", "https://0.0.0.0:443"]
# Set the environment variable and start the application with HTTP and HTTPS support
ENV ASPNETCORE_ENVIRONMENT=Development
ENTRYPOINT ["dotnet", "CleanAspire.Api.dll", "--urls", "http://0.0.0.0:80;https://0.0.0.0:443"]

0 comments on commit c7bd43e

Please sign in to comment.