feat: docker for production deployment
This commit is contained in:
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@ -0,0 +1,7 @@
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
node_modules
|
||||
npm-debug.log
|
||||
README.md
|
||||
.next
|
||||
.git
|
||||
48
Dockerfile
Normal file
48
Dockerfile
Normal file
@ -0,0 +1,48 @@
|
||||
FROM node:18-alpine 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
|
||||
|
||||
RUN corepack enable
|
||||
COPY .yarn ./.yarn
|
||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .yarnrc.yml ./
|
||||
|
||||
RUN yarn --frozen-lockfile
|
||||
|
||||
|
||||
# Rebuild the source code only when needed
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN yarn build
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
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/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
CMD ["node", "server.js"]
|
||||
4
build_docker.sh
Normal file
4
build_docker.sh
Normal file
@ -0,0 +1,4 @@
|
||||
sudo docker build -t git.logidex.ru/aserbin/logidex-id-frontend:latest .
|
||||
sudo docker images git.logidex.ru/aserbin/logidex-id-frontend:latest
|
||||
sudo docker login git.logidex.ru
|
||||
sudo docker push git.logidex.ru/aserbin/logidex-id-frontend:latest
|
||||
20
compose.yml
Normal file
20
compose.yml
Normal file
@ -0,0 +1,20 @@
|
||||
services:
|
||||
logidex-id-frontend:
|
||||
image: git.logidex.ru/aserbin/logidex-id-frontend:latest
|
||||
container_name: logidex-id-frontend
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
ports:
|
||||
- "3001:3000"
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: "500m"
|
||||
networks:
|
||||
- logidex-id-network
|
||||
|
||||
networks:
|
||||
logidex-id-network:
|
||||
driver: bridge
|
||||
@ -5,6 +5,7 @@ const withBundleAnalyzer = bundleAnalyzer({
|
||||
});
|
||||
|
||||
export default withBundleAnalyzer({
|
||||
output: "standalone",
|
||||
reactStrictMode: false,
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
|
||||
@ -31,7 +31,8 @@
|
||||
"next": "15.3.3",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"react-imask": "^7.6.1"
|
||||
"react-imask": "^7.6.1",
|
||||
"sharp": "^0.34.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.27.4",
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { render as testingLibraryRender } from "@testing-library/react";
|
||||
import { MantineProvider } from "@mantine/core";
|
||||
import { darkTheme } from "@/theme";
|
||||
import { theme } from "@/theme";
|
||||
import React from "react";
|
||||
|
||||
export function render(ui: React.ReactNode) {
|
||||
return testingLibraryRender(<>{ui}</>, {
|
||||
wrapper: ({ children }: { children: React.ReactNode }) => (
|
||||
<MantineProvider
|
||||
theme={darkTheme}
|
||||
theme={theme}
|
||||
env="test">
|
||||
{children}
|
||||
</MantineProvider>
|
||||
|
||||
@ -9091,6 +9091,7 @@ __metadata:
|
||||
react: "npm:19.1.0"
|
||||
react-dom: "npm:19.1.0"
|
||||
react-imask: "npm:^7.6.1"
|
||||
sharp: "npm:^0.34.3"
|
||||
storybook: "npm:^8.6.8"
|
||||
storybook-dark-mode: "npm:^4.0.2"
|
||||
stylelint: "npm:^16.20.0"
|
||||
@ -11227,7 +11228,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"sharp@npm:^0.34.1":
|
||||
"sharp@npm:^0.34.1, sharp@npm:^0.34.3":
|
||||
version: 0.34.3
|
||||
resolution: "sharp@npm:0.34.3"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user