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