Compare commits
No commits in common. "f949b9970591f67c4edc7dbe312d24407c2073a9" and "4f3db08bdb285e13156b9698a83c59fc7630ec72" have entirely different histories.
f949b99705
...
4f3db08bdb
@ -9,24 +9,29 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: canina
|
runs-on: canina
|
||||||
timeout-minutes: 20
|
container:
|
||||||
|
image: node:20-alpine
|
||||||
|
timeout-minutes: 40
|
||||||
steps:
|
steps:
|
||||||
- name: Setup SSH key
|
- name: Setup SSH key
|
||||||
shell: sh
|
shell: sh
|
||||||
env:
|
env:
|
||||||
SSH_KEY: ${{ secrets.DEPLOY_KEY }}
|
SSH_KEY: ${{ secrets.DEPLOY_KEY }}
|
||||||
run: |
|
run: |
|
||||||
|
apk add --no-cache openssh-client bash
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "$SSH_KEY" > ~/.ssh/id_ed25519
|
echo "$SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
ssh-keyscan -p 2234 -H 172.17.0.1 >> ~/.ssh/known_hosts
|
ssh-keyscan -p 2234 -H 172.17.0.1 >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
- name: Deploy with VPN for build
|
- name: Deploy
|
||||||
shell: sh
|
shell: sh
|
||||||
timeout-minutes: 20
|
timeout-minutes: 38
|
||||||
env:
|
|
||||||
BRANCH: ${{ github.ref_name }}
|
|
||||||
run: |
|
run: |
|
||||||
|
BRANCH="${GITHUB_REF_NAME}"
|
||||||
echo "Deploying branch: ${BRANCH}"
|
echo "Deploying branch: ${BRANCH}"
|
||||||
ssh -o StrictHostKeyChecking=no -p 2234 devops@172.17.0.1 \
|
ssh -o StrictHostKeyChecking=no \
|
||||||
"bash /opt/services/scripts/with-vpn.sh \"bash /opt/services/canina/deploy.sh ${BRANCH}\""
|
-o ServerAliveInterval=30 \
|
||||||
|
-o ServerAliveCountMax=30 \
|
||||||
|
-p 2234 devops@172.17.0.1 \
|
||||||
|
"sudo bash /opt/services/scripts/depcanina.sh ${BRANCH}"
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
FROM node:20-alpine AS app-builder
|
FROM node:20-alpine AS app-builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
ENV NEXT_PUBLIC_API_URL=https://api.canina.ir/api
|
ENV NEXT_PUBLIC_API_URL=https://stageapi.canina.ir/api
|
||||||
COPY frontend/application/package*.json ./
|
COPY frontend/application/package*.json ./
|
||||||
RUN npm ci --include=dev --prefer-offline --no-audit
|
RUN npm ci --include=dev --prefer-offline --no-audit
|
||||||
COPY frontend/application ./
|
COPY frontend/application ./
|
||||||
@ -11,7 +11,7 @@ RUN npm run build
|
|||||||
|
|
||||||
FROM node:20-alpine AS admin-builder
|
FROM node:20-alpine AS admin-builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV VITE_API_URL=https://api.canina.ir/api
|
ENV VITE_API_URL=https://stageapi.canina.ir/api
|
||||||
COPY frontend/admin-panel/package*.json ./
|
COPY frontend/admin-panel/package*.json ./
|
||||||
RUN npm ci --include=dev --prefer-offline --no-audit
|
RUN npm ci --include=dev --prefer-offline --no-audit
|
||||||
COPY frontend/admin-panel ./
|
COPY frontend/admin-panel ./
|
||||||
|
|||||||
@ -131,5 +131,3 @@
|
|||||||
|
|
||||||
**تهیه شده با رویکرد پزشکی و رعایت اصل تناسب و پاکیزگی دیزاین.** ❤️
|
**تهیه شده با رویکرد پزشکی و رعایت اصل تناسب و پاکیزگی دیزاین.** ❤️
|
||||||
**کیفیت ممتاز آلمانی، دسترسی آسان ایرانی.**
|
**کیفیت ممتاز آلمانی، دسترسی آسان ایرانی.**
|
||||||
# CI/CD test
|
|
||||||
# CI/CD test
|
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
RUN apk add --no-cache openssl 2>/dev/null || true
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci --prefer-offline --no-audit
|
RUN npm config set registry http://registry.parsaaghayi.ir/repository/npm-proxy/ && npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV PRISMA_CLI_BINARY_TARGETS=linux-musl-openssl-3.0.x
|
ENV PRISMA_CLI_BINARY_TARGETS=linux-musl-openssl-3.0.x
|
||||||
RUN npx prisma generate && npm run build
|
RUN npx prisma generate && npm run build
|
||||||
|
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
RUN apk add --no-cache openssl 2>/dev/null || true
|
|
||||||
RUN mkdir -p /app/uploads && chown node:node /app/uploads
|
RUN mkdir -p /app/uploads && chown node:node /app/uploads
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --chown=node:node --from=builder /app/package*.json ./
|
COPY --chown=node:node --from=builder /app/package*.json ./
|
||||||
|
|||||||
@ -1,65 +1,63 @@
|
|||||||
services:
|
services:
|
||||||
db_prod:
|
db_stage:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
container_name: canino_db_prod
|
container_name: canino_db_stage
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: canino_prod
|
POSTGRES_USER: canino_stage
|
||||||
POSTGRES_PASSWORD: caninopassword_prod
|
POSTGRES_PASSWORD: caninopassword_stage
|
||||||
POSTGRES_DB: caninodb_prod
|
POSTGRES_DB: caninodb_stage
|
||||||
volumes:
|
volumes:
|
||||||
- canina_prod_db:/var/lib/postgresql/data
|
- canina_stage_db:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
- traefik_public
|
- traefik_public
|
||||||
|
|
||||||
redis_prod:
|
redis_stage:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
container_name: canino_redis_prod
|
container_name: canino_redis_stage
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- traefik_public
|
- traefik_public
|
||||||
|
|
||||||
backend_prod:
|
backend_stage:
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: ./backend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: canino_backend_prod
|
container_name: canino_backend_stage
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=postgresql://canino_prod:caninopassword_prod@db_prod:5432/caninodb_prod?schema=public
|
- DATABASE_URL=postgresql://canino_stage:caninopassword_stage@db_stage:5432/caninodb_stage?schema=public
|
||||||
- REDIS_HOST=redis_prod
|
- REDIS_HOST=redis_stage
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
- PORT=3000
|
- PORT=3000
|
||||||
volumes:
|
|
||||||
- canina_prod_uploads:/app/uploads
|
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.canina-api-prod.rule=Host(`api.canina.ir`) || Host(`apicanina.parsaaghayi.ir`)"
|
- "traefik.http.routers.canina-api-stage.rule=Host(`stageapi.canina.ir`) || Host(`api.caninastage.parsaaghayi.ir`)"
|
||||||
- "traefik.http.routers.canina-api-prod.entrypoints=websecure"
|
- "traefik.http.routers.canina-api-stage.entrypoints=websecure"
|
||||||
- "traefik.http.routers.canina-api-prod.tls=true"
|
- "traefik.http.routers.canina-api-stage.tls=true"
|
||||||
- "traefik.http.services.canina-api-prod.loadbalancer.server.port=3000"
|
- "traefik.http.services.canina-api-stage.loadbalancer.server.port=3000"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db_prod
|
- db_stage
|
||||||
- redis_prod
|
- redis_stage
|
||||||
networks:
|
networks:
|
||||||
- traefik_public
|
- traefik_public
|
||||||
|
|
||||||
frontend_prod:
|
frontend_stage:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: canino_frontend_prod
|
container_name: canino_frontend_stage
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- NEXT_PUBLIC_API_URL=http://backend_prod:3000
|
- NEXT_PUBLIC_API_URL=http://backend_stage:3000
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.canina-prod.rule=Host(`canina.ir`) || Host(`admin.canina.ir`) || Host(`canina.parsaaghayi.ir`) || Host(`admincanina.parsaaghayi.ir`)"
|
- "traefik.http.routers.canina-stage.rule=Host(`stage.canina.ir`) || Host(`stageadmin.canina.ir`) || Host(`caninastage.parsaaghayi.ir`)"
|
||||||
- "traefik.http.routers.canina-prod.entrypoints=websecure"
|
- "traefik.http.routers.canina-stage.entrypoints=websecure"
|
||||||
- "traefik.http.routers.canina-prod.tls=true"
|
- "traefik.http.routers.canina-stage.tls=true"
|
||||||
- "traefik.http.services.canina-prod.loadbalancer.server.port=8080"
|
- "traefik.http.services.canina-stage.loadbalancer.server.port=8080"
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend_prod
|
- backend_stage
|
||||||
networks:
|
networks:
|
||||||
- traefik_public
|
- traefik_public
|
||||||
|
|
||||||
@ -68,5 +66,4 @@ networks:
|
|||||||
external: true
|
external: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
canina_prod_db:
|
canina_stage_db:
|
||||||
canina_prod_uploads:
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
server {
|
server {
|
||||||
listen 8080;
|
listen 8080;
|
||||||
server_name canina.ir stage.canina.ir;
|
server_name __APP_HOST__;
|
||||||
|
|
||||||
# Security Headers
|
# Security Headers
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
@ -21,7 +21,7 @@ server {
|
|||||||
|
|
||||||
# Backend API
|
# Backend API
|
||||||
location /api {
|
location /api {
|
||||||
proxy_pass http://backend:3000;
|
proxy_pass http://__BACKEND_HOST__:3000;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
@ -33,7 +33,7 @@ server {
|
|||||||
|
|
||||||
server {
|
server {
|
||||||
listen 8080;
|
listen 8080;
|
||||||
server_name admin.canina.ir stageadmin.canina.ir;
|
server_name __ADMIN_HOST__;
|
||||||
|
|
||||||
root /app/admin_static;
|
root /app/admin_static;
|
||||||
index index.html;
|
index index.html;
|
||||||
@ -52,7 +52,7 @@ server {
|
|||||||
|
|
||||||
# Backend API for Admin
|
# Backend API for Admin
|
||||||
location /api {
|
location /api {
|
||||||
proxy_pass http://backend:3000;
|
proxy_pass http://__BACKEND_HOST__:3000;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user