Deployment added.
This commit is contained in:
+25
-17
@@ -1,18 +1,19 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Stage 1: Install frontend dependencies
|
||||
# Stage 1: Install frontend dependencies (Native execution on host architecture)
|
||||
# ------------------------------------------------------------------------------
|
||||
FROM node:lts-trixie-slim AS deps
|
||||
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS deps
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY frontend/package.json frontend/package-lock.json* ./
|
||||
RUN npm ci
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm ci
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Stage 2: Build the TanStack Start frontend
|
||||
# Stage 2: Build the TanStack Start frontend (Native execution on host architecture)
|
||||
# ------------------------------------------------------------------------------
|
||||
FROM node:lts-trixie-slim AS builder
|
||||
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS builder
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY --from=deps /app/frontend/node_modules ./node_modules
|
||||
@@ -22,25 +23,28 @@ ENV NODE_ENV=production
|
||||
RUN npm run build
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Stage 3: Fetch PocketBase binary for target architecture
|
||||
# Stage 3: Fetch PocketBase binary for target architecture (Native host downloader)
|
||||
# ------------------------------------------------------------------------------
|
||||
FROM alpine:3.20 AS pb-downloader
|
||||
ARG TARGETARCH=amd64
|
||||
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 \
|
||||
&& PB_ARCH="${TARGETARCH}" \
|
||||
&& if [ "$TARGETARCH" = "x86_64" ]; then PB_ARCH="amd64"; fi \
|
||||
&& if [ "$TARGETARCH" = "aarch64" ]; then PB_ARCH="arm64"; fi \
|
||||
&& 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
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Stage 4: Production runner
|
||||
# Stage 4: Production runner (Target architecture)
|
||||
# ------------------------------------------------------------------------------
|
||||
FROM node:lts-trixie-slim AS runner
|
||||
FROM node:22-bookworm-slim AS runner
|
||||
LABEL maintainer="Amritanshu <docker@tanshu.com>"
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
@@ -62,10 +66,10 @@ COPY docker-entrypoint.sh /app/docker-entrypoint.sh
|
||||
RUN chmod +x /app/docker-entrypoint.sh
|
||||
|
||||
# Environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PB_DATA_DIR=/app/pb_data
|
||||
ENV NODE_ENV=production \
|
||||
PORT=3000 \
|
||||
HOST=0.0.0.0 \
|
||||
PB_DATA_DIR=/app/pb_data
|
||||
|
||||
# Persistent data volume for PocketBase SQLite database and file storage
|
||||
VOLUME ["/app/pb_data"]
|
||||
@@ -74,4 +78,8 @@ VOLUME ["/app/pb_data"]
|
||||
# Port 8090: PocketBase REST API & Admin UI
|
||||
EXPOSE 3000 8090
|
||||
|
||||
# Health check for both PocketBase and frontend server
|
||||
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"]
|
||||
|
||||
Reference in New Issue
Block a user