diff --git a/.github/workflows/uffizzi-build.yaml b/.github/workflows/uffizzi-build.yaml index 7a2d28f02..c3dd53295 100644 --- a/.github/workflows/uffizzi-build.yaml +++ b/.github/workflows/uffizzi-build.yaml @@ -14,6 +14,12 @@ jobs: - name: checkout uses: actions/checkout@v3 + - name: Generate Dockerfile + id: generate-dockerfile + run: | + cd uffizzi + ./create-dockerfile.sh + - name: Generate UUID image name id: uuid run: echo "UUID_TAG=$(uuidgen)" >> $GITHUB_ENV @@ -41,7 +47,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - name: Push Image to TTL.SH + - name: Push Image to Uffizzi run: docker push registry.uffizzi.com/${{ env.UUID_TAG }}:60h render-compose-file: diff --git a/i18next.d.ts b/i18next.d.ts new file mode 100644 index 000000000..893029948 --- /dev/null +++ b/i18next.d.ts @@ -0,0 +1,8 @@ +// i18next.d.ts +import 'i18next'; + +declare module 'i18next' { + interface CustomTypeOptions { + returnNull: false; + } +} diff --git a/package-lock.json b/package-lock.json index 5a84811a4..b5b0b6df5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "micromatch": "4.0.5", "next": "13.0.7", "next-auth": "4.18.6", - "next-i18next": "12.1.0", + "next-i18next": "13.0.2", "next-mdx-remote": "4.2.0", "node-fetch": "3.3.0", "nodemailer": "6.8.0", @@ -1597,10 +1597,11 @@ } }, "node_modules/@babel/runtime": { - "version": "7.18.9", - "license": "MIT", + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.6.tgz", + "integrity": "sha512-Q+8MqP7TiHMWzSfwiJwXCjyf4GYA4Dgw3emg/7xmwsdLJOZUp+nMqcOwOzzYheuM1rhDu8FSj2l0aoMygEuXuA==", "dependencies": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.13.11" }, "engines": { "node": ">=6.9.0" @@ -5501,7 +5502,9 @@ }, "node_modules/html-parse-stringify": { "version": "3.0.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz", + "integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==", + "peer": true, "dependencies": { "void-elements": "3.1.0" } @@ -5543,7 +5546,9 @@ } }, "node_modules/i18next": { - "version": "21.9.2", + "version": "22.4.6", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.6.tgz", + "integrity": "sha512-9Tm1ezxWyzV+306CIDMBbYBitC1jedQyYuuLtIv7oxjp2ohh8eyxP9xytIf+2bbQfhH784IQKPSYp+Zq9+YSbw==", "funding": [ { "type": "individual", @@ -5558,14 +5563,15 @@ "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" } ], - "license": "MIT", + "peer": true, "dependencies": { - "@babel/runtime": "^7.17.2" + "@babel/runtime": "^7.20.6" } }, "node_modules/i18next-fs-backend": { - "version": "1.1.5", - "license": "MIT" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-2.1.0.tgz", + "integrity": "sha512-gur0HAEkVDeUgZ9WNUcACYYl2N5FUt0C6bQCWsFPc+IYMXYWfiFQa8QQ930QAVYf71I75Ptl4XqQo5sl/u6/mA==" }, "node_modules/iconv-lite": { "version": "0.4.24", @@ -7395,12 +7401,10 @@ } }, "node_modules/next-i18next": { - "version": "12.1.0", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/next-i18next/-/next-i18next-13.0.2.tgz", + "integrity": "sha512-aUHyKT2kztMgEP44zDB5KoW8XZUQawIdOYWXcrMH6lxAcS0kBsKX0uKMzGS5XlgLW88gvOVc3D7NdfCznLgyyg==", "funding": [ - { - "type": "individual", - "url": "https://locize.com" - }, { "type": "individual", "url": "https://locize.com/i18next.html" @@ -7408,24 +7412,31 @@ { "type": "individual", "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + }, + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://github.com/belgattitude" } ], - "license": "MIT", "dependencies": { - "@babel/runtime": "^7.18.9", + "@babel/runtime": "^7.20.6", "@types/hoist-non-react-statics": "^3.3.1", "core-js": "^3", "hoist-non-react-statics": "^3.3.2", - "i18next": "^21.9.1", - "i18next-fs-backend": "^1.1.5", - "react-i18next": "^11.18.4" + "i18next-fs-backend": "^2.1.0" }, "engines": { - "node": ">=12" + "node": ">=14" }, "peerDependencies": { - "next": ">= 10.0.0", - "react": ">= 16.8.0" + "i18next": "^22.0.6", + "next": ">= 12.0.0", + "react": ">= 17.0.2", + "react-i18next": "^12.1.1" } }, "node_modules/next-mdx-remote": { @@ -8379,8 +8390,10 @@ } }, "node_modules/react-i18next": { - "version": "11.18.6", - "license": "MIT", + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-12.1.1.tgz", + "integrity": "sha512-mFdieOI0LDy84q3JuZU6Aou1DoWW2fhapcTGeBS8+vWSJuViuoCLQAMYSb0QoHhXS8B0WKUOPpx4cffAP7r/aA==", + "peer": true, "dependencies": { "@babel/runtime": "^7.14.5", "html-parse-stringify": "^3.0.1" @@ -8547,8 +8560,9 @@ } }, "node_modules/regenerator-runtime": { - "version": "0.13.9", - "license": "MIT" + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "node_modules/regexp.prototype.flags": { "version": "1.4.3", @@ -10270,7 +10284,9 @@ }, "node_modules/void-elements": { "version": "3.1.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz", + "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -15667,9 +15683,11 @@ } }, "@babel/runtime": { - "version": "7.18.9", + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.6.tgz", + "integrity": "sha512-Q+8MqP7TiHMWzSfwiJwXCjyf4GYA4Dgw3emg/7xmwsdLJOZUp+nMqcOwOzzYheuM1rhDu8FSj2l0aoMygEuXuA==", "requires": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.13.11" } }, "@babel/runtime-corejs3": { @@ -20703,6 +20721,9 @@ }, "html-parse-stringify": { "version": "3.0.1", + "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz", + "integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==", + "peer": true, "requires": { "void-elements": "3.1.0" } @@ -20726,13 +20747,18 @@ "dev": true }, "i18next": { - "version": "21.9.2", + "version": "22.4.6", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.6.tgz", + "integrity": "sha512-9Tm1ezxWyzV+306CIDMBbYBitC1jedQyYuuLtIv7oxjp2ohh8eyxP9xytIf+2bbQfhH784IQKPSYp+Zq9+YSbw==", + "peer": true, "requires": { - "@babel/runtime": "^7.17.2" + "@babel/runtime": "^7.20.6" } }, "i18next-fs-backend": { - "version": "1.1.5" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-2.1.0.tgz", + "integrity": "sha512-gur0HAEkVDeUgZ9WNUcACYYl2N5FUt0C6bQCWsFPc+IYMXYWfiFQa8QQ930QAVYf71I75Ptl4XqQo5sl/u6/mA==" }, "iconv-lite": { "version": "0.4.24", @@ -21771,15 +21797,15 @@ } }, "next-i18next": { - "version": "12.1.0", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/next-i18next/-/next-i18next-13.0.2.tgz", + "integrity": "sha512-aUHyKT2kztMgEP44zDB5KoW8XZUQawIdOYWXcrMH6lxAcS0kBsKX0uKMzGS5XlgLW88gvOVc3D7NdfCznLgyyg==", "requires": { - "@babel/runtime": "^7.18.9", + "@babel/runtime": "^7.20.6", "@types/hoist-non-react-statics": "^3.3.1", "core-js": "^3", "hoist-non-react-statics": "^3.3.2", - "i18next": "^21.9.1", - "i18next-fs-backend": "^1.1.5", - "react-i18next": "^11.18.4" + "i18next-fs-backend": "^2.1.0" } }, "next-mdx-remote": { @@ -22344,7 +22370,10 @@ } }, "react-i18next": { - "version": "11.18.6", + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-12.1.1.tgz", + "integrity": "sha512-mFdieOI0LDy84q3JuZU6Aou1DoWW2fhapcTGeBS8+vWSJuViuoCLQAMYSb0QoHhXS8B0WKUOPpx4cffAP7r/aA==", + "peer": true, "requires": { "@babel/runtime": "^7.14.5", "html-parse-stringify": "^3.0.1" @@ -22438,7 +22467,9 @@ } }, "regenerator-runtime": { - "version": "0.13.9" + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "regexp.prototype.flags": { "version": "1.4.3", @@ -23456,7 +23487,10 @@ } }, "void-elements": { - "version": "3.1.0" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz", + "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==", + "peer": true }, "web-streams-polyfill": { "version": "3.2.1" diff --git a/package.json b/package.json index 0f968ccaa..3416ddead 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "micromatch": "4.0.5", "next": "13.0.7", "next-auth": "4.18.6", - "next-i18next": "12.1.0", + "next-i18next": "13.0.2", "next-mdx-remote": "4.2.0", "node-fetch": "3.3.0", "nodemailer": "6.8.0", diff --git a/pages/_app.tsx b/pages/_app.tsx index 90c1af8fe..5cc7a4c23 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -7,6 +7,7 @@ import { Toaster } from '@components/Toaster'; import { appWithTranslation } from 'next-i18next'; import { ReactElement, ReactNode } from 'react'; import micromatch from 'micromatch'; +import nextI18NextConfig from '../next-i18next.config.js'; import { AccountLayout, SetupLayout } from '@components/layouts'; @@ -66,7 +67,7 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) { ); } -export default appWithTranslation(MyApp); +export default appWithTranslation(MyApp, nextI18NextConfig); export type AppPropsWithLayout = AppProps & { Component: NextPageWithLayout; diff --git a/uffizzi/Dockerfile b/uffizzi/Dockerfile index 4ea66559d..b5693c7b5 100644 --- a/uffizzi/Dockerfile +++ b/uffizzi/Dockerfile @@ -1,37 +1,70 @@ -FROM node:16.18.0-alpine3.16 AS base +ARG NODEJS_IMAGE=node:16.18.1-alpine3.16 +FROM --platform=$BUILDPLATFORM $NODEJS_IMAGE AS base # Install dependencies only when needed FROM base AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app -COPY package.json package-lock.json ./ + +# Install dependencies based on the preferred package manager +COPY package.json package-lock.json ./ COPY npm npm -RUN npm install --legacy-peer-deps +RUN npm ci + + # Rebuild the source code only when needed FROM base AS builder WORKDIR /app -COPY . . + COPY --from=deps /app/npm ./npm COPY --from=deps /app/node_modules ./node_modules -RUN npm run build && npm install --legacy-peer-deps --production --ignore-scripts --prefer-offline +COPY . . + + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the build. +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN npm run build + # Production image, copy all the files and run next -FROM base AS runner +FROM $NODEJS_IMAGE AS runner WORKDIR /app ENV NODE_OPTIONS="--max-http-header-size=81920" -ENV NODE_ENV production -RUN addgroup -g 1001 -S nodejs -RUN adduser -S nextjs -u 1001 + +ENV NODE_ENV production +# Uncomment the following line in case you want to disable telemetry during runtime. +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + COPY --from=builder /app/public ./public -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --from=builder /app/npm ./npm -COPY --from=builder /app/node_modules ./node_modules -COPY --from=builder /app/package.json ./package.json + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + + +USER nextjs + +EXPOSE 5225 + +ENV PORT 5225 + +CMD ["node", "server.js"] + + +FROM runner AS uffizzi +USER root COPY --from=builder /app/uffizzi/saml_config ./uffizzi/saml_config COPY ./uffizzi/docker-entrypoint.sh . @@ -39,11 +72,4 @@ RUN chmod +x docker-entrypoint.sh USER nextjs -EXPOSE 5225 - -# Next.js collects completely anonymous telemetry data about general usage. -# Learn more here: https://nextjs.org/telemetry -# Uncomment the following line in case you want to disable telemetry. -ENV NEXT_TELEMETRY_DISABLED 1 - -CMD ["./docker-entrypoint.sh"] +CMD ["./docker-entrypoint.sh"] \ No newline at end of file diff --git a/uffizzi/Dockerfile.tmpl b/uffizzi/Dockerfile.tmpl new file mode 100644 index 000000000..7a55646b9 --- /dev/null +++ b/uffizzi/Dockerfile.tmpl @@ -0,0 +1,10 @@ +FROM runner AS uffizzi +USER root +COPY --from=builder /app/uffizzi/saml_config ./uffizzi/saml_config + +COPY ./uffizzi/docker-entrypoint.sh . +RUN chmod +x docker-entrypoint.sh + +USER nextjs + +CMD ["./docker-entrypoint.sh"] \ No newline at end of file diff --git a/uffizzi/create-dockerfile.sh b/uffizzi/create-dockerfile.sh new file mode 100755 index 000000000..ed8d27bbe --- /dev/null +++ b/uffizzi/create-dockerfile.sh @@ -0,0 +1 @@ +cat ../Dockerfile Dockerfile.tmpl > Dockerfile \ No newline at end of file