Files
Termix/docker/Dockerfile
T

113 lines
3.5 KiB
Docker
Raw Normal View History

2025-10-01 15:40:10 -05:00
# Stage 1: Install dependencies
+5
2026-08-19 14:12:06 -05:00
FROM node:24-slim AS deps
2025-08-07 02:20:27 -05:00
WORKDIR /app
+7
2025-11-05 10:36:16 -06:00
RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/*
2025-08-07 02:20:27 -05:00
COPY package*.json ./
2026-05-06 15:12:07 -05:00
COPY .npmrc ./
COPY vendor ./vendor
2025-08-07 02:20:27 -05:00
2026-06-04 15:16:53 -04:00
COPY scripts/patch-guacamole-lite.cjs ./scripts/
2026-05-06 15:12:07 -05:00
RUN npm ci --ignore-scripts && \
2026-06-04 15:16:53 -04:00
node scripts/patch-guacamole-lite.cjs && \
2025-08-07 02:20:27 -05:00
npm cache clean --force
# Stage 2: Build frontend
FROM deps AS frontend-builder
WORKDIR /app
COPY . .
2025-10-01 15:40:10 -05:00
RUN find public/fonts -name "*.ttf" ! -name "*Regular.ttf" ! -name "*Bold.ttf" ! -name "*Italic.ttf" -delete
2025-08-07 02:20:27 -05:00
2025-10-01 15:40:10 -05:00
RUN npm cache clean --force && \
2026-01-02 03:21:45 -06:00
NODE_OPTIONS="--max-old-space-size=3072" npm run build
2025-10-01 15:40:10 -05:00
# Stage 3: Build backend
2025-08-07 02:20:27 -05:00
FROM deps AS backend-builder
WORKDIR /app
COPY . .
2026-05-06 15:12:07 -05:00
RUN npm rebuild better-sqlite3
2025-09-12 14:42:00 -05:00
RUN npm run build:backend
2025-08-07 02:20:27 -05:00
+5
2026-08-19 14:12:06 -05:00
# Stage 4: Download OPKSSH binary for the target platform so the image works offline
FROM node:24-slim AS opkssh-downloader
ARG TARGETARCH
ARG OPKSSH_VERSION=v0.16.0
WORKDIR /opkssh
RUN apt-get update && apt-get install -y curl ca-certificates && rm -rf /var/lib/apt/lists/*
RUN case "$TARGETARCH" in \
amd64) OPKSSH_ARCH=amd64 ;; \
arm64) OPKSSH_ARCH=arm64 ;; \
*) echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; \
esac && \
curl -fSL -o "opkssh-linux-${OPKSSH_ARCH}" \
"https://github.com/openpubkey/opkssh/releases/download/${OPKSSH_VERSION}/opkssh-linux-${OPKSSH_ARCH}" && \
chmod 755 "opkssh-linux-${OPKSSH_ARCH}" && \
echo -n "$OPKSSH_VERSION" > version.txt
# Stage 5: Production dependencies only
FROM node:24-slim AS production-deps
2025-08-07 02:20:27 -05:00
WORKDIR /app
2025-10-01 15:40:10 -05:00
RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/*
2025-08-07 02:20:27 -05:00
COPY package*.json ./
2026-05-06 15:12:07 -05:00
COPY .npmrc ./
COPY vendor ./vendor
2025-08-07 02:20:27 -05:00
2026-06-04 15:16:53 -04:00
COPY scripts/patch-guacamole-lite.cjs ./scripts/
2026-05-06 15:12:07 -05:00
RUN npm ci --omit=dev --ignore-scripts && \
2026-06-04 15:16:53 -04:00
node scripts/patch-guacamole-lite.cjs && \
npm rebuild better-sqlite3 bcryptjs ssh2 && \
2025-08-07 02:20:27 -05:00
npm cache clean --force
+5
2026-08-19 14:12:06 -05:00
# Stage 6: Final optimized image
FROM node:24-slim
2025-10-01 15:40:10 -05:00
WORKDIR /app
2025-08-07 02:20:27 -05:00
ENV DATA_DIR=/app/data \
PORT=8080 \
+2
2026-07-26 18:47:27 -05:00
NODE_ENV=production \
POSTHOG_API_KEY=phc_xM8UznirsFxUkGE68gH4jzeqevf4kh76wGw7Ci7hH2dd
2025-08-07 02:20:27 -05:00
2026-06-21 15:55:41 -05:00
RUN apt-get update && apt-get install -y nginx gettext-base openssl ca-certificates gosu wget certbot python3-certbot-dns-cloudflare && \
+4
2026-02-12 22:28:13 -06:00
update-ca-certificates && \
2025-10-01 15:40:10 -05:00
rm -rf /var/lib/apt/lists/* && \
2026-05-06 15:12:07 -05:00
mkdir -p /app/data /app/uploads /app/data/.opk /app/nginx /tmp/nginx && \
chown -R node:node /app /tmp/nginx && \
chmod 755 /app/data /app/uploads /app/data/.opk /app/nginx /tmp/nginx
2025-08-07 02:20:27 -05:00
+1
2025-12-31 22:20:12 -06:00
COPY docker/nginx.conf /app/nginx/nginx.conf.template
COPY docker/nginx-https.conf /app/nginx/nginx-https.conf.template
2025-08-07 02:20:27 -05:00
+1
2025-12-31 22:20:12 -06:00
COPY --chown=node:node --from=frontend-builder /app/dist /app/html
2025-08-07 02:20:27 -05:00
2025-10-01 15:40:10 -05:00
COPY --chown=node:node --from=production-deps /app/node_modules /app/node_modules
COPY --chown=node:node --from=backend-builder /app/dist/backend ./dist/backend
+5
2026-08-19 14:12:06 -05:00
COPY --chown=node:node --from=opkssh-downloader /opkssh /app/opkssh-bundled
2025-10-01 15:40:10 -05:00
COPY --chown=node:node package.json ./
+3
2026-08-06 14:41:39 -05:00
# Schema for Postgres and MySQL. Unused by the default SQLite deployment, which
# builds its tables at startup instead.
COPY --chown=node:node drizzle ./drizzle
2025-08-07 02:20:27 -05:00
VOLUME ["/app/data"]
2026-06-29 13:28:26 -05:00
EXPOSE ${PORT} 30001 30002 30003 30004 30005 30006 30007 30008 30009 30010 30011 30012
2025-08-07 02:20:27 -05:00
+5
2026-03-08 18:02:14 -05:00
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD wget -q -O /dev/null http://localhost:30001/health || exit 1
2026-01-24 19:49:42 -06:00
2025-08-07 02:20:27 -05:00
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
+1
2025-12-31 22:20:12 -06:00
+7
2025-11-05 10:36:16 -06:00
CMD ["/entrypoint.sh"]