Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (38 loc) · 1.53 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (38 loc) · 1.53 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=dev
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 \
GOOS="${TARGETOS:-linux}" \
GOARCH="${TARGETARCH:-amd64}" \
go build \
-trimpath \
-ldflags="-s -w -X main.version=${VERSION}" \
-o /out/opencode2api ./cmd/opencode2api
FROM alpine:3.22
RUN apk add --no-cache ca-certificates su-exec tzdata \
&& addgroup -S opencode2api \
&& adduser -S -G opencode2api -h /var/lib/opencode2api opencode2api \
&& mkdir -p /app /var/lib/opencode2api \
&& chown -R opencode2api:opencode2api /app /var/lib/opencode2api
COPY --from=builder /out/opencode2api /usr/local/bin/opencode2api
COPY --chmod=0755 docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY --chown=opencode2api:opencode2api config.example.json /app/config.example.json
COPY LICENSE /usr/share/licenses/opencode2api/LICENSE
LABEL org.opencontainers.image.licenses="GPL-3.0-or-later"
# LISTEN_ADDRESS / WEBUI_LISTEN_ADDRESS are intentionally unset: config.json is
# authoritative. Export them to override the configured listen addresses.
ENV CONFIG_PATH=/var/lib/opencode2api/config.json \
CONFIG_SEED_PATH= \
LISTEN_ADDRESS= \
WEBUI_LISTEN_ADDRESS= \
STATE_DIR=/var/lib/opencode2api
WORKDIR /app
EXPOSE 8080 8081
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1:8080/healthz || exit 1
ENTRYPOINT ["/usr/local/bin/docker-entrypoint"]