re-deploy

This commit is contained in:
ordinarthur 2026-03-12 15:37:59 +01:00
parent 4fdeacd19e
commit 9537c0342c
3 changed files with 21 additions and 22 deletions

View File

@ -1,31 +1,22 @@
FROM node:22-alpine AS base
# ── Install dependencies ─────────────────────────────────────────────────────
FROM node:22-alpine AS deps
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
# ── Dependencies ─────────────────────────────────────────────────────────────
FROM base AS deps
COPY package.json pnpm-lock.yaml ./
COPY prisma ./prisma/
RUN pnpm install --frozen-lockfile
# ── Build static site ────────────────────────────────────────────────────────
FROM base AS build
# ── Production ───────────────────────────────────────────────────────────────
FROM node:22-alpine
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm prisma generate
# Astro build needs DATABASE_URL at build time (passed as build arg by Coolify)
ARG DATABASE_URL
RUN pnpm build
# ── Production ───────────────────────────────────────────────────────────────
FROM base AS production
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY . .
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
EXPOSE 3000
# Migrate DB + seed if needed + start server
CMD ["sh", "-c", "pnpm prisma migrate deploy && node server.mjs"]
# Astro SSG needs the DB at build time → build happens at startup after Postgres is ready
CMD ["sh", "-c", "pnpm prisma migrate deploy && pnpm build && node server.mjs"]

View File

@ -3,8 +3,6 @@ services:
build:
context: .
dockerfile: Dockerfile
args:
- DATABASE_URL=${DATABASE_URL}
volumes:
- static:/app/dist
environment:
@ -20,6 +18,12 @@ services:
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "sh", "-c", "[ -f /app/dist/index.html ] && wget -qO- http://localhost:3000/api/health || exit 1"]
interval: 10s
timeout: 5s
retries: 30
start_period: 60s
restart: unless-stopped
labels:
- traefik.enable=true
@ -51,7 +55,8 @@ services:
- static:/usr/share/nginx/html:ro
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- fastify
fastify:
condition: service_healthy
restart: unless-stopped
labels:
- traefik.enable=true

View File

@ -93,6 +93,9 @@ app.get('/sitemap.xml', async (_, reply) => {
)
})
// ── Health check ────────────────────────────────────────────────────────────
app.get('/api/health', async () => ({ status: 'ok' }))
// ── Checkout Stripe ─────────────────────────────────────────────────────────
app.post('/api/checkout', async (request, reply) => {
const { product, email } = request.body ?? {}