add ci-cd
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
node_modules
|
||||
build
|
||||
.DS_Store
|
||||
.env
|
||||
48
.github/workflows/main.yaml
vendored
Normal file
48
.github/workflows/main.yaml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Build and deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
tags: smallbuster/fe-docs:latest
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
needs: build
|
||||
steps:
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Pull Docker image from Docker Hub
|
||||
run: |
|
||||
docker pull smallbuster/fe-docs:latest
|
||||
|
||||
- name: Stop and remove existing container
|
||||
run: |
|
||||
docker stop fe-docs || true && docker rm fe-docs || true
|
||||
|
||||
- name: Run Docker container
|
||||
run: |
|
||||
docker run -d --restart unless-stopped \
|
||||
--name fe-docs smallbuster/fe-docs:latest
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
|
||||
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
# Используем официальный образ Node.js
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
# Устанавливаем рабочий каталог
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем файлы зависимостей
|
||||
COPY package.json package-lock.json* ./
|
||||
|
||||
# Устанавливаем зависимости
|
||||
RUN npm install
|
||||
|
||||
# Копируем все файлы проекта
|
||||
COPY . .
|
||||
|
||||
# Собираем проект
|
||||
RUN npm ci
|
||||
RUN npm run build
|
||||
|
||||
# Используем nginx для обслуживания статических файлов
|
||||
FROM nginx:alpine
|
||||
|
||||
# Копируем собранные файлы из builder в nginx
|
||||
COPY --from=builder /app/build /usr/share/nginx/html
|
||||
|
||||
# Копируем конфигурацию nginx (если нужно)
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Открываем порт 80
|
||||
EXPOSE 80
|
||||
|
||||
# Запускаем nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
8
docker-compose.yaml
Normal file
8
docker-compose.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "5001:80"
|
||||
restart: always
|
||||
15
nginx.conf
Normal file
15
nginx.conf
Normal file
@@ -0,0 +1,15 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user