Skip to content

Commit 024fe28

Browse files
committed
build: add Dockerfile
1 parent d05ab64 commit 024fe28

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.dockerignore
2+
.env
3+
.git
4+
.gitignore
5+
.vs
6+
.vscode
7+
docker-compose*.yml
8+
docker-compose.dcproj
9+
*.md
10+
LICENSE
11+
*.testsettings
12+
vsts-docs
13+
ServiceFabric
14+
Components
15+
cli-windows
16+
cli-mac
17+
cli-linux
18+
**/bin/
19+
**/obj/
20+
**/node_modules/
21+
**/bower_components/
22+
**/wwwroot/lib/
23+
**/appsettings.Development.json
24+
.github/

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build-env
2+
3+
ARG TARGETARCH
4+
5+
WORKDIR /app
6+
7+
COPY . .
8+
9+
# Private Nuget feed
10+
# NuGet.config file must be in the root of the project
11+
# RUN --mount=type=secret,id=github_token \
12+
# dotnet nuget update source github --username <org> --password $(cat /run/secrets/github_token) --store-password-in-clear-text --configfile NuGet.Config
13+
14+
15+
# restore dependencies
16+
RUN dotnet restore ./src/DemoApi/ -a $TARGETARCH
17+
18+
# build
19+
RUN dotnet publish ./src/DemoApi/ -c Release --no-restore -o out -a $TARGETARCH --self-contained false -p:PublishSingleFile=true
20+
21+
# Create runtime image
22+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim
23+
24+
WORKDIR /app
25+
26+
ENV TZ Europe/Prague
27+
28+
# required to enable read only root filesystem
29+
ENV COMPlus_EnableDiagnostics=0
30+
31+
USER 1001
32+
33+
COPY --from=build-env /app/out .
34+
35+
ENTRYPOINT ["./DemoApi"]

0 commit comments

Comments
 (0)