-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
33 lines (31 loc) · 1.1 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
FROM node:20-alpine AS ui-builder
ARG ui_mode=production
WORKDIR /src/ui
RUN corepack enable pnpm
COPY ui/package.json ui/pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
COPY ui ./
RUN pnpm vite build --mode ${ui_mode}
FROM golang:1.23-alpine AS api-builder
ARG version=unknown
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,id=golang,target=/go/pkg/mod/ \
go mod download
COPY . .
COPY --from=ui-builder /src/ui/dist ./ui/dist
RUN --mount=type=cache,id=golang,target=/go/pkg/mod/ \
--mount=type=cache,id=golang,target=/root/.cache/go-build \
go build -o /bin/goce -ldflags "-s -w -X main.version=${version}" ./cmd/goce &&\
go build -o /bin/godl -ldflags "-s -w" ./cmd/tools/godl
FROM alpine:3.20
RUN apk add ca-certificates tzdata curl tar git
RUN addgroup -g 1000 goce && adduser -u 1000 -DG goce goce &&\
mkdir /opt/data && chown goce: /opt/data
USER goce
RUN mkdir -p ~/sdk ~/go/pkg/mod ~/.cache/go-build
WORKDIR /opt
COPY --from=api-builder --chown=goce:goce /bin/goce /bin/godl ./
EXPOSE 9000
CMD ["/opt/goce"]