feat(auth): add Dockerfile for containerization
This commit is contained in:
parent
db831758d9
commit
dcb1a0add8
74
docs/task-08-create-dockerfile.md
Normal file
74
docs/task-08-create-dockerfile.md
Normal 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
|
||||
5
src/Fengling.AuthService/.dockerignore
Normal file
5
src/Fengling.AuthService/.dockerignore
Normal file
@ -0,0 +1,5 @@
|
||||
bin/
|
||||
obj/
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
*.md
|
||||
19
src/Fengling.AuthService/Dockerfile
Normal file
19
src/Fengling.AuthService/Dockerfile
Normal 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"]
|
||||
Loading…
Reference in New Issue
Block a user