feat: add ci-cd
This commit is contained in:
41
Dockerfile
Normal file
41
Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
# Стадия сборки (builder)
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
# Устанавливаем рабочую директорию
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем package.json и package-lock.json (или yarn.lock)
|
||||
COPY package*.json ./
|
||||
|
||||
# Устанавливаем зависимости
|
||||
RUN npm install --frozen-lockfile
|
||||
|
||||
# Копируем все файлы проекта
|
||||
COPY . .
|
||||
|
||||
# Собираем приложение
|
||||
RUN npm build
|
||||
|
||||
# Стадия запуска (runner)
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
# Включаем node пользователя
|
||||
RUN addgroup -g 1001 -S nodejs
|
||||
RUN adduser -S nextjs -u 1001
|
||||
|
||||
# Копируем необходимые файлы из стадии builder
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/next.config.js ./next.config.js
|
||||
|
||||
# Переключаем на пользователя nextjs
|
||||
USER nextjs
|
||||
|
||||
# Открываем порт
|
||||
EXPOSE 3000
|
||||
|
||||
# Запускаем приложение
|
||||
CMD ["npm", "start"]
|
||||
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
fire-exam:
|
||||
image: smallbuster/fire-exam:latest
|
||||
container_name: fire-exam
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5002:80"
|
||||
|
||||
Reference in New Issue
Block a user