forked from thesouldev/goboxd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (32 loc) · 1.2 KB
/
Copy pathDockerfile
File metadata and controls
36 lines (32 loc) · 1.2 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
# syntax=docker/dockerfile:1.7
ARG GO_VERSION=1.23
ARG DEBIAN_VERSION=bookworm
ARG NSJAIL_VERSION=3.4
# ---- Build nsjail from source ----
FROM debian:${DEBIAN_VERSION}-slim AS nsjail-builder
ARG NSJAIL_VERSION
ENV NSJAIL_VERSION=${NSJAIL_VERSION}
COPY scripts /opt/scripts
RUN /opt/scripts/install.sh system nsjail
# ---- Builder / dev image (Go + linters + nsjail + language toolchains) ----
FROM golang:${GO_VERSION}-${DEBIAN_VERSION} AS builder
COPY scripts /opt/scripts
COPY --from=nsjail-builder /usr/local/bin/nsjail /usr/local/bin/nsjail
RUN /opt/scripts/install.sh nsjail-runtime langs
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 \
&& go install github.com/air-verse/air@v1.61.7
WORKDIR /src
COPY go.mod ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/goboxd ./cmd/goboxd
# ---- Runtime image ----
FROM debian:${DEBIAN_VERSION}-slim AS runtime
COPY scripts /opt/scripts
COPY --from=nsjail-builder /usr/local/bin/nsjail /usr/local/bin/nsjail
RUN /opt/scripts/install.sh all \
&& rm -rf /opt/scripts
COPY --from=builder /out/goboxd /usr/local/bin/goboxd
COPY configs/ /configs/
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/goboxd"]