re-deploy
This commit is contained in:
parent
4fdeacd19e
commit
9537c0342c
29
Dockerfile
29
Dockerfile
@ -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
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# ── Dependencies ─────────────────────────────────────────────────────────────
|
|
||||||
FROM base AS deps
|
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
COPY prisma ./prisma/
|
COPY prisma ./prisma/
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
# ── Build static site ────────────────────────────────────────────────────────
|
# ── Production ───────────────────────────────────────────────────────────────
|
||||||
FROM base AS build
|
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 --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm prisma generate
|
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
|
EXPOSE 3000
|
||||||
|
|
||||||
# Migrate DB + seed if needed + start server
|
# Astro SSG needs the DB at build time → build happens at startup after Postgres is ready
|
||||||
CMD ["sh", "-c", "pnpm prisma migrate deploy && node server.mjs"]
|
CMD ["sh", "-c", "pnpm prisma migrate deploy && pnpm build && node server.mjs"]
|
||||||
|
|||||||
@ -3,8 +3,6 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
|
||||||
- DATABASE_URL=${DATABASE_URL}
|
|
||||||
volumes:
|
volumes:
|
||||||
- static:/app/dist
|
- static:/app/dist
|
||||||
environment:
|
environment:
|
||||||
@ -20,6 +18,12 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
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
|
restart: unless-stopped
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
@ -51,7 +55,8 @@ services:
|
|||||||
- static:/usr/share/nginx/html:ro
|
- static:/usr/share/nginx/html:ro
|
||||||
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- fastify
|
fastify:
|
||||||
|
condition: service_healthy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
|
|||||||
@ -93,6 +93,9 @@ app.get('/sitemap.xml', async (_, reply) => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ── Health check ────────────────────────────────────────────────────────────
|
||||||
|
app.get('/api/health', async () => ({ status: 'ok' }))
|
||||||
|
|
||||||
// ── Checkout Stripe ─────────────────────────────────────────────────────────
|
// ── Checkout Stripe ─────────────────────────────────────────────────────────
|
||||||
app.post('/api/checkout', async (request, reply) => {
|
app.post('/api/checkout', async (request, reply) => {
|
||||||
const { product, email } = request.body ?? {}
|
const { product, email } = request.body ?? {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user