-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathContainerfile
More file actions
101 lines (82 loc) · 4.08 KB
/
Copy pathContainerfile
File metadata and controls
101 lines (82 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Roots of The Valley — single-stage build
# When BASE_IMAGE=rotv-base, infrastructure layers are pre-baked (fast CI builds)
# When BASE_IMAGE=ubi10-core, everything builds from scratch (local dev)
ARG BASE_IMAGE=quay.io/crunchtools/ubi10-core:latest
FROM ${BASE_IMAGE}
LABEL maintainer="fatherlinux <scott.mccarty@crunchtools.com>"
LABEL description="Roots of The Valley - Cuyahoga Valley National Park destination explorer"
# Install Node.js and Playwright/Chromium system dependencies
# No RHSM needed — all packages in UBI + pgdg repos
# When using rotv-base, these are already installed (cache hit / no-op)
RUN dnf install -y nodejs npm \
nspr nss alsa-lib atk cups-libs gtk3 \
libXcomposite libXdamage libXrandr libxkbcommon \
mesa-libgbm pango libdrm \
libxshmfence libX11 libXext libXfixes \
&& dnf clean all
# Install Playwright globally with Chromium (pinned to match backend/package.json)
RUN npm install -g playwright@1.58.1 && npx playwright install chromium
# Add PostgreSQL 17 + PostGIS from official pgdg repository
# RHSM registration provides RHEL BaseOS/AppStream (required for boost-serialization → SFCGAL → postgis35_17)
# EPEL provides additional PostGIS dependencies (hdf5, xerces-c)
RUN --mount=type=secret,id=activation_key \
--mount=type=secret,id=org_id \
if [ -s /run/secrets/activation_key ] && [ -s /run/secrets/org_id ]; then \
subscription-manager register \
--activationkey="$(cat /run/secrets/activation_key)" \
--org="$(cat /run/secrets/org_id)"; \
fi && \
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm && \
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-10-x86_64/pgdg-redhat-repo-latest.noarch.rpm && \
dnf install -y postgresql17-server postgresql17 postgis35_17 && \
subscription-manager unregister 2>/dev/null || true && \
dnf clean all
# Create symlinks for PostgreSQL commands
RUN ln -sf /usr/pgsql-17/bin/initdb /usr/local/bin/initdb && \
ln -sf /usr/pgsql-17/bin/pg_ctl /usr/local/bin/pg_ctl && \
ln -sf /usr/pgsql-17/bin/postgres /usr/local/bin/postgres && \
ln -sf /usr/pgsql-17/bin/psql /usr/local/bin/psql && \
ln -sf /usr/pgsql-17/bin/pg_isready /usr/local/bin/pg_isready
# PostgreSQL user (runs as uid 70 for pgdg compatibility)
RUN useradd -u 70 -m -s /bin/bash postgres || true
# PostgreSQL data directory (bind-mounted at runtime)
ENV PGDATA=/data/pgdata
RUN mkdir -p /data/pgdata && chown postgres:postgres /data/pgdata
# Environment
ENV NODE_ENV=development PORT=8080 STATIC_PATH=/app/public
ENV PGHOST=localhost PGPORT=5432 PGDATABASE=rotv PGUSER=postgres PGPASSWORD=rotv
WORKDIR /app
# Build frontend
# Fix: force NODE_ENV=production for the Vite build only — the global
# ENV NODE_ENV=development (set above, required by the backend at runtime)
# otherwise makes Vite emit a dev React bundle (jsxDEV + StrictMode
# double-mount, larger/slower). Scoped to this RUN so runtime env is unchanged. (#556)
COPY frontend/package*.json ./frontend/
RUN cd frontend && npm install
COPY frontend/ ./frontend/
RUN cd frontend && NODE_ENV=production npm run build
# Install backend dependencies
# BUILD_ENV=test includes devDependencies (vitest) for CI
ARG BUILD_ENV=production
COPY backend/package*.json ./
RUN if [ "$BUILD_ENV" = "test" ]; then npm install; else npm install --omit=dev; fi
# Copy backend code
COPY backend/ ./
# Move built frontend to public directory. Test builds keep the frontend
# source at /frontend so backend unit tests can import pure frontend utils
# (tests/*.unit.test.js -> ../../frontend/src/... matches the host layout).
RUN mv frontend/dist public && \
if [ "$BUILD_ENV" = "test" ]; then mkdir -p /frontend && mv frontend/src /frontend/src; fi && \
rm -rf frontend
# Copy systemd units and scripts
COPY rootfs/ /
# Make scripts executable and enable services
RUN chmod +x /usr/local/bin/rotv-init.sh && \
systemctl enable postgresql rotv-init rotv-backend
# Create directory for environment file
RUN mkdir -p /etc/rotv
EXPOSE 8080
EXPOSE 25
EXPOSE 3001
STOPSIGNAL SIGRTMIN+3
CMD ["/sbin/init"]