Files
im_manager/Dockerfile
T

53 lines
1.6 KiB
Docker

# ---- Stage 1: build the Vue frontend ----
FROM node:22-alpine AS web-build
WORKDIR /web
ENV CI=true
RUN npm install -g pnpm
COPY web/package.json web/pnpm-lock.yaml web/pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
COPY web/ .
RUN pnpm run build
# ---- Stage 2: build the Go backend, embedding the frontend build ----
FROM golang:1.24-alpine AS server-build
RUN apk add --no-cache git
WORKDIR /src
COPY server/go.mod server/go.sum ./
RUN go mod download
COPY server/ .
# Same layout the project's own Makefile produces: built frontend goes into
# resource/public/admin/ before packing/building the backend.
RUN rm -rf resource/public/admin && mkdir -p resource/public/admin
COPY --from=web-build /web/dist/ ./resource/public/admin/
# main.go does `import _ "hotgo/internal/packed"`, a file normally generated by
# `gf build` (see server/hack/config.yaml: packSrc/packDst) and gitignored —
# generate it explicitly with the same gf CLI version pinned in go.mod.
RUN go install github.com/gogf/gf/cmd/gf/v2@v2.10.0
RUN gf pack resource internal/packed/packed.go
RUN CGO_ENABLED=0 go build -o /out/hotgo main.go
# ---- Stage 3: runtime ----
FROM alpine:3.22
RUN apk add --no-cache ca-certificates gettext bash tzdata
WORKDIR /app
COPY --from=server-build /src/manifest ./manifest
COPY --from=server-build /src/hack ./hack
COPY --from=server-build /out/hotgo .
COPY server/manifest/docker/entrypoint.sh .
RUN mkdir -p storage/logs storage/data storage/cache storage/diskqueue \
&& chmod +x entrypoint.sh hotgo
HEALTHCHECK --interval=1m --timeout=3s --start-period=20s \
CMD nc -z localhost 8000 || exit 1
EXPOSE 8000
ENTRYPOINT ["./entrypoint.sh"]