refactor(docker): update health check and remove entrypoint script
quality / commitlint (push) Skipped
CD / update-wiki (push) Successful in 6s
quality / changes (push) Successful in 9s
quality / web (push) Skipped
quality / api (push) Skipped
quality / docker-check (push) Skipped
CD / quality (push) Successful in 11s
CD / publish (push) Successful in 1m40s
quality / commitlint (push) Skipped
CD / update-wiki (push) Successful in 6s
quality / changes (push) Successful in 9s
quality / web (push) Skipped
quality / api (push) Skipped
quality / docker-check (push) Skipped
CD / quality (push) Successful in 11s
CD / publish (push) Successful in 1m40s
- Replaced the health check command in the Dockerfile to use a Node.js fetch call for improved reliability. - Removed the custom entrypoint script as it was deemed unnecessary, simplifying the Docker image. - Adjusted health check start period from 10s to 15s for better initialization timing.
This commit is contained in:
@@ -29,31 +29,24 @@ RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
|
||||
&& rm -rf /out/src /out/test /out/.turbo \
|
||||
&& rm -rf /out/node_modules/@cfdm/db/src /out/node_modules/@cfdm/db/scripts /out/node_modules/@cfdm/db/.turbo \
|
||||
&& rm -rf /out/node_modules/@cfdm/shared/src /out/node_modules/@cfdm/shared/.turbo \
|
||||
&& find /out/node_modules/@cfdm -type f \( -name '*.d.ts' -o -name '*.map' -o -name 'tsconfig*.json' -o -name 'vitest.config.ts' -o -name 'drizzle.config.ts' \) -delete \
|
||||
&& find /out/dist -type f \( -name '*.d.ts' -o -name 'tsconfig*.json' -o -name 'vitest.config.ts' -o -name 'drizzle.config.ts' \) -delete
|
||||
&& find /out/dist /out/node_modules/@cfdm -type f \( -name '*.d.ts' -o -name '*.map' -o -name 'tsconfig*.json' -o -name 'vitest.config.ts' -o -name 'drizzle.config.ts' \) -delete
|
||||
|
||||
FROM ${BASE_NODE} AS runtime
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache ca-certificates wget su-exec
|
||||
RUN apk add --no-cache ca-certificates
|
||||
ARG VERSION=dev
|
||||
ARG GIT_SHA=unknown
|
||||
ARG BUILD_TIME=
|
||||
ENV NODE_ENV=production \
|
||||
NODE_OPTIONS=--enable-source-maps \
|
||||
STATIC_DIR=/app/static \
|
||||
DATABASE_URL=sqlite:/data/app.db \
|
||||
SERVER_PORT=8080 \
|
||||
APP_VERSION=${VERSION} \
|
||||
GIT_SHA=${GIT_SHA} \
|
||||
BUILD_TIME=${BUILD_TIME}
|
||||
COPY --from=build --chown=node:node /out ./
|
||||
COPY deploy/docker/cfdm/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh \
|
||||
&& mkdir -p /data \
|
||||
&& chown node:node /data /app
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
COPY --from=build /out ./
|
||||
EXPOSE 8080
|
||||
VOLUME ["/data"]
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD ["wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health"]
|
||||
CMD ["node", "--max-old-space-size=384", "dist/server.js"]
|
||||
CMD ["node", "-e", "fetch('http://127.0.0.1:8080/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
|
||||
CMD ["node", "dist/server.js"]
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
mkdir -p /data
|
||||
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
chown -R node:node /data 2>/dev/null || true
|
||||
chmod -R u+rwX /data 2>/dev/null || true
|
||||
if su-exec node sh -c 'touch /data/.write-test && rm -f /data/.write-test'; then
|
||||
exec su-exec node "$@"
|
||||
fi
|
||||
echo "cfdm: /data is not writable by user node after chown; starting as root" >&2
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
+2
-4
@@ -19,11 +19,9 @@ services:
|
||||
volumes:
|
||||
- ./data:/data
|
||||
restart: unless-stopped
|
||||
init: true
|
||||
mem_limit: 512m
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health"]
|
||||
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:8080/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
start_period: 15s
|
||||
|
||||
Reference in New Issue
Block a user