Files
pocket-id/Dockerfile

54 lines
1.3 KiB
Docker
Raw Normal View History

2025-05-17 11:17:55 -07:00
# This file uses multi-stage builds to build the application from source, including the front-end
# 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
WORKDIR /build
2024-08-12 11:00:25 +02:00
COPY ./frontend/package*.json ./
RUN npm ci
COPY ./frontend ./
RUN BUILD_OUTPUT_PATH=dist npm run build
2024-08-12 11:00:25 +02:00
# Stage 2: Build Backend
FROM golang:1.24-alpine AS backend-builder
ARG BUILD_TAGS
WORKDIR /build
2024-08-12 11:00:25 +02:00
COPY ./backend/go.mod ./backend/go.sum ./
RUN go mod download
COPY ./backend ./
COPY --from=frontend-builder /build/dist ./frontend/dist
COPY .version .version
WORKDIR /build/cmd
RUN VERSION=$(cat /build/.version) \
CGO_ENABLED=0 \
GOOS=linux \
go build \
-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 \
-o /build/pocket-id-backend \
.
2024-08-12 11:00:25 +02:00
# Stage 3: Production Image
FROM alpine
2024-08-12 11:00:25 +02:00
WORKDIR /app
RUN apk add --no-cache curl su-exec
COPY --from=backend-builder /build/pocket-id-backend /app/pocket-id
COPY ./scripts/docker /app/docker
COPY ./scripts/create-one-time-access-token.sh /app/
2024-08-12 11:00:25 +02:00
RUN chmod +x /app/pocket-id /app/create-one-time-access-token.sh && \
find /app/docker -name "*.sh" -exec chmod +x {} \;
2024-08-12 11:00:25 +02:00
EXPOSE 1411
2024-08-12 11:00:25 +02:00
ENV APP_ENV=production
ENTRYPOINT ["sh", "/app/docker/entrypoint.sh"]
CMD ["/app/pocket-id"]