feat(auth): add Dockerfile for containerization

This commit is contained in:
Sam 2026-02-02 09:55:10 +08:00
parent db831758d9
commit dcb1a0add8
3 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,74 @@
# Task 8: Create Dockerfile
## Task Description
**Files:**
- Create: `src/Fengling.AuthService/Dockerfile`
- Create: `src/Fengling.AuthService/.dockerignore`
## Implementation Steps
### Step 1: Create Dockerfile
Create: `src/Fengling.AuthService/Dockerfile`
```dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ["Fengling.AuthService.csproj", "./"]
RUN dotnet restore "Fengling.AuthService.csproj"
COPY . .
WORKDIR "/src"
RUN dotnet build "Fengling.AuthService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Fengling.AuthService.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Fengling.AuthService.dll"]
```
### Step 2: Create .dockerignore
Create: `src/Fengling.AuthService/.dockerignore`
```
bin/
obj/
Dockerfile
.dockerignore
*.md
```
### Step 3: Commit
```bash
git add src/Fengling.AuthService/Dockerfile src/Fengling.AuthService/.dockerignore
git commit -m "feat(auth): add Dockerfile for containerization"
```
## Context
This task adds Docker support for containerization. The multi-stage Dockerfile builds the project in a SDK container and copies only the runtime to a lightweight runtime container.
**Tech Stack**: Docker, .NET 10.0
## Verification
- [ ] Dockerfile created with multi-stage build
- [ ] .dockerignore created
- [ ] Dockerfile uses .NET 10.0
- [ ] Exposes port 80
- [ ] Committed to git
## Notes
- Multi-stage build reduces image size
- Only runtime container in final image
- Ready for Kubernetes deployment

View File

@ -0,0 +1,5 @@
bin/
obj/
Dockerfile
.dockerignore
*.md

View File

@ -0,0 +1,19 @@
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ["Fengling.AuthService.csproj", "./"]
RUN dotnet restore "Fengling.AuthService.csproj"
COPY . .
WORKDIR "/src"
RUN dotnet build "Fengling.AuthService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Fengling.AuthService.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Fengling.AuthService.dll"]