Skip to content

Instantly share code, notes, and snippets.

@ebicoglu
Last active December 22, 2020 18:35
Show Gist options
  • Save ebicoglu/5637f7fb4b003604238c98f0da07aec1 to your computer and use it in GitHub Desktop.
Save ebicoglu/5637f7fb4b003604238c98f0da07aec1 to your computer and use it in GitHub Desktop.
Containerize Blazor with Docker + nginx
---
version: "3.4"
services:
yourproject-migrator:
build:
context: .
dockerfile: src/YourProject.DbMigrator/Dockerfile
image: "${REGISTRY:-}yourproject-migrator:${TAG:-latest}"
yourproject-frontend:
build:
context: .
dockerfile: src/YourProject.Blazor/Dockerfile
image: "${REGISTRY:-}yourproject-frontend:${TAG:-latest}"
yourproject-backend:
build:
context: .
dockerfile: src/YourProject.HttpApi.Host/Dockerfile
image: "${REGISTRY:-}yourproject-backend:${TAG:-latest}"
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS builder
WORKDIR /app
COPY . .
RUN dotnet publish -c Release src/YourProject.Blazor -o /app/publish
FROM nginx:alpine
COPY --from=builder /app/publish/wwwroot /usr/share/nginx/html/
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS builder
WORKDIR /app
COPY . .
RUN dotnet publish -c Release src/YourProject.DbMigrator -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS runner
WORKDIR /app
COPY --from=builder /app/publish /app
EXPOSE 80
CMD [ "dotnet", "YourProject.DbMigrator.dll"]
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS builder
WORKDIR /app
COPY . .
RUN dotnet publish -c Release src/YourProject.HttpApi.Host -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS runner
WORKDIR /app
COPY --from=builder /app/publish /app
EXPOSE 80
CMD [ "dotnet", "YourProject.HttpApi.Host.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment