mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Update CI/CD configuration with SSH key
This commit is contained in:
@@ -1,73 +1,42 @@
|
|||||||
image: python:3.11
|
image: python:3.11
|
||||||
|
|
||||||
variables:
|
|
||||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .pip-cache/
|
|
||||||
- backend/venv/
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- build
|
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
|
variables:
|
||||||
|
DOCKER_HOST: tcp://docker:2375
|
||||||
|
SSH_PRIVATE_KEY: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDI1N1+AZhGX1QHu6x5vzH3kLiWnddDkKd4gkok+9Vu2dhREiQ/uIVJA1KZgqUZ0vdaD1GTJmtDN6qvn0ef7GIvKE9QuGki/JimFmrZJx75jfsXt2Un7/lTX1Zfa1O9n2fGPFuULGEj7A4eeIxe9RVjbbYRyJR30j2oJ9wr0wC7IP6pnjDZELoJYLEm9x1UfwQeQp6f"
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- python -V
|
- python -V
|
||||||
- python -m venv backend/venv
|
- pip install -r backend/requirements.txt
|
||||||
- source backend/venv/bin/activate
|
|
||||||
- pip install --upgrade pip
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
services:
|
|
||||||
- redis:latest
|
|
||||||
- postgres:15
|
|
||||||
variables:
|
|
||||||
POSTGRES_DB: app
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/app
|
|
||||||
REDIS_HOST: redis
|
|
||||||
script:
|
script:
|
||||||
- cd backend
|
- cd backend
|
||||||
- pip install -r requirements.txt
|
|
||||||
- pytest -v
|
- pytest -v
|
||||||
only:
|
only:
|
||||||
- main
|
- main
|
||||||
- merge_requests
|
- Testing
|
||||||
|
|
||||||
lint:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- cd backend
|
|
||||||
- pip install flake8
|
|
||||||
- flake8 .
|
|
||||||
only:
|
|
||||||
- main
|
|
||||||
- merge_requests
|
|
||||||
|
|
||||||
build:
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- cd backend
|
|
||||||
- pip install -r requirements.txt
|
|
||||||
- echo "Building application..."
|
|
||||||
- python -c "import sys; print(sys.version)"
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- backend/
|
|
||||||
only:
|
|
||||||
- main
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
script:
|
script:
|
||||||
- echo "Deploying application..."
|
- apt-get update -qy
|
||||||
- cd backend
|
- apt-get install -y openssh-client
|
||||||
- alembic upgrade head
|
- mkdir -p ~/.ssh
|
||||||
environment:
|
- chmod 700 ~/.ssh
|
||||||
name: production
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
|
||||||
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
|
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
|
||||||
|
- scp -r * root@185.139.70.62:/root/app/
|
||||||
|
- ssh root@185.139.70.62 "cd /root/app && docker-compose down && docker-compose up -d"
|
||||||
only:
|
only:
|
||||||
- main
|
- main
|
||||||
|
environment:
|
||||||
|
name: production
|
||||||
Reference in New Issue
Block a user