-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
94 lines (73 loc) · 2.27 KB
/
Dockerfile
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine as buildnode
ARG TARGETPLATFORM
ARG VERSION
LABEL description="This image builds the Sensor Server"
LABEL vendor="ser.soft GmbH"
LABEL maintainer="[email protected]"
LABEL version="${VERSION}"
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
WORKDIR /sensor-server
RUN <<EOC
set -eux
case "${TARGETPLATFORM}" in
'linux/amd64') export RUNTIME_ID='linux-musl-x64' ;;
'linux/arm64') export RUNTIME_ID='linux-musl-arm64' ;;
*)
echo "Unsupported platform: ${TARGETPLATFORM}"
exit 1
;;
esac
echo -n "${RUNTIME_ID}" > /tmp/runtime-id
EOC
COPY server/*.sln .
WORKDIR /sensor-server/SensorServer
COPY server/SensorServer/*.csproj .
WORKDIR /sensor-server
RUN unset VERSION; \
dotnet restore --runtime "$(cat /tmp/runtime-id)"
COPY server/ ./
RUN <<EOC
set -eux
RUNTIME_ID="$(cat /tmp/runtime-id)"
if echo "${VERSION}" | grep -Eq '^[0-9]+.[0-9]+.[0-9]+'; then
PROJECT_VERSION="${VERSION}"
else
PROJECT_VERSION="0.0.1-${VERSION}"
fi
rm -f appsettings.Development.json
unset VERSION
dotnet publish --no-restore \
--configuration release \
--runtime "${RUNTIME_ID}" \
--no-self-contained \
--output ./dist \
-p:Version="${PROJECT_VERSION}"
EOC
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
ARG VERSION
LABEL description="This image runs the Sensor Server"
LABEL vendor="ser.soft GmbH"
LABEL maintainer="[email protected]"
LABEL version="${VERSION}"
ENV TZ=UTC
ENV SERVER_PORT=8080
ENV ASPNETCORE_URLS=http://+:${SERVER_PORT}
ENV ASPNETCORE_ENVIRONMENT=Production
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN <<EOC
set -eux
apk add --update --no-cache curl icu-libs icu-data-full
mkdir -p /sensor-server/data
addgroup --system --gid 1000 sensor-server
adduser --system --uid 1000 --ingroup sensor-server --home /sensor-server sensor-server
chown -R sensor-server:sensor-server /sensor-server
EOC
WORKDIR /sensor-server
USER sensor-server:sensor-server
EXPOSE ${SERVER_PORT}
COPY bin/docker-healthcheck.sh /usr/local/bin/docker-healthcheck.sh
COPY --from=buildnode /sensor-server/dist/ ./
VOLUME [ "/sensor-server/data" ]
HEALTHCHECK --interval=10s --timeout=3s --start-period=30s \
CMD ["/usr/local/bin/docker-healthcheck.sh"]
ENTRYPOINT ["/sensor-server/SensorServer"]