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
|
2024-08-12 11:00:25 +02:00
|
|
|
WORKDIR /app/frontend
|
|
|
|
|
COPY ./frontend/package*.json ./
|
|
|
|
|
RUN npm ci
|
|
|
|
|
COPY ./frontend ./
|
|
|
|
|
RUN npm run build
|
|
|
|
|
RUN npm prune --production
|
|
|
|
|
|
|
|
|
|
# Stage 2: Build Backend
|
2024-08-24 12:43:22 +02:00
|
|
|
FROM golang:1.23-alpine AS backend-builder
|
2025-03-29 15:11:25 -07:00
|
|
|
ARG BUILD_TAGS
|
2024-08-12 11:00:25 +02:00
|
|
|
WORKDIR /app/backend
|
|
|
|
|
COPY ./backend/go.mod ./backend/go.sum ./
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
|
|
RUN apk add --no-cache gcc musl-dev
|
|
|
|
|
|
|
|
|
|
COPY ./backend ./
|
|
|
|
|
WORKDIR /app/backend/cmd
|
2025-03-29 15:11:25 -07:00
|
|
|
RUN CGO_ENABLED=1 \
|
|
|
|
|
GOOS=linux \
|
|
|
|
|
go build \
|
|
|
|
|
-tags "${BUILD_TAGS}" \
|
|
|
|
|
-o /app/backend/pocket-id-backend \
|
|
|
|
|
.
|
2024-08-12 11:00:25 +02:00
|
|
|
|
|
|
|
|
# Stage 3: Production Image
|
2025-01-27 09:48:20 +01:00
|
|
|
FROM node:22-alpine
|
2025-01-20 18:50:58 +08:00
|
|
|
# Delete default node user
|
2024-11-21 18:44:43 +01:00
|
|
|
RUN deluser --remove-home node
|
|
|
|
|
|
2024-11-24 18:53:32 +01:00
|
|
|
RUN apk add --no-cache caddy curl su-exec
|
2024-09-09 10:29:41 +02:00
|
|
|
COPY ./reverse-proxy /etc/caddy/
|
2024-08-12 11:00:25 +02:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
COPY --from=frontend-builder /app/frontend/build ./frontend/build
|
|
|
|
|
COPY --from=frontend-builder /app/frontend/node_modules ./frontend/node_modules
|
|
|
|
|
COPY --from=frontend-builder /app/frontend/package.json ./frontend/package.json
|
|
|
|
|
|
|
|
|
|
COPY --from=backend-builder /app/backend/pocket-id-backend ./backend/pocket-id-backend
|
|
|
|
|
|
|
|
|
|
COPY ./scripts ./scripts
|
2025-03-13 14:18:48 +01:00
|
|
|
RUN chmod +x ./scripts/**/*.sh
|
2024-08-12 11:00:25 +02:00
|
|
|
|
2024-10-30 11:53:36 +01:00
|
|
|
EXPOSE 80
|
2024-08-12 11:00:25 +02:00
|
|
|
ENV APP_ENV=production
|
|
|
|
|
|
2024-11-21 18:44:43 +01:00
|
|
|
ENTRYPOINT ["sh", "./scripts/docker/create-user.sh"]
|
2025-03-28 02:00:55 -07:00
|
|
|
CMD ["sh", "./scripts/docker/entrypoint.sh"]
|