2025-05-17 11:17:55 -07:00
|
|
|
# This file uses multi-stage builds to build the application from source, including the front-end
|
|
|
|
|
|
2025-03-29 15:11:25 -07:00
|
|
|
# Tags passed to "go build"
|
|
|
|
|
ARG BUILD_TAGS=""
|
|
|
|
|
|
2024-08-12 11:00:25 +02:00
|
|
|
# Stage 1: Build Frontend
|
2025-01-27 09:48:20 +01:00
|
|
|
FROM node:22-alpine AS frontend-builder
|
2025-08-10 12:16:30 -05:00
|
|
|
RUN corepack enable
|
|
|
|
|
|
2025-05-17 00:36:58 +02:00
|
|
|
WORKDIR /build
|
2025-08-10 12:16:30 -05:00
|
|
|
|
|
|
|
|
COPY pnpm-workspace.yaml pnpm-lock.yaml ./
|
|
|
|
|
COPY frontend/package.json ./frontend/
|
|
|
|
|
RUN pnpm --filter pocket-id-frontend install --frozen-lockfile
|
|
|
|
|
|
|
|
|
|
COPY ./frontend ./frontend/
|
|
|
|
|
|
|
|
|
|
RUN BUILD_OUTPUT_PATH=dist pnpm --filter pocket-id-frontend run build
|
2024-08-12 11:00:25 +02:00
|
|
|
|
|
|
|
|
# Stage 2: Build Backend
|
2025-08-15 05:33:27 +02:00
|
|
|
FROM golang:1.25-alpine AS backend-builder
|
2025-03-29 15:11:25 -07:00
|
|
|
ARG BUILD_TAGS
|
2025-05-17 00:36:58 +02:00
|
|
|
WORKDIR /build
|
2024-08-12 11:00:25 +02:00
|
|
|
COPY ./backend/go.mod ./backend/go.sum ./
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
|
|
COPY ./backend ./
|
2025-08-10 12:16:30 -05:00
|
|
|
COPY --from=frontend-builder /build/frontend/dist ./frontend/dist
|
2025-05-17 00:36:58 +02:00
|
|
|
COPY .version .version
|
|
|
|
|
|
|
|
|
|
WORKDIR /build/cmd
|
|
|
|
|
RUN VERSION=$(cat /build/.version) \
|
|
|
|
|
CGO_ENABLED=0 \
|
2025-03-29 15:11:25 -07:00
|
|
|
GOOS=linux \
|
|
|
|
|
go build \
|
2025-05-17 00:36:58 +02:00
|
|
|
-tags "${BUILD_TAGS}" \
|
2025-05-17 11:17:55 -07:00
|
|
|
-ldflags="-X github.com/pocket-id/pocket-id/backend/internal/common.Version=${VERSION} -buildid=${VERSION}" \
|
|
|
|
|
-trimpath \
|
2025-07-27 03:03:52 +02:00
|
|
|
-o /build/pocket-id \
|
2025-05-17 00:36:58 +02:00
|
|
|
.
|
2024-08-12 11:00:25 +02:00
|
|
|
|
|
|
|
|
# Stage 3: Production Image
|
2025-05-17 00:36:58 +02:00
|
|
|
FROM alpine
|
2024-08-12 11:00:25 +02:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-05-17 00:36:58 +02:00
|
|
|
RUN apk add --no-cache curl su-exec
|
|
|
|
|
|
2025-07-27 03:03:52 +02:00
|
|
|
COPY --from=backend-builder /build/pocket-id /app/pocket-id
|
2025-05-17 00:36:58 +02:00
|
|
|
COPY ./scripts/docker /app/docker
|
2024-08-12 11:00:25 +02:00
|
|
|
|
2025-05-18 04:22:40 -07:00
|
|
|
RUN chmod +x /app/pocket-id && \
|
2025-05-17 00:36:58 +02:00
|
|
|
find /app/docker -name "*.sh" -exec chmod +x {} \;
|
2024-08-12 11:00:25 +02:00
|
|
|
|
2025-05-17 00:36:58 +02:00
|
|
|
EXPOSE 1411
|
2024-08-12 11:00:25 +02:00
|
|
|
ENV APP_ENV=production
|
|
|
|
|
|
2025-07-04 12:26:01 -07:00
|
|
|
HEALTHCHECK --interval=90s --timeout=5s --start-period=10s --retries=3 CMD [ "/app/pocket-id", "healthcheck" ]
|
|
|
|
|
|
2025-05-17 00:36:58 +02:00
|
|
|
ENTRYPOINT ["sh", "/app/docker/entrypoint.sh"]
|
|
|
|
|
CMD ["/app/pocket-id"]
|