Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ name: Build and Deploy

on:
push:
branches:
- main
branches: [ main, staging ]

env:
DEPLOYMENT_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'staging' }}

jobs:
build:
runs-on: self-hosted
runs-on: ${{ github.ref == 'refs/heads/main' && 'self-hosted' || 'gcidp' }}
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Build
env:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
run: docker compose up --build -d
COMMIT_SHA: ${{ github.sha }}
run: docker compose -f docker-compose.${{ env.DEPLOYMENT_ENV }}.yml up -d --build

- name: Cleanup
run: docker system prune -f
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
uses: actions/checkout@v3

- name: Build
run: docker compose build
run: docker compose -f docker-compose.production.yml build
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx:1.21.6 AS nginx
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/nginx.conf
CMD ["nginx", "-g", "daemon off;"]
11 changes: 4 additions & 7 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
FROM node:20-alpine as build-stage
FROM node:20-alpine AS build-stage

WORKDIR /app
RUN npm install -g pnpm@8.15.2
COPY package.json pnpm-lock.yaml .npmrc ./
RUN pnpm i --frozen-lockfile
COPY . .

FROM build-stage as prod
FROM build-stage AS prod
ARG NUXT_PUBLIC_API_URL
ENV NUXT_PUBLIC_API_URL=$NUXT_PUBLIC_API_URL
RUN pnpm build
CMD pnpm start:prod

FROM nginx:1.21.6 as nginx
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=node /app/.output/public /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
3 changes: 2 additions & 1 deletion app/pages/positions/import.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ async function upload() {
loading.value = true;
try {
const {error} = await rpcService.create({
method: 'UploadPositionsFromExcel', params: {
method: 'UploadPositionsFromExcel',
params: {
fileId: fileId.value
}
}).exec();
Expand Down
2 changes: 1 addition & 1 deletion back/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"password": "postgres",
"username": "postgres"
},
"gcidp": {
"staging": {
"database": "elxolding",
"dialect": "postgres",
"host": "elxolding_db",
Expand Down
6 changes: 0 additions & 6 deletions back/config/gcidp.json

This file was deleted.

6 changes: 6 additions & 0 deletions back/config/staging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"host": "api-elxolding.ci.iota.uz",
"port": 3030,
"images_url": "https://api-elxolding.ci.iota.uz/media/",
"postgres": "postgres://postgres:postgres@elxolding_db/elxolding"
}
12 changes: 12 additions & 0 deletions docker-compose.yml → docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ services:
build:
context: ./app
target: prod
args:
- NUXT_PUBLIC_API_URL=/api

nginx:
restart: always
image: nginx:1.21.3
build:
context: ./
target: nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ~/volumes/elxolding/uploads:/www/media
ports:
- "80:80"
depends_on:
- back

back:
restart: always
Expand Down
67 changes: 67 additions & 0 deletions docker-compose.staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: '3.8'

services:
front:
restart: always
build:
context: ./app
target: prod
args:
- NUXT_PUBLIC_API_URL=https://api-elxolding.ci.iota.uz
environment:
- NUXT_PUBLIC_API_URL=https://api-elxolding.ci.iota.uz
labels:
- "traefik.enable=true"
- "traefik.docker.network=app"
- "traefik.http.routers.${COMMIT_SHA}-front.rule=Host(`elxolding.ci.iota.uz`)"
- "traefik.http.routers.${COMMIT_SHA}-front.tls=true"
- "traefik.http.routers.${COMMIT_SHA}-front.tls.certresolver=letsencrypt"
- "traefik.http.routers.${COMMIT_SHA}-front.tls.domains[0].main=iota.uz"
- "traefik.http.routers.${COMMIT_SHA}-front.tls.domains[0].sans=*.ci.iota.uz"
- "traefik.http.services.${COMMIT_SHA}-front.loadbalancer.server.port=80"
volumes:
- ~/volumes/elxolding/uploads:/www/media
networks:
- app

back:
restart: always
build:
context: ./back
target: prod
environment:
NODE_ENV: staging
labels:
- "traefik.enable=true"
- "traefik.docker.network=app"
- "traefik.http.routers.${COMMIT_SHA}-back.rule=Host(`api-elxolding.ci.iota.uz`)"
- "traefik.http.routers.${COMMIT_SHA}-back.tls=true"
- "traefik.http.routers.${COMMIT_SHA}-back.tls.certresolver=letsencrypt"
- "traefik.http.routers.${COMMIT_SHA}-back.tls.domains[0].main=iota.uz"
- "traefik.http.routers.${COMMIT_SHA}-back.tls.domains[0].sans=*.ci.iota.uz"
- "traefik.http.services.${COMMIT_SHA}-back.loadbalancer.server.port=3030"
volumes:
- ~/volumes/elxolding/postgres:/app/uploads
depends_on:
- db
networks:
- app

db:
restart: always
image: postgres:15.1
hostname: elxolding_db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: elxolding
ports:
- "17565:5432"
volumes:
- ~/volumes/elxolding/postgres:/var/lib/postgresql/data
networks:
- app

networks:
app:
external: true
7 changes: 5 additions & 2 deletions app/nginx/default.conf → nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ server {
listen 80;
listen [::]:80;

location /api/ {
proxy_pass http://back:3030/;
}

location / {
alias /usr/share/nginx/html;
try_files $uri @node;
proxy_pass http://front:80;
}

location /uploads/media/ {
Expand Down
File renamed without changes.