Compare commits
7 commits
7cdcf52149
...
1446b66085
| Author | SHA1 | Date | |
|---|---|---|---|
| 1446b66085 | |||
| 2ec2f61904 | |||
| d28cce3fba | |||
| 8ea12591b6 | |||
| dcd90e4fff | |||
| b0affaa936 | |||
| 453e48c2b5 |
10 changed files with 594 additions and 442 deletions
|
|
@ -9,10 +9,10 @@ stages:
|
||||||
|
|
||||||
lint next.js:
|
lint next.js:
|
||||||
stage: lint
|
stage: lint
|
||||||
image: node:18-alpine3.17
|
image: oven/bun:1.0.1
|
||||||
script:
|
script:
|
||||||
- npm ci --frozen-lockfile
|
- bun install --frozen-lockfile
|
||||||
- SKIP_ENV_VALIDATION=1 npm run lint
|
- SKIP_ENV_VALIDATION=1 bun run lint
|
||||||
|
|
||||||
lint helm:
|
lint helm:
|
||||||
stage: lint
|
stage: lint
|
||||||
|
|
|
||||||
0
BUN.md
Normal file
0
BUN.md
Normal file
41
bun.alpine.dockerfile
Normal file
41
bun.alpine.dockerfile
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
FROM --platform=linux/amd64 alpine:3.18 as base
|
||||||
|
|
||||||
|
FROM --platform=linux/amd64 base as download
|
||||||
|
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
RUN apk add --no-cache unzip
|
||||||
|
|
||||||
|
RUN wget https://github.com/oven-sh/bun/releases/download/bun-v1.0.7/bun-linux-x64.zip
|
||||||
|
RUN unzip bun-linux-x64.zip
|
||||||
|
|
||||||
|
FROM --platform=linux/amd64 base as bun
|
||||||
|
|
||||||
|
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
|
||||||
|
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-2.35-r0.apk
|
||||||
|
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r0/glibc-bin-2.35-r0.apk
|
||||||
|
RUN apk --no-cache --force-overwrite add glibc-2.35-r0.apk glibc-bin-2.35-r0.apk
|
||||||
|
|
||||||
|
RUN /usr/glibc-compat/bin/ldd /lib/ld-linux-x86-64.so.2
|
||||||
|
|
||||||
|
COPY --from=download /tmp/bun-linux-x64/bun /usr/local/bin
|
||||||
|
|
||||||
|
FROM --platform=linux/amd64 bun as app
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
EXPOSE 3000
|
||||||
|
ENV PORT 3000
|
||||||
|
|
||||||
|
ARG SKIP_ENV_VALIDATION=1
|
||||||
|
|
||||||
|
# RUN apk add --no-cache libc6-compat openssl1.1-compat # gcompat
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
RUN bunx prisma generate
|
||||||
|
RUN bun run build
|
||||||
|
|
||||||
|
CMD ["bun", "run", "/app/.next/standalone/server.js"]
|
||||||
22
bun.dockerfile
Normal file
22
bun.dockerfile
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
FROM --platform=linux/amd64 oven/bun:1.0.7
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 3000
|
||||||
|
ENV PORT 3000
|
||||||
|
|
||||||
|
ARG NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ARG SKIP_ENV_VALIDATION=1
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
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/*
|
||||||
|
|
||||||
|
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
Executable file
BIN
bun.lockb
Executable file
Binary file not shown.
74
multistage.dockerfile
Normal file
74
multistage.dockerfile
Normal 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"]
|
||||||
852
package-lock.json
generated
852
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,7 +5,6 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"postinstall": "prisma generate",
|
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"seed": "esbuild prisma/seed.ts --outfile=seed.cjs --bundle --format=cjs --external:prisma --external:@prisma/client --platform=node && node seed.cjs"
|
"seed": "esbuild prisma/seed.ts --outfile=seed.cjs --bundle --format=cjs --external:prisma --external:@prisma/client --platform=node && node seed.cjs"
|
||||||
|
|
@ -15,7 +14,7 @@
|
||||||
"@heroicons/react": "^2.0.18",
|
"@heroicons/react": "^2.0.18",
|
||||||
"@next-auth/prisma-adapter": "^1.0.5",
|
"@next-auth/prisma-adapter": "^1.0.5",
|
||||||
"@paralleldrive/cuid2": "^2.2.1",
|
"@paralleldrive/cuid2": "^2.2.1",
|
||||||
"@prisma/client": "^4.14.0",
|
"@prisma/client": "^5.2.0",
|
||||||
"@t3-oss/env-nextjs": "^0.3.1",
|
"@t3-oss/env-nextjs": "^0.3.1",
|
||||||
"clsx": "^1.2.1",
|
"clsx": "^1.2.1",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
|
|
@ -42,7 +41,7 @@
|
||||||
"postcss": "^8.4.21",
|
"postcss": "^8.4.21",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
"prettier-plugin-tailwindcss": "^0.2.8",
|
"prettier-plugin-tailwindcss": "^0.2.8",
|
||||||
"prisma": "^4.14.0",
|
"prisma": "^5.2.0",
|
||||||
"tailwindcss": "^3.3.0",
|
"tailwindcss": "^3.3.0",
|
||||||
"typescript": "^5.1.3"
|
"typescript": "^5.1.3"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
11
scripts/create-image-pull-secret.sh
Executable file
11
scripts/create-image-pull-secret.sh
Executable 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
|
||||||
|
|
@ -37,7 +37,7 @@ declare module "next-auth" {
|
||||||
*
|
*
|
||||||
* @see https://stackoverflow.com/a/75526977
|
* @see https://stackoverflow.com/a/75526977
|
||||||
*/
|
*/
|
||||||
declare module 'next-auth/jwt' {
|
declare module "next-auth/jwt" {
|
||||||
interface JWT {
|
interface JWT {
|
||||||
id_token?: string;
|
id_token?: string;
|
||||||
provider?: string;
|
provider?: string;
|
||||||
|
|
@ -56,10 +56,15 @@ const originLinkAccount = adapter.linkAccount;
|
||||||
*/
|
*/
|
||||||
adapter.linkAccount = (account: AdapterAccount) => {
|
adapter.linkAccount = (account: AdapterAccount) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { 'not-before-policy': _, refresh_expires_in, ...data } = account;
|
const { "not-before-policy": _, refresh_expires_in, ...data } = account;
|
||||||
return originLinkAccount(data);
|
|
||||||
|
if (!originLinkAccount) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return originLinkAccount(data);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
|
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
|
||||||
*
|
*
|
||||||
|
|
@ -83,10 +88,10 @@ export const authOptions: NextAuthOptions = {
|
||||||
*/
|
*/
|
||||||
jwt({ token, account }) {
|
jwt({ token, account }) {
|
||||||
if (account) {
|
if (account) {
|
||||||
token.id_token = account?.id_token
|
token.id_token = account?.id_token;
|
||||||
token.provider = account?.provider
|
token.provider = account?.provider;
|
||||||
}
|
}
|
||||||
return token
|
return token;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
adapter: adapter,
|
adapter: adapter,
|
||||||
|
|
@ -119,12 +124,14 @@ export const authOptions: NextAuthOptions = {
|
||||||
*/
|
*/
|
||||||
async signOut({ token }: { token: JWT }) {
|
async signOut({ token }: { token: JWT }) {
|
||||||
if (token.provider === "keycloak") {
|
if (token.provider === "keycloak") {
|
||||||
const logOutURL = new URL(`${env.KEYCLOAK_ISSUER}/protocol/openid-connect/logout`)
|
const logOutURL = new URL(
|
||||||
logOutURL.searchParams.set("id_token_hint", token.id_token ?? '')
|
`${env.KEYCLOAK_ISSUER}/protocol/openid-connect/logout`
|
||||||
|
);
|
||||||
|
logOutURL.searchParams.set("id_token_hint", token.id_token ?? "");
|
||||||
await fetch(logOutURL);
|
await fetch(logOutURL);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Reference in a new issue