Skip to content

Commit

Permalink
next@15 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
agnlez committed Dec 9, 2024
1 parent 111c08b commit bd14a56
Show file tree
Hide file tree
Showing 7 changed files with 243 additions and 383 deletions.
1 change: 0 additions & 1 deletion client/.env.default
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ NEXTAUTH_URL=http://localhost:$PORT

# API Url. Depending on the environment we will use different urls.
NEXT_PUBLIC_API_URL=https://staging.fora.dev-vizzuality.com/sub-path/backend/api/v1
NEXT_PUBLIC_API_URL_FAKE=https://jsonplaceholder.typicode.com

# Google Analytics tracking ID. If you're working with an Google Analytics 4 property, you have a Measurement ID instead of a Tracking ID.
NEXT_PUBLIC_GA_TRACKING_ID=UA-000000-2
Expand Down
29 changes: 20 additions & 9 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# Install dependencies only when needed
FROM node:16.14-alpine3.15 AS deps
FROM node:22.11.0-alpine 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 git
#RUN apk add --no-cache libc6-compat git

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

WORKDIR /app
COPY .yarn ./.yarn
COPY package.json yarn.lock .yarnrc.yml ./
RUN yarn install --immutable
RUN corepack enable

#COPY .yarn ./.yarn
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --prod --frozen-lockfile
#RUN yarn install --immutable


# If using npm with a `package-lock.json` comment out above and use below instead
# COPY package.json package-lock.json ./
# RUN npm ci

# Rebuild the source code only when needed
FROM node:16.14-alpine3.15 AS builder
FROM node:22.11.0-alpine AS builder
WORKDIR /app
RUN corepack enable

COPY . .
COPY --from=deps /app/node_modules ./node_modules

Expand All @@ -22,10 +32,11 @@ COPY --from=deps /app/node_modules ./node_modules
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1

RUN yarn build
RUN pnpm build

# Production image, copy all the files and run next
FROM node:16.14-alpine3.15 AS runner
FROM node:22.11.0-alpine AS runner
RUN corepack enable
WORKDIR /app

ENV NODE_ENV production
Expand All @@ -35,7 +46,7 @@ ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# You only need to copy next.config.ts if you are NOT using the default configuration
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
Expand Down
14 changes: 7 additions & 7 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ Here's a step by step guide on how to address vulnerabilities found in productio
## Env variables


| Variable name | Description | Default value |
|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------:|
| NEXTAUTH_SECRET | Key used to encrypt the NextAuth.js JWT, and to hash email verification tokens. Do not forget to add a secret. NextAuth can handle without it in development mode, but it won't in production! [https://next-auth.js.org/configuration/options#secret](https://next-auth.js.org/configuration/options#secret) | |
| NEXTAUTH_URL | Needed by the next-auth library for [handling auth requests and callbacks](https://next-auth.js.org/configuration/options#nextauth_url). Set the environment variable to the canonical URL of your site. Not needed in Vercel deploys. | |
| NEXT_PUBLIC_API_URL | URL of the API. | https://jsonplaceholder.typicode.com |
| NEXT_PUBLIC_GA_TRACKING_ID | Google Analytics tracking ID. If you're working with an Google Analytics 4 property, you have a Measurement ID instead of a Tracking ID. | |
| NEXT_PUBLIC_BASE_PATH | As this project should live in a subpath of a domain, we need to specify a basePath inside the next.config.ts. You may think this variable must be without the NEXT_PUBLIC but it also affects the images urls. That's why we need it at build and run time. We MUST leave it as an empty string for Vercel and local environments = "" [https://nextjs.org/docs/pages/api-reference/next-config-js/basePath](https://nextjs.org/docs/pages/api-reference/next-config-js/basePath) | |
| Variable name | Description | Default value |
|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------:|
| NEXTAUTH_SECRET | Key used to encrypt the NextAuth.js JWT, and to hash email verification tokens. Do not forget to add a secret. NextAuth can handle without it in development mode, but it won't in production! [https://next-auth.js.org/configuration/options#secret](https://next-auth.js.org/configuration/options#secret) | |
| NEXTAUTH_URL | Needed by the next-auth library for [handling auth requests and callbacks](https://next-auth.js.org/configuration/options#nextauth_url). Set the environment variable to the canonical URL of your site. Not needed in Vercel deploys. | |
| NEXT_PUBLIC_API_URL | URL of the API. | https://jsonplaceholder.typicode.com |
| NEXT_PUBLIC_GA_TRACKING_ID | Google Analytics tracking ID. If you're working with an Google Analytics 4 property, you have a Measurement ID instead of a Tracking ID. | |
| NEXT_PUBLIC_BASE_PATH | As this project should live in a subpath of a domain, we need to specify a basePath inside the next.config.js. You may think this variable must be without the NEXT_PUBLIC but it also affects the images urls. That's why we need it at build and run time. We MUST leave it as an empty string for Vercel and local environments = "" [https://nextjs.org/docs/pages/api-reference/next-config-js/basePath](https://nextjs.org/docs/pages/api-reference/next-config-js/basePath) | |



Expand Down
9 changes: 5 additions & 4 deletions client/next.config.ts → client/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextConfig } from 'next';
import withPlugins from 'next-compose-plugins';
import withOptimizedImages from 'next-optimized-images';
const withPlugins = require('next-compose-plugins');
const withOptimizedImages = require('next-optimized-images');

const nextConfig: NextConfig = {
/** @type {import('next').NextConfig} */
const nextConfig = {
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
images: {
remotePatterns: [
Expand All @@ -12,6 +12,7 @@ const nextConfig: NextConfig = {
},
],
},
output: 'standalone',
};

module.exports = withPlugins(
Expand Down
6 changes: 3 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"check-types": "tsc --noEmit -p tsconfig.json",
"check-types": "tsc -p tsconfig.json",
"lint": "eslint -c .eslintrc.js --ext .js,.jsx,.ts,.tsx --fix --ignore-path .eslintignore .",
"test": "start-server-and-test 'pnpm dev' 3000 'pnpm cypress:run'",
"cypress:open": "cypress open",
Expand Down Expand Up @@ -45,7 +45,7 @@
"jsona": "1.10.1",
"jsonwebtoken": "8.5.1",
"lodash": "4.17.21",
"next": "15.0.3",
"next": "14.2.18",
"next-auth": "4.24.10",
"next-compose-plugins": "2.2.1",
"next-optimized-images": "2.6.2",
Expand Down Expand Up @@ -76,7 +76,7 @@
"eslint": "8.57.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-next": "15.0.3",
"eslint-config-next": "14.2.18",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-import": "2.25.3",
Expand Down
Loading

0 comments on commit bd14a56

Please sign in to comment.