feat: add new dockerfile

This commit is contained in:
SD 2024-06-27 17:05:35 +04:00
parent 5303bb895d
commit ab5bd5fe2b
7 changed files with 37 additions and 10 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
node_modules/
.next
.idea

View File

@ -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
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"]

View File

@ -28,8 +28,6 @@ const nextConfig = {
taint: true,
// typedRoutes: true
},
output: 'export',
distDir: 'dist',
poweredByHeader: false,
productionBrowserSourceMaps: true,
trailingSlash: true

View File

@ -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": {

View File

@ -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;
};

View File

@ -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';