Files
hops/Dockerfile
T
tanshu a7c9324170 Model the build on mozimo and target emily
- Makefile: PLATFORMS, tags :<commit> and :main, build-check with --pull.
- deploy.sh: push, guards, git pull --ff-only, optional --prune, image_tag.
- Replace .containerignore with .dockerignore.
- Add the opt-in image prune to the hops role.
- Tag the Caddyfile task so --skip-tags caddy works before DNS cutover.
- Trim comments and rewrite build and deploy text in plain prose.
2026-10-20 17:47:49 +05:30

69 lines
2.1 KiB
Docker

# syntax=docker/dockerfile:1
# Frontend dependencies. Runs on the build platform.
FROM --platform=$BUILDPLATFORM node:lts-trixie-slim AS deps
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN --mount=type=cache,target=/root/.npm \
npm ci
# Frontend build. Runs on the build platform.
FROM --platform=$BUILDPLATFORM node:lts-trixie-slim AS builder
WORKDIR /app/frontend
COPY --from=deps /app/frontend/node_modules ./node_modules
COPY frontend/ ./
ENV NODE_ENV=production
RUN npm run build
# PocketBase binary for the target architecture. Runs on the build platform.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS pb-downloader
ARG TARGETARCH
ARG PB_VERSION=0.40.2
RUN apk add --no-cache curl unzip ca-certificates \
&& case "${TARGETARCH}" in \
amd64) PB_ARCH="amd64" ;; \
arm64) PB_ARCH="arm64" ;; \
arm) PB_ARCH="armv7" ;; \
*) echo "Unsupported target architecture: ${TARGETARCH}" >&2; exit 1 ;; \
esac \
&& curl -fsSL -o /tmp/pb.zip "https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_${PB_ARCH}.zip" \
&& unzip /tmp/pb.zip -d /app \
&& chmod +x /app/pocketbase \
&& rm -f /tmp/pb.zip
# Runtime image. Runs on the target architecture.
FROM node:lts-trixie-slim AS runner
LABEL maintainer="Amritanshu <docker@tanshu.com>"
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=pb-downloader /app/pocketbase /app/pocketbase
COPY backend/pb_migrations /app/pb_migrations
COPY --from=builder /app/frontend/.output /app/frontend/.output
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
ENV NODE_ENV=production \
PORT=3000 \
HOST=0.0.0.0 \
PB_DATA_DIR=/app/pb_data
VOLUME ["/app/pb_data"]
EXPOSE 3000 8090
# podman drops this when it builds an OCI image. The Quadlet unit repeats it.
HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \
CMD curl -fsS http://127.0.0.1:8090/api/health > /dev/null && curl -fsS http://127.0.0.1:3000 > /dev/null || exit 1
ENTRYPOINT ["/app/docker-entrypoint.sh"]