Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare applications for Azure deployment by generating infrastructure code, Dockerfiles, and config files.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/recipes/azd/docker.md
1# Dockerfile Generation23Create Dockerfiles for containerized services.45## When to Containerize67| Include | Exclude |8|---------|---------|9| APIs, microservices | Static websites (use Static Web Apps) |10| Web apps (SSR) | Azure Functions (native deploy) |11| Background workers | Database services |12| Message processors | Logic Apps |1314## Templates by Language1516### Node.js1718```dockerfile19FROM node:22-slim20WORKDIR /app21COPY package*.json ./22RUN npm ci --only=production23COPY . .24EXPOSE 300025CMD ["node", "index.js"]26```2728### Python2930```dockerfile31FROM python:3.13-slim32WORKDIR /app33COPY requirements.txt .34RUN pip install --no-cache-dir -r requirements.txt35COPY . .36EXPOSE 800037CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]38```3940### .NET4142```dockerfile43FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base44WORKDIR /app45EXPOSE 80804647FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build48WORKDIR /src49COPY ["*.csproj", "./"]50RUN dotnet restore51COPY . .52RUN dotnet publish -c Release -o /app/publish5354FROM base AS final55WORKDIR /app56COPY --from=build /app/publish .57ENTRYPOINT ["dotnet", "App.dll"]58```5960### Java6162```dockerfile63FROM eclipse-temurin:21-jdk-alpine AS build64WORKDIR /app65COPY . .66RUN ./mvnw package -DskipTests6768FROM eclipse-temurin:21-jre-alpine69WORKDIR /app70COPY --from=build /app/target/*.jar app.jar71EXPOSE 808072ENTRYPOINT ["java", "-jar", "app.jar"]73```7475### Go7677```dockerfile78FROM golang:1.22-alpine AS build79WORKDIR /app80COPY go.* ./81RUN go mod download82COPY . .83RUN CGO_ENABLED=0 go build -o main .8485FROM alpine:latest86WORKDIR /app87COPY --from=build /app/main .88EXPOSE 808089CMD ["./main"]90```9192## .dockerignore9394```95.git96node_modules97__pycache__98*.pyc99.env100.azure101```102103## Best Practices104105- Use slim/alpine base images106- Multi-stage builds for compiled languages107- Non-root user when possible108- Include health check endpoint in app109110## Runtime-Specific Configuration111112For production settings specific to each runtime:113114| Runtime | Reference |115|---------|-----------|116| Node.js/Express | [runtimes/nodejs.md](../../runtimes/nodejs.md) |117