feat(CUB-65): add multi-stage Dockerfile and .dockerignore for backend
This commit is contained in:
27
backend/.dockerignore
Normal file
27
backend/.dockerignore
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Build artifacts
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
|
||||||
|
# IDE / editor
|
||||||
|
.vs/
|
||||||
|
.vscode/
|
||||||
|
*.user
|
||||||
|
*.suo
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Environment & secrets
|
||||||
|
appsettings.Development.json
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
*.md
|
||||||
|
*.log
|
||||||
30
backend/Dockerfile
Normal file
30
backend/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# ── Stage 1: Build ──────────────────────────────────────────
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Copy csproj first for layer caching — restores before copying source
|
||||||
|
COPY Extrudex.csproj .
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
# Copy the rest of the source
|
||||||
|
COPY . .
|
||||||
|
RUN dotnet publish Extrudex.csproj \
|
||||||
|
-c Release \
|
||||||
|
-o /app/publish \
|
||||||
|
--no-restore
|
||||||
|
|
||||||
|
# ── Stage 2: Runtime ────────────────────────────────────────
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Non-root user for security
|
||||||
|
RUN adduser --disabled-password --gecos "" appuser
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
# Copy published output from build stage
|
||||||
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
|
# ASP.NET Core listens on 8080 by default in .NET 8+
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["dotnet", "Extrudex.dll"]
|
||||||
Reference in New Issue
Block a user