-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
71 lines (49 loc) · 1.71 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
# Stage 1: Build web
FROM --platform=${BUILDPLATFORM} docker.io/library/node:23.4 AS web-builder
WORKDIR /work
COPY ./Makefile /work/Makefile
COPY ./web/package.json /work/web/package.json
COPY ./web/package-lock.json /work/web/package-lock.json
RUN --mount=type=secret,id=CODECOV_TOKEN \
cd web && npm ci
COPY ./web /work/web
ENV NODE_ENV=production
RUN make web-build
# Stage 2: Prepare external files
FROM --platform=${BUILDPLATFORM} docker.io/library/debian:stable-slim AS downloader
WORKDIR /workspace
COPY Makefile .
RUN apt-get update && \
apt-get install -y --no-install-recommends make curl ca-certificates && \
mkdir -p ./internal/macoui ./internal/blocky && \
make internal/resources/macoui internal/resources/blocky
# Stage 3: Build
FROM --platform=${BUILDPLATFORM} docker.io/library/golang:1.23 AS builder
ARG GIT_BUILD_HASH
ARG TARGETARCH
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=${TARGETARCH}
WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
COPY . .
COPY --from=downloader /workspace/ /workspace/
COPY --from=web-builder /work/web/dist/ /workspace/web/dist/
RUN make docker-build
# Stage 4: Run
FROM docker.io/library/debian:stable-slim
WORKDIR /
RUN apt-get update && \
apt-get install -y --no-install-recommends nmap bash-completion bash ca-certificates && \
mkdir -p /etc/bash_completion.d/ && \
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/ && \
mkdir /data && \
chown 65532:65532 /data && \
echo ". /etc/bash_completion" >> /etc/bash.bashrc
COPY --from=builder /workspace/gravity /bin/gravity
RUN /bin/gravity completion bash > /etc/bash_completion.d/gravity
ENTRYPOINT ["/bin/gravity"]
CMD [ "server" ]