Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created January 12, 2024 15:36
Show Gist options
  • Save dontpaniclabsgists/3714446da8adaec35bcd51b7c4bbae0a to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/3714446da8adaec35bcd51b7c4bbae0a to your computer and use it in GitHub Desktop.
# Stage 1: Build the application
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
# Copy the client1 project files
COPY client1/. ./client1/
COPY serviceA/. ./serviceA/
COPY serviceB/. ./serviceB/
WORKDIR /src/client1
RUN dotnet build -c Release -o /app/build
# Stage 2: Publish the application
FROM build AS publish
RUN dotnet publish -c Release -o /app/publish
# Stage 3: Create the final image
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS final
WORKDIR /app
# Use a non-root user for enhanced security
USER nobody:nogroup
EXPOSE 80
# Copy the published files from the ‘publish’ stage
COPY --from=publish /app/publish .
# Define the entry point
ENTRYPOINT [“dotnet”, “client1.dll”]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment