From ab5bd5fe2b21b5e74ac0ce6ad11eb19ea0c33b11 Mon Sep 17 00:00:00 2001 From: SD Date: Thu, 27 Jun 2024 17:05:35 +0400 Subject: [PATCH] feat: add new dockerfile --- .dockerignore | 3 +++ Dockerfile | 27 ++++++++++++++----- next.config.js | 2 -- package.json | 2 +- .../{[[...slug]] => [...slug]}/page.tsx | 0 .../account/(simple)/sessions/page.ts | 12 +++++++++ src/app/[locale]/account/page.tsx | 1 - 7 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 .dockerignore rename src/app/[locale]/account/(simple)/sessions/{[[...slug]] => [...slug]}/page.tsx (100%) create mode 100644 src/app/[locale]/account/(simple)/sessions/page.ts diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..037855b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules/ +.next +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 820ce10..2e74df7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,23 @@ -FROM node:bookworm AS build -RUN node -v +FROM node:20.10.0 as dependencies +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci --verbose + +FROM node:20.10.0 as builder WORKDIR /app COPY . . -FROM nginx -COPY --from=build /app/dist /usr/share/nginx/html/ -RUN rm /etc/nginx/conf.d/default.conf -COPY _nginx/nginx.conf /etc/nginx/conf.d \ No newline at end of file +COPY --from=dependencies /app/node_modules ./node_modules +RUN npm run build --debug --verbose + +FROM node:20.10.0 as runner +WORKDIR /app +COPY . . + +ENV NODE_ENV production +COPY --from=builder /app/public ./public +COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/.next ./.next +COPY --from=dependencies /app/node_modules ./node_modules + +EXPOSE 4200 +CMD ["npm", "start"] diff --git a/next.config.js b/next.config.js index 466969a..2d8efde 100644 --- a/next.config.js +++ b/next.config.js @@ -28,8 +28,6 @@ const nextConfig = { taint: true, // typedRoutes: true }, - output: 'export', - distDir: 'dist', poweredByHeader: false, productionBrowserSourceMaps: true, trailingSlash: true diff --git a/package.json b/package.json index fec2b54..fdfb4c7 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "next dev -p 4200", "build": "next build", - "start": "next start", + "start": "next start -p 4200", "lint": "next lint" }, "dependencies": { diff --git a/src/app/[locale]/account/(simple)/sessions/[[...slug]]/page.tsx b/src/app/[locale]/account/(simple)/sessions/[...slug]/page.tsx similarity index 100% rename from src/app/[locale]/account/(simple)/sessions/[[...slug]]/page.tsx rename to src/app/[locale]/account/(simple)/sessions/[...slug]/page.tsx diff --git a/src/app/[locale]/account/(simple)/sessions/page.ts b/src/app/[locale]/account/(simple)/sessions/page.ts new file mode 100644 index 0000000..18c8a76 --- /dev/null +++ b/src/app/[locale]/account/(simple)/sessions/page.ts @@ -0,0 +1,12 @@ +'use client'; + +import { redirect } from 'next/navigation'; +import { useLocalStorage } from '../../../../../hooks/useLocalStorage'; +import { AUTH_TOKEN_KEY } from '../../../../../constants/common'; +import { SessionType } from '../../../../../types/sessions'; + +export default function SessionsMainPage() { + const [token] = useLocalStorage(AUTH_TOKEN_KEY, ''); + + return token ? redirect(SessionType.UPCOMING) : null; +}; diff --git a/src/app/[locale]/account/page.tsx b/src/app/[locale]/account/page.tsx index d37d47d..badb23a 100644 --- a/src/app/[locale]/account/page.tsx +++ b/src/app/[locale]/account/page.tsx @@ -1,6 +1,5 @@ 'use client'; -import React from 'react'; import { redirect } from 'next/navigation'; import { useLocalStorage } from '../../../hooks/useLocalStorage'; import { AUTH_TOKEN_KEY } from '../../../constants/common';