-
Notifications
You must be signed in to change notification settings - Fork 0
/
tourcalc.experiment.docker.from-scratch
52 lines (42 loc) · 2.21 KB
/
tourcalc.experiment.docker.from-scratch
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
# Experimental. Not tested, not even run. Just built
# Self-contained app, with trimming
# Produces ~131M docker image (instead of ~300M when framework-dependent (that is default) and ~187 when no trimming)
# Only linux-arm64 is built-in here (hardcoded in this docker file)
# to build:
# podman build -f tourcalc.run.docker.from-scratch -t tourcalcdev-s:dev-s --no-cache .
FROM scratch AS base
WORKDIR /app
#RUN dotnet --version
EXPOSE 80
EXPOSE 443
#### Build and publish backend
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS publishtc
WORKDIR /src
COPY . .
WORKDIR "/src/TCBlazor/Server"
RUN export TZ='Europe/Moscow' && export DT="$(date +"%Y%m%d-%H%M%S")" && \
dotnet publish \
--sc true \
--runtime linux-arm64 \
--version-suffix $DT \
-p:PublishTrimmed=true \
"TCBlazor.Server.csproj" -c Release -o /app
WORKDIR /app
# for tourcalc.run.docker only. DO NOT copy to tourcalc.docker (that is basically for build by ci/cd)
# replace buildnum and buildver
RUN export TZ='Europe/Moscow' && export DT="$(date +"%Y%m%d-%H%M%S")" && grep -Irl "#{Build.BuildNumber}#" . | xargs sed -i 's/#{Build.BuildNumber}#/'$DT'/g'
RUN grep -Irl "#{Build.SourceBranch}#" . | xargs sed -i 's/#{Build.SourceBranch}#/local/g'
FROM base AS final
WORKDIR /app
COPY --from=publishtc /app .
#RUN ls -Rla /app
ENTRYPOINT ["dotnet", "TCBlazor.Server.dll"]
### README
#build: podman build -f tourcalc.run.docker -t tourcalc:dev --no-cache .
#DEV build: podman build -f tourcalc.run.docker -t tourcalcdev:dev --no-cache .
#run: podman run -p 8080:80 -e StorageType=InMemory localhost/tourcalc:dev
#run daemon (detached): podman run -d -p 8080:80 --env-file ~/config/tourcalc.env localhost/tourcalc:dev
#run listening local: podman run -d -p 127.0.0.1:8080:80 --env-file ~/config/tourcalc.env localhost/tourcalc:dev
#DEV run listening local: podman run -d -p 127.0.0.1:8082:80 --env-file ~/config/tourcalc.env --name tourcalcdev localhost/tourcalcdev:dev
# DEV alltogether
# podman build -f tourcalc.run.docker -t tourcalcdev:dev --no-cache . && podman stop tourcalcdev && podman rm tourcalcdev && podman run -d -p 127.0.0.1:8082:80 --env-file ~/config/tourcalc.env --name tourcalcdev localhost/tourcalcdev:dev