-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (61 loc) · 2.44 KB
/
Dockerfile
File metadata and controls
74 lines (61 loc) · 2.44 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
67
68
69
70
71
72
73
74
# Build stage
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
# Install Node.js
RUN apt-get update && apt-get install -y ca-certificates curl gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y nodejs && \
npm install -g pnpm && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /App
COPY ESPresense-companion.sln ./
COPY src/ESPresense.Companion.csproj src/
COPY src/ui/package.json src/ui/pnpm-lock.yaml src/ui/
RUN echo "Building on ${BUILDPLATFORM} for ${TARGETPLATFORM}" && \
echo "TARGETOS=${TARGETOS}" && \
echo "TARGETARCH=${TARGETARCH}" && \
echo "TARGETPLATFORM=${TARGETPLATFORM}" && \
echo "BUILDPLATFORM=${BUILDPLATFORM}"
RUN case "${TARGETARCH}" in \
amd64) dotnet_arch=x64 ;; \
arm64) dotnet_arch=arm64 ;; \
arm) dotnet_arch=arm ;; \
*) echo "Unsupported TARGETARCH=${TARGETARCH}" >&2; exit 1 ;; \
esac && \
dotnet restore src/ESPresense.Companion.csproj -r "${TARGETOS}-${dotnet_arch}"
COPY . ./
RUN case "${TARGETARCH}" in \
amd64) dotnet_arch=x64 ;; \
arm64) dotnet_arch=arm64 ;; \
arm) dotnet_arch=arm ;; \
*) echo "Unsupported TARGETARCH=${TARGETARCH}" >&2; exit 1 ;; \
esac && \
dotnet publish src/ESPresense.Companion.csproj -c Release --no-restore -r "${TARGETOS}-${dotnet_arch}" -o out
# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
ARG TARGETPLATFORM
# Install curl for healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends curl && \
apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /App
EXPOSE 8267 8268
ENV HTTP_PORTS=8267 \
HTTPS_PORTS="" \
OTA_UPDATE_PORT=8268 \
CONFIG_DIR="/config/espresense"
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
COPY --from=build-env /App/out .
LABEL \
io.hass.version="VERSION" \
io.hass.type="addon" \
io.hass.arch="${TARGETPLATFORM}"
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8267/healthz || exit 1
ENTRYPOINT ["dotnet", "ESPresense.Companion.dll"]