Merge pull request #4 from LISA-ITMO/dockerfile-dependencies #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DEV workflow | |
on: | |
push: | |
branches: | |
- DEV | |
jobs: | |
build_and_push_front_to_docker_hub: | |
name: Push Docker frontend image to DockerHub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
ref: 'DEV' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.2.0 | |
- name: Login to Docker | |
uses: docker/login-action@v3.1.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: ./ | |
file: client/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/frontend:DEV | |
build_and_push_users_to_docker_hub: | |
name: Push Docker Users image to DockerHub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
ref: 'DEV' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.2.0 | |
- name: Login to Docker | |
uses: docker/login-action@v3.1.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: ./users | |
file: users/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/backend-users:DEV | |
build_and_push_tests_to_docker_hub: | |
name: Push Docker tests image to DockerHub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
ref: 'DEV' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.2.0 | |
- name: Login to Docker | |
uses: docker/login-action@v3.1.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: ./tests | |
file: tests/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/backend-tests:DEV | |
build_and_push_subjects_to_docker_hub: | |
name: Push Docker subjects image to DockerHub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
ref: 'DEV' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.2.0 | |
- name: Login to Docker | |
uses: docker/login-action@v3.1.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: ./subjects | |
file: subjects/docker/dev/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/backend-subjects:DEV | |
build_and_push_analytics_to_docker_hub: | |
name: Push Docker analytics image to DockerHub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
ref: 'DEV' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.2.0 | |
- name: Login to Docker | |
uses: docker/login-action@v3.1.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: ./analytics | |
file: analytics/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/backend-analytics:DEV | |
deploy: | |
name: Деплой на сервер | |
runs-on: ubuntu-latest | |
needs: | |
- build_and_push_subjects_to_docker_hub | |
- build_and_push_users_to_docker_hub | |
- build_and_push_tests_to_docker_hub | |
- build_and_push_analytics_to_docker_hub | |
- build_and_push_front_to_docker_hub | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Executing remote ssh commands to stop docker, clean up | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
password: ${{ secrets.SSH_PASSPHRASE }} | |
script: | | |
docker compose -f DEV/compose/docker-compose-DH-DEV.yml down | |
docker volume rm compose-dev_static | |
cp -r DEV/compose/env ./env | |
rm -rf DEV | |
mkdir -p DEV/compose | |
mv ./env DEV/compose | |
- name: Copy compose via ssh | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
password: ${{ secrets.SSH_PASSPHRASE }} | |
source: "compose" | |
target: "DEV" | |
- name: Executing remote ssh commands to deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
password: ${{ secrets.SSH_PASSPHRASE }} | |
script: | | |
mkdir DEV/dbs | |
touch DEV/dbs/users_db.sqlite3 | |
touch DEV/dbs/tests_db.sqlite3 | |
touch DEV/dbs/subjects_db.sqlite3 | |
touch DEV/dbs/analytics_db.sqlite3 | |
docker compose -f DEV/compose/docker-compose-DH-DEV.yml pull | |
docker compose -f DEV/compose/docker-compose-DH-DEV.yml up --build -d | |
docker system prune -af |