Skip to content

Commit

Permalink
Добавляет деплой
Browse files Browse the repository at this point in the history
  • Loading branch information
Suvorov771 committed Jan 31, 2023
1 parent 5bc06af commit b467e99
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: deploy

on:
release:
types: [published]

jobs:
deploy:
runs-on: htmlacademy_runner
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Deploy
run: |
cd deploy/ansible
ansible-playbook "deploy.yml"
4 changes: 4 additions & 0 deletions deploy/ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[defaults]

inventory=/var/ansible/inventory
deprecation_warnings=false
34 changes: 34 additions & 0 deletions deploy/ansible/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
- name: deploy
hosts: lo_eva08
gather_facts: no

vars:
project_name: vue-third-pizza-start-source
project_dir: "/usr/www/{{ project_name }}"

tasks:

- name: Create project dir
file:
path: "{{ project_dir }}"
state: directory

- name: Copy project
synchronize:
src: "{{ playbook_dir }}/../../"
dest: "{{ project_dir }}/"
delete: yes
recursive: yes

- name: Build docker image
shell: |
cd {{ project_dir }}/backend
docker build -t {{ project_name }}:latest . --no-cache
- name: Restart app and remove old image
shell: |
img=$(docker ps -a --filter "name=^{{ project_name }}$" --format "{{.Image}}")
cd {{ project_dir }}/deploy
docker-compose -p {{ project_name }} down
docker-compose -p {{ project_name }} up -d
docker rmi $img
21 changes: 21 additions & 0 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3'

services:

backend:
container_name: vue-third-pizza-start-source
image: vue-third-pizza-start-source:latest
restart: always
command: npm start
volumes:
- ../backend:/backend
- /backend/node_modules
ports:
- 4000:3000
networks:
- vue-third_network

networks:
vue-third_network:
name: vue-third_network
external: true

0 comments on commit b467e99

Please sign in to comment.