forked from pushbits/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
47 lines (33 loc) · 1.16 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
FROM docker.io/library/golang:alpine as builder
ARG BUILD_VERSION=0.1.0
# build server
WORKDIR /server
COPY . .
RUN set -ex \
&& apk add --no-cache build-base \
&& go mod download && go mod verify \
&& PB_BUILD_VERSION="$BUILD_VERSION" make build \
&& chmod +x /server/out/pushbits
# build cli
RUN apk add --no-cache git \
&& git clone https://github.com/nonedotone/pushbits-cli.git /cli \
&& cd /cli && go mod download && go mod verify \
&& PBCLI_BUILD_VERSION="$BUILD_VERSION" make build \
&& chmod +x /cli/out/pbcli
FROM docker.io/library/alpine
ARG USER_ID=1000
ENV PUSHBITS_HTTP_PORT="8080"
EXPOSE 8080
WORKDIR /app
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /server/out/pushbits ./pushbits
COPY --from=builder /cli/out/pbcli ./pbcli
RUN set -ex \
&& apk add --no-cache ca-certificates curl \
&& update-ca-certificates \
&& mkdir -p /data \
&& ln -s /data/pushbits.db /app/pushbits.db \
&& ln -s /data/config.yml /app/config.yml
USER ${USER_ID}
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD curl --fail http://localhost:$PUSHBITS_HTTP_PORT/health || exit 1
ENTRYPOINT ["./pushbits"]