All checks were successful
Build and Publish TechDocs / build-and-publish (push) Successful in 55s
- chore: ingest source code 58 files from https://github.com/gothinkster/node-express-realworld-example-app - feat: add platform deployment artifacts - feat: add CI/CD workflow automation
40 lines
1.5 KiB
Docker
40 lines
1.5 KiB
Docker
# Build stage - compile TypeScript with Nx esbuild
|
|
FROM node:20-bullseye-slim AS build
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
RUN npm install
|
|
|
|
COPY nx.json project.json tsconfig*.json ./
|
|
COPY src ./src
|
|
|
|
RUN DATABASE_URL=postgresql://x:x@localhost/placeholder npx prisma generate --schema=src/prisma/schema.prisma
|
|
RUN npx nx build api --configuration=production
|
|
|
|
# Runtime stage — Debian bullseye-slim ships OpenSSL 1.1 (required by Prisma 4.x)
|
|
FROM node:20-bullseye-slim
|
|
WORKDIR /app
|
|
|
|
RUN groupadd --system api && \
|
|
useradd --system -g api api
|
|
|
|
COPY --from=build /app/dist/api/ ./
|
|
|
|
# Copy Prisma generated native client (Debian OpenSSL 1.1 binary)
|
|
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
|
|
# Copy @prisma/client package
|
|
COPY --from=build /app/node_modules/@prisma ./node_modules/@prisma
|
|
# Copy Prisma CLI so migrate/push can run
|
|
COPY --from=build /app/node_modules/prisma ./node_modules/prisma
|
|
COPY --from=build /app/node_modules/.bin/prisma ./node_modules/.bin/prisma
|
|
# Copy schema so Prisma can run migrations at startup
|
|
COPY --from=build /app/src/prisma ./src/prisma
|
|
RUN npm install --omit=dev --ignore-scripts 2>/dev/null || npm install --omit=dev
|
|
|
|
RUN chown -R api:api .
|
|
USER api
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["sh", "-c", "n=0; until node_modules/.bin/prisma migrate deploy --schema=src/prisma/schema.prisma; do n=$((n+1)); if [ $n -ge 30 ]; then echo migrate: giving up after $n attempts; exit 1; fi; echo migrate: database not ready, attempt $n of 30, retrying in 5s; sleep 5; done; exec node main.js"]
|