Circleci project setup (close #86) (#104)

* feat: build and deploy services
This commit is contained in:
Leandro Antônio Farias Machado 2023-08-15 10:50:23 -03:00 committed by GitHub
parent 2ea567d7d7
commit 44ee44b3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,66 +9,51 @@ executors:
jobs: jobs:
build_controller: build_and_deploy_controller:
executor: golang executor: golang
steps: steps:
- checkout - checkout
- run: - run:
name: Build Controller name: Build and Deploy Controller
command: | command: |
cd backend/services/controller && go build -o controller cmd/oktopus/main.go cd backend/services/controller && go build -o controller cmd/oktopus/main.go
scp -o StrictHostKeyChecking=no controller $SSH_USER@$SSH_HOST:/home/$SSH_USER
ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "sudo mv controller /usr/bin/ && sudo systemctl restart controller"
build_mochi: build_and_deploy_mochi:
executor: golang executor: golang
steps: steps:
- checkout - checkout
- run: - run:
name: Build Mochi name: Build and Deploy Mochi
command: | command: |
cd backend/services/mochi/ && go build -o mochi cmd/main.go cd backend/services/mochi/ && go build -o mochi cmd/main.go
scp -o StrictHostKeyChecking=no mochi $SSH_USER@$SSH_HOST:/home/$SSH_USER
ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "sudo mv mochi /usr/bin/ && sudo systemctl restart mochi"
build_frontend: build_and_deploy_frontend:
executor: nodejs executor: nodejs
steps: steps:
- checkout - checkout
- run: - run:
name: Build Frontend name: Build and Deploy Frontend
command: | command: |
cd frontend/ && npm i && npm run build cd frontend && npm i && npm run build
scp -o StrictHostKeyChecking=no -r .next/ $SSH_USER@$SSH_HOST:/home/$SSH_USER/oktopus/frontend
ssh -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "pm2 restart oktopus"
deploy_controller:
machine:
image: ubuntu-2004:202010-01
steps:
- run:
name: Send Binary to Server
command: |
scp backend/services/controller/controller $SSH_USER@$SSH_HOST:/home/$SSH_USER
ssh $SSH_USER@$SSH_HOST
- run:
name: Restart Services
command: |
sudo su
mv controller /usr/bin/
systemctl restart controller
workflows: workflows:
build_and_deploy: build_and_deploy:
jobs: jobs:
- build_controller: - build_and_deploy_controller:
filters: filters:
branches: branches:
only: dev only: main
- build_mochi: - build_and_deploy_mochi:
filters: filters:
branches: branches:
only: dev only: main
- build_frontend: - build_and_deploy_frontend:
filters: filters:
branches: branches:
only: dev only: main
- deploy_controller:
requires:
- build_controller
filters:
branches:
only: dev