Compare commits

..

No commits in common. "f949b9970591f67c4edc7dbe312d24407c2073a9" and "4f3db08bdb285e13156b9698a83c59fc7630ec72" have entirely different histories.

6 changed files with 46 additions and 48 deletions

View File

@ -9,24 +9,29 @@ on:
jobs:
deploy:
runs-on: canina
timeout-minutes: 20
container:
image: node:20-alpine
timeout-minutes: 40
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 with VPN for build
- name: Deploy
shell: sh
timeout-minutes: 20
env:
BRANCH: ${{ github.ref_name }}
timeout-minutes: 38
run: |
BRANCH="${GITHUB_REF_NAME}"
echo "Deploying branch: ${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}\""
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}"

View File

@ -1,7 +1,7 @@
FROM node:20-alpine AS app-builder
WORKDIR /app
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 ./
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://api.canina.ir/api
ENV VITE_API_URL=https://stageapi.canina.ir/api
COPY frontend/admin-panel/package*.json ./
RUN npm ci --include=dev --prefer-offline --no-audit
COPY frontend/admin-panel ./

View File

@ -131,5 +131,3 @@
**تهیه شده با رویکرد پزشکی و رعایت اصل تناسب و پاکیزگی دیزاین.** ❤️
**کیفیت ممتاز آلمانی، دسترسی آسان ایرانی.**
# CI/CD test
# CI/CD test

View File

@ -1,14 +1,12 @@
FROM node:20-alpine AS builder
RUN apk add --no-cache openssl 2>/dev/null || true
WORKDIR /app
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 . .
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 ./

View File

@ -1,65 +1,63 @@
services:
db_prod:
db_stage:
image: postgres:16-alpine
container_name: canino_db_prod
container_name: canino_db_stage
restart: always
environment:
POSTGRES_USER: canino_prod
POSTGRES_PASSWORD: caninopassword_prod
POSTGRES_DB: caninodb_prod
POSTGRES_USER: canino_stage
POSTGRES_PASSWORD: caninopassword_stage
POSTGRES_DB: caninodb_stage
volumes:
- canina_prod_db:/var/lib/postgresql/data
- canina_stage_db:/var/lib/postgresql/data
networks:
- traefik_public
redis_prod:
redis_stage:
image: redis:7-alpine
container_name: canino_redis_prod
container_name: canino_redis_stage
restart: always
networks:
- traefik_public
backend_prod:
backend_stage:
build:
context: ./backend
dockerfile: Dockerfile
container_name: canino_backend_prod
container_name: canino_backend_stage
restart: always
environment:
- DATABASE_URL=postgresql://canino_prod:caninopassword_prod@db_prod:5432/caninodb_prod?schema=public
- REDIS_HOST=redis_prod
- DATABASE_URL=postgresql://canino_stage:caninopassword_stage@db_stage:5432/caninodb_stage?schema=public
- REDIS_HOST=redis_stage
- REDIS_PORT=6379
- PORT=3000
volumes:
- canina_prod_uploads:/app/uploads
labels:
- "traefik.enable=true"
- "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"
- "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"
depends_on:
- db_prod
- redis_prod
- db_stage
- redis_stage
networks:
- traefik_public
frontend_prod:
frontend_stage:
build:
context: .
dockerfile: Dockerfile
container_name: canino_frontend_prod
container_name: canino_frontend_stage
restart: always
environment:
- NEXT_PUBLIC_API_URL=http://backend_prod:3000
- NEXT_PUBLIC_API_URL=http://backend_stage:3000
labels:
- "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-prod.entrypoints=websecure"
- "traefik.http.routers.canina-prod.tls=true"
- "traefik.http.services.canina-prod.loadbalancer.server.port=8080"
- "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"
depends_on:
- backend_prod
- backend_stage
networks:
- traefik_public
@ -68,5 +66,4 @@ networks:
external: true
volumes:
canina_prod_db:
canina_prod_uploads:
canina_stage_db:

View File

@ -1,6 +1,6 @@
server {
listen 8080;
server_name canina.ir stage.canina.ir;
server_name __APP_HOST__;
# Security Headers
server_tokens off;
@ -21,7 +21,7 @@ server {
# Backend API
location /api {
proxy_pass http://backend:3000;
proxy_pass http://__BACKEND_HOST__: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.canina.ir stageadmin.canina.ir;
server_name __ADMIN_HOST__;
root /app/admin_static;
index index.html;
@ -52,7 +52,7 @@ server {
# Backend API for Admin
location /api {
proxy_pass http://backend:3000;
proxy_pass http://__BACKEND_HOST__:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';