-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
131 lines (116 loc) · 3.22 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM crazymax/goxx:latest AS goxx
FROM --platform=$BUILDPLATFORM crazymax/osxcross:11.3 AS osxcross
FROM goxx AS base
ENV GO111MODULE=auto
ENV CGO_ENABLED=1
WORKDIR /src
FROM base AS vendored
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/go/pkg/mod \
go mod tidy && go mod download
FROM vendored AS build
ARG TARGETPLATFORM
ARG RELEASE_VERSION
ARG GO_BUILD_LDFLAGS
RUN --mount=type=cache,sharing=private,target=/var/cache/apt \
--mount=type=cache,sharing=private,target=/var/lib/apt/lists \
goxx-apt-get install -y binutils gcc g++ pkg-config
RUN --mount=type=bind,source=.,rw \
--mount=from=osxcross,target=/osxcross,src=/osxcross,rw \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod <<EOT
BUILDMODE=
if [ "$(. goxx-env && echo $GOOS)" != "windows" ]; then
case "$(. goxx-env && echo $GOARCH)" in
mips*|ppc64)
# pie build mode is not supported on mips architectures
;;
*)
BUILDMODE="-buildmode=pie"
;;
esac
fi
LDFLAGS="$GO_BUILD_LDFLAGS -s -w"
if [ "$(. goxx-env && echo $GOOS)" = "linux" ]; then
LDFLAGS="$LDFLAGS -extldflags -static"
fi
GO_BUILD_TAGS="-tags 'production'"
goxx-go env
goxx-go build -v -o /out/server -trimpath -ldflags "$LDFLAGS" $BUILDMODE $GO_BUILD_TAGS .
EOT
FROM scratch AS artifact
COPY --from=build /out /
FROM --platform=$BUILDPLATFORM postgres:15 AS postgres
FROM --platform=$BUILDPLATFORM debian:12-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq5 ca-certificates iputils-ping
RUN update-ca-certificates
COPY --from=postgres /usr/lib/postgresql/15/bin/pg_dump /usr/local/bin
COPY --from=postgres /usr/lib/postgresql/15/bin/pg_restore /usr/local/bin
RUN mkdir -p /app
RUN chown nobody /app
WORKDIR /app/
COPY conf conf/
COPY data data/
COPY LICENSE .
COPY README.md .
COPY CONTRIBUTING.md .
COPY --from=build /out/server .
ENTRYPOINT [ "/app/server" ]
EXPOSE 3000
EXPOSE 3001
EXPOSE 3002
EXPOSE 3003
EXPOSE 1883
EXPOSE 8080
EXPOSE 8443
ENV PG_USER="smart_home"
ENV PG_PASS="smart_home"
ENV PG_HOST="postgres"
ENV PG_NAME="smart_home"
ENV PG_PORT="5432"
ENV PG_DEBUG="false"
ENV PG_MAX_IDLE_CONNS="10"
ENV PG_MAX_OPEN_CONNS="50"
ENV PG_CONN_MAX_LIFE_TIME="30"
ENV AUTO_MIGRATE="true"
ENV SNAPSHOT_DIR=""
ENV MODE="release"
ENV MQTT_PORT="1883"
ENV MQTT_RETRY_INTERVAL="20"
ENV MQTT_RETRY_CHECK_INTERVAL="20"
ENV MQTT_SESSION_EXPIRY_INTERVAL="0"
ENV MQTT_SESSION_EXPIRE_CHECK_INTERVAL="0"
ENV MQTT_QUEUE_QOS_0_MESSAGES="true"
ENV MQTT_MAX_INFLIGHT="32"
ENV MQTT_MAX_AWAIT_REL="100"
ENV MQTT_MAX_MSG_QUEUE="1000"
ENV MQTT_DELIVER_MODE="1"
ENV LOGGING="true"
ENV COLORED_LOGGING="false"
ENV ALEXA_HOST=""
ENV ALEXA_PORT="3003"
ENV API_HTTP_PORT="3001"
ENV API_HTTPS_PORT="3002"
ENV API_SWAGGER="true"
ENV API_GZIP="false"
ENV LANG="EN"
ENV ROOT_MODE="false"
ENV DOMAIN="localhost"
ENV PPROF="false"
ENV ROOT_SECRET=""
ENV PATH="$PATH:/app"
ENV GATE_API_HTTP_PORT="8080"
ENV GATE_API_HTTPS_PORT="8443"
ENV GATE_API_DEBUG="false"
ENV GATE_API_GZIP="true"
ENV GATE_DOMAIN="localhost"
ENV GATE_PPROF="false"
ENV GATE_HTTPS="false"
ENV GATE_PROXY_TIMEOUT="5"
ENV GATE_PROXY_IDLE_TIMEOUT="10"
ENV GATE_PROXY_SECRET_KEY=""
VOLUME /app/snapshots
VOLUME /app/data
VOLUME /app/conf