github workflow
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
name: Docker Build & Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "dp-gui" ]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push Server image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./server
|
||||
push: true
|
||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-server:${{ github.ref_name }}
|
||||
|
||||
- name: Build and push Client image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./client
|
||||
push: true
|
||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-client:${{ github.ref_name }}
|
||||
+21
-6
@@ -1,17 +1,32 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://server:3000;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
server {
|
||||
listen 3000;
|
||||
server_name localhost;
|
||||
location / {
|
||||
proxy_pass http://backend:3000/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host \$http_host;
|
||||
}
|
||||
}
|
||||
+15
-53
@@ -6,6 +6,10 @@ set -euo pipefail
|
||||
#################################
|
||||
REPO_URL="https://github.com/denpiligrim/3dp-manager/archive/refs/heads/dp-gui.tar.gz"
|
||||
PROJECT_DIR="/opt/3dp-manager"
|
||||
DOCKER_USER="denpiligrim"
|
||||
DOCKER_TAG="dp-gui"
|
||||
IMAGE_SERVER="ghcr.io/${DOCKER_USER}/3dp-manager-server:${DOCKER_TAG}"
|
||||
IMAGE_CLIENT="ghcr.io/${DOCKER_USER}/3dp-manager-client:${DOCKER_TAG}"
|
||||
|
||||
# Цвета для вывода
|
||||
RED='\033[0;31m'
|
||||
@@ -178,51 +182,6 @@ log "Сгенерированы секретные ключи для БД и JWT
|
||||
#################################
|
||||
# ГЕНЕРАЦИЯ ФАЙЛОВ DOCKER
|
||||
#################################
|
||||
|
||||
# --- 1. Dockerfile для Client ---
|
||||
cat > client/Dockerfile <<EOF
|
||||
FROM node:24-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV VITE_API_URL=/api
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
COPY nginx-client.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
EOF
|
||||
|
||||
# --- 3. Dockerfile для Server ---
|
||||
cat > server/Dockerfile <<EOF
|
||||
FROM node:24-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
FROM node:24-alpine
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production
|
||||
COPY --from=builder /app/dist ./dist
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
EXPOSE 3000
|
||||
CMD ["node", "dist/main"]
|
||||
EOF
|
||||
|
||||
cat > server/.env <<EOF
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
@@ -237,7 +196,7 @@ if [[ "$USE_SSL" == "true" ]]; then
|
||||
# 1. Nginx Config
|
||||
cat > client/nginx-client.conf <<EOF
|
||||
server {
|
||||
listen $FINAL_PORT ssl;
|
||||
listen 443 ssl;
|
||||
server_name $UI_HOST;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
@@ -296,7 +255,7 @@ services:
|
||||
- app-network
|
||||
|
||||
backend:
|
||||
build: ./server
|
||||
image: ${IMAGE_SERVER}
|
||||
container_name: 3dp-backend
|
||||
restart: always
|
||||
depends_on:
|
||||
@@ -314,15 +273,16 @@ services:
|
||||
- app-network
|
||||
|
||||
frontend:
|
||||
build: ./client
|
||||
image: ${IMAGE_CLIENT}
|
||||
container_name: 3dp-frontend
|
||||
restart: always
|
||||
depends_on:
|
||||
- backend
|
||||
ports:
|
||||
- "${FINAL_PORT}:${FINAL_PORT}"
|
||||
- "${FINAL_PORT}:443"
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./client/nginx-client.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ${CERT_PATH}:/etc/nginx/certs/fullchain.pem:ro
|
||||
- ${KEY_PATH}:/etc/nginx/certs/privkey.pem:ro
|
||||
networks:
|
||||
@@ -342,7 +302,7 @@ else
|
||||
# 1. Nginx Config
|
||||
cat > client/nginx-client.conf <<EOF
|
||||
server {
|
||||
listen ${FINAL_PORT};
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
@@ -394,7 +354,7 @@ services:
|
||||
- app-network
|
||||
|
||||
backend:
|
||||
build: ./server
|
||||
image: ${IMAGE_SERVER}
|
||||
container_name: 3dp-backend
|
||||
restart: always
|
||||
depends_on:
|
||||
@@ -412,14 +372,16 @@ services:
|
||||
- app-network
|
||||
|
||||
frontend:
|
||||
build: ./client
|
||||
image: ${IMAGE_CLIENT}
|
||||
container_name: 3dp-frontend
|
||||
restart: always
|
||||
depends_on:
|
||||
- backend
|
||||
ports:
|
||||
- "${FINAL_PORT}:${FINAL_PORT}"
|
||||
- "${FINAL_PORT}:80"
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./client/nginx-client.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
|
||||
Reference in New Issue
Block a user