Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (53 loc) · 1.86 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (53 loc) · 1.86 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## Multi-stage build for FileHorizon (.NET 8)
## Build args (override as needed):
# BUILD_CONFIGURATION=Release
# UID=1001
# GID=1001
# VERSION= (optional; .git is not in the build context, so MinVer cannot read tags here)
ARG BUILD_CONFIGURATION=Release
ARG UID=1001
ARG GID=1001
############################
## Build Stage
############################
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION=Release
ARG VERSION=
WORKDIR /src
# Copy solution and project files first to leverage layer caching
COPY FileHorizon.sln ./
COPY src/Directory.Build.props src/
COPY src/FileHorizon.Application/FileHorizon.Application.csproj src/FileHorizon.Application/
COPY src/FileHorizon.Host/FileHorizon.Host.csproj src/FileHorizon.Host/
COPY test/FileHorizon.Application.Tests/FileHorizon.Application.Tests.csproj test/FileHorizon.Application.Tests/
# Restore
RUN dotnet restore FileHorizon.sln --nologo
# Copy full source
COPY . .
# Build & publish (self-contained trimming not applied yet to keep diagnostics easier)
RUN dotnet publish src/FileHorizon.Host/FileHorizon.Host.csproj \
-c ${BUILD_CONFIGURATION} \
-o /app/publish \
--no-restore \
--nologo \
-p:MinVerVersionOverride=${VERSION}
############################
## Runtime Stage (ASP.NET Core runtime image)
############################
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
ENV ASPNETCORE_URLS=http://0.0.0.0:8080 \
DOTNET_EnableDiagnostics=0
# Create non-root user/group
ARG UID=1001
ARG GID=1001
RUN groupadd -g ${GID} appgroup \
&& useradd -u ${UID} -g appgroup -m appuser \
&& mkdir -p /app/data /app/config \
&& chown -R appuser:appgroup /app
WORKDIR /app
COPY --from=build /app/publish ./
# Expose health port (8080) – actual port mapping decided at run
EXPOSE 8080
USER appuser
# Default: run the host
ENTRYPOINT ["dotnet", "FileHorizon.Host.dll"]