diff --git a/Dockerfile b/Dockerfile index fb77e40..0437fbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ ARG ui_mode=production WORKDIR /src/ui RUN corepack enable pnpm COPY ui/package.json ui/pnpm-lock.yaml ./ -RUN pnpm install +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} @@ -11,18 +12,19 @@ FROM golang:1.23-alpine AS api-builder ARG version=unknown WORKDIR /src COPY go.mod go.sum ./ -RUN go mod download +RUN --mount=type=cache,id=golang,target=/go/pkg/mod/ \ + go mod download COPY . . COPY --from=ui-builder /src/ui/dist ./ui/dist -RUN \ - 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 +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 +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