Fixes for all the bullshit
This commit is contained in:
@@ -148,7 +148,7 @@ services:
|
|||||||
- CMD
|
- CMD
|
||||||
- node
|
- node
|
||||||
- -e
|
- -e
|
||||||
- 'require("http").get("http://127.0.0.1:3000/", (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on("error", () => process.exit(1))'
|
- 'require("http").get("http://0.0.0.0:3000/", {timeout: 5000}, (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on("error", () => process.exit(1))'
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
@@ -128,10 +128,10 @@ services:
|
|||||||
QR_API_URL: http://qr_api:8080
|
QR_API_URL: http://qr_api:8080
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
[
|
- CMD
|
||||||
'CMD-SHELL',
|
- node
|
||||||
'node -e "require(''http'').get(''http://127.0.0.1:3000/'', (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on(''error'', () => process.exit(1))"',
|
- -e
|
||||||
]
|
- 'require("http").get("http://0.0.0.0:3000/", {timeout: 5000}, (r) => { r.resume(); process.exit(r.statusCode >= 200 && r.statusCode < 500 ? 0 : 1); }).on("error", () => process.exit(1))'
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
2
qr-api/.npmrc
Normal file
2
qr-api/.npmrc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Force pnpm to run build scripts for better-sqlite3
|
||||||
|
enable-pre-post-scripts=true
|
||||||
@@ -1,25 +1,23 @@
|
|||||||
# Build stage: TypeScript only (no native deps in this stage).
|
# Build stage: use npm (not pnpm) to avoid workspace issues with better-sqlite3.
|
||||||
FROM node:20-bookworm-slim AS builder
|
FROM node:20-bookworm-slim AS builder
|
||||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json pnpm-lock.yaml* ./
|
COPY package.json ./
|
||||||
RUN pnpm install
|
RUN npm install
|
||||||
|
# Verify better-sqlite3 was compiled; fail build if not.
|
||||||
|
RUN test -f node_modules/better-sqlite3/build/Release/better_sqlite3.node || \
|
||||||
|
(echo "ERROR: better-sqlite3.node not found after npm install" && exit 1)
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm run build
|
RUN npm run build
|
||||||
|
RUN npm prune --production
|
||||||
|
|
||||||
# Runtime: install deps here so better-sqlite3 is compiled for this exact image/platform.
|
# Runtime: copy pre-built node_modules from builder.
|
||||||
FROM node:20-bookworm-slim
|
FROM node:20-bookworm-slim
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
# Install build deps needed to compile better-sqlite3; remove after install to keep image small.
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
||||||
COPY package.json pnpm-lock.yaml* ./
|
|
||||||
RUN pnpm install --prod \
|
|
||||||
&& apt-get purge -y python3 make g++ \
|
|
||||||
&& apt-get autoremove -y --purge \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
CMD ["node", "dist/index.js"]
|
CMD ["node", "dist/index.js"]
|
||||||
|
|||||||
Reference in New Issue
Block a user