File size: 870 Bytes
364a2ae
 
 
 
 
 
 
 
 
 
eb5ac74
364a2ae
 
 
 
 
 
 
 
 
 
cfa20a7
d23130d
 
364a2ae
 
d23130d
 
364a2ae
 
1b194cc
df4441b
d23130d
 
364a2ae
 
d23130d
 
 
364a2ae
 
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
# ---------- Build stage ----------
ARG GO_VERSION=1.24
FROM golang:${GO_VERSION}-bookworm AS builder
WORKDIR /src

RUN apt-get update && apt-get install -y git

# Clone sources from GitHub
RUN git clone https://github.com/boltrunner/gcli2api.git .

COPY server.go ./internal/server/server.go

# Optionally download modules, build
RUN go mod download
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
    go build -trimpath -ldflags="-s -w" -o /out/gcli2api .

# ---------- Runtime stage ----------
FROM alpine:3.20 AS runtime

WORKDIR /app

USER root

RUN apk --no-cache add ca-certificates

RUN chmod -R 777 /app

COPY --from=builder /out/gcli2api /app/gcli2api

COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

RUN adduser -D -H -u 10001 appuser

USER 10001

ENTRYPOINT ["/entrypoint.sh"]

CMD ["server", "-c", "/app/config.json"]