-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (29 loc) · 1.04 KB
/
Dockerfile
File metadata and controls
37 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Use .NET 9 SDK to build
FROM mcr.microsoft.com/dotnet/sdk:10.0.100 AS build
WORKDIR /src
COPY Directory.Build.props ./
# Copy project file and restore dependencies (better layer caching)
COPY src/BuslyCLI.Console/BuslyCLI.Console.csproj ./BuslyCLI.Console/
RUN dotnet restore "BuslyCLI.Console/BuslyCLI.Console.csproj" \
-r linux-musl-x64
# Copy source code and build
COPY src/BuslyCLI.Console/ ./BuslyCLI.Console/
RUN dotnet publish "./BuslyCLI.Console/BuslyCLI.Console.csproj" \
-c Release \
-r linux-musl-x64 \
-o /app/publish \
--no-restore \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-p:TrimMode=partial \
-p:EnableCompressionInSingleFile=true \
-p:SelfContained=true
# Use minimal runtime for smaller image size
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine AS final
WORKDIR /app
# Copy published app
COPY --from=build /app/publish .
# Change ownership to non-root user
RUN chown -R $APP_UID:$APP_UID /app
USER $APP_UID
ENTRYPOINT ["./BuslyCLI.Console"]