1
0
Fork 0
This commit is contained in:
Vojtěch Mareš 2023-09-14 13:57:56 +02:00
parent d28cce3fba
commit 2ec2f61904
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
7 changed files with 6533 additions and 2 deletions

0
BUN.md Normal file
View file

View file

@ -1,4 +1,4 @@
FROM --platform=linux/amd64 oven/bun:1.0.1
FROM --platform=linux/amd64 oven/bun:1.0.4
WORKDIR /app
EXPOSE 3000
@ -16,6 +16,7 @@ RUN apt-get update && \
COPY . .
RUN bun install --frozen-lockfile
RUN bunx --bun prisma generate
RUN bun --bun run build
CMD ["bun", "run", "/app/.next/standalone/server.js"]

BIN
bun.lockb

Binary file not shown.

74
multistage.dockerfile Normal file
View file

@ -0,0 +1,74 @@
FROM --platform=linux/amd64 node:18-bullseye-slim as node
FROM --platform=linux/amd64 oven/bun:1.0.1 as bun
### DEPENDENCIES
FROM node AS deps
WORKDIR /app
# RUN apk add --no-cache libc6-compat openssl1.1-compat
RUN apt-get update && apt-get install -y openssl=1.1.1n-0+deb11u5
COPY prisma ./prisma
COPY package.json package-lock.json ./
RUN npm ci --frozen-lockfile
### BUILDER
FROM node AS builder
WORKDIR /app
COPY --from=deps /app/prisma ./prisma
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED 1
RUN SKIP_ENV_VALIDATION=1 npm run build
### RUNNER
# FROM base AS runner
FROM bun AS runner
WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN apt-get update && \
apt-get install -y ca-certificates openssl=1.1.1n-0+deb11u5 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Required for `npx prisma migrate deploy`
COPY --from=builder /app/prisma ./prisma
# Required for `npx prisma db seed`
COPY --from=builder /app/content ./content
COPY --from=builder /app/src/content/training.ts ./src/content/training.ts
COPY --from=builder /app/src/server/db.ts ./src/server/db.ts
COPY --from=builder /app/src/env.mjs ./src/env.mjs
# Required for Next.js
COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/tsconfig.json ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["bun", "run", "server.js"]

6446
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,6 @@
"scripts": {
"build": "next build",
"dev": "next dev",
"postinstall": "prisma generate",
"lint": "next lint",
"start": "next start",
"seed": "esbuild prisma/seed.ts --outfile=seed.cjs --bundle --format=cjs --external:prisma --external:@prisma/client --platform=node && node seed.cjs"

View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
USERNAME="FILL_ME"
PASSWORD="FILL_ME"
NAMESPACE="backoffice-staging"
kubectl create secret docker-registry registry \
--namespace $NAMESPACE \
--docker-server=registry.mareshq.com \
--docker-username=$USERNAME \
--docker-password=$PASSWORD