-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (36 loc) · 1.42 KB
/
Copy pathDockerfile
File metadata and controls
50 lines (36 loc) · 1.42 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
# syntax=docker/dockerfile:1.7
FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS build
WORKDIR /src
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown
COPY go.mod go.sum ./
RUN go mod download
COPY cmd ./cmd
COPY internal ./internal
RUN set -eux; \
if [ "$TARGETARCH" = "arm" ]; then export GOARM="${TARGETVARIANT#v}"; fi; \
CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH" \
go build -trimpath \
-ldflags "-s -w -X github.com/6Kmfi6HP/opencode2api/internal/app.version=$VERSION -X github.com/6Kmfi6HP/opencode2api/internal/app.commit=$COMMIT -X github.com/6Kmfi6HP/opencode2api/internal/app.date=$DATE" \
-o /out/opencode2api ./cmd/opencode2api
FROM alpine:3.20
RUN apk add --no-cache ca-certificates su-exec tzdata wget \
&& addgroup -S opencode2api \
&& adduser -S -G opencode2api -h /data opencode2api \
&& mkdir -p /app /data \
&& chown -R opencode2api:opencode2api /data
WORKDIR /data
COPY --from=build /out/opencode2api /usr/local/bin/opencode2api
COPY config.example.json /app/config.example.json
COPY docker/entrypoint.sh /entrypoint.sh
ENV OPENCODE2API_PORT=8000 \
OPENCODE2API_CONFIG=/data/config.json \
OPENCODE2API_PASSWORD=123456
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD wget -qO- "http://127.0.0.1:${OPENCODE2API_PORT}/health" >/dev/null || exit 1
ENTRYPOINT ["/entrypoint.sh"]