From 3adc568ae4ccc112d2ffc678ede08518f282e373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:13:45 +0300 Subject: [PATCH 01/33] fix --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3b9f7d9..3508ea4 100644 --- a/Makefile +++ b/Makefile @@ -40,15 +40,13 @@ update: setup-ci: sudo adduser github - su github - ssh-keygen + sudo -u github ssh-keygen #ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"\ - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys + sudo -u github cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys2 - chmod 700 -R ~/.ssh - chmod 640 ~/.ssh/authorized_keys - exit + sudo -u github chmod 700 -R ~/.ssh + sudo -u github chmod 640 ~/.ssh/authorized_keys nano /etc/ssh/sshd_config #AllowUsers github #Match User github From d4a1ba485212d2b84f0b6d3c37e620678efc931b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:14:53 +0300 Subject: [PATCH 02/33] fix --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3508ea4..0f3bc82 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,8 @@ update: echo "Frontend updated successfully" setup-ci: - sudo adduser github + # Add user if not exists + id -u github &>/dev/null || sudo adduser github sudo -u github ssh-keygen #ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"\ sudo -u github cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys From 2e5a6768d0b51e3c7b7dcc2b42672a6dd501d634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:18:28 +0300 Subject: [PATCH 03/33] fix --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0f3bc82..8ebc9ed 100644 --- a/Makefile +++ b/Makefile @@ -43,11 +43,11 @@ setup-ci: id -u github &>/dev/null || sudo adduser github sudo -u github ssh-keygen #ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"\ - sudo -u github cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys + sudo cat /home/github/.ssh/id_rsa.pub >> /home/github/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys2 - sudo -u github chmod 700 -R ~/.ssh - sudo -u github chmod 640 ~/.ssh/authorized_keys + sudo -u github chmod 700 -R /home/github/.ssh + sudo -u github chmod 640 /home/github/.ssh/authorized_keys nano /etc/ssh/sshd_config #AllowUsers github #Match User github From 924fa7359cb5f249f9416619bc8c63ca555c8632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:20:37 +0300 Subject: [PATCH 04/33] fix --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8ebc9ed..a16c83e 100644 --- a/Makefile +++ b/Makefile @@ -46,8 +46,8 @@ setup-ci: sudo cat /home/github/.ssh/id_rsa.pub >> /home/github/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys2 - sudo -u github chmod 700 -R /home/github/.ssh - sudo -u github chmod 640 /home/github/.ssh/authorized_keys + sudo chmod 777 -R /home/github/.ssh + sudo chmod 666 /home/github/.ssh/authorized_keys nano /etc/ssh/sshd_config #AllowUsers github #Match User github From 33ef92430e003ac6a40aa9b1380eb8cb6397accb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:23:35 +0300 Subject: [PATCH 05/33] fix --- Makefile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a16c83e..ce74471 100644 --- a/Makefile +++ b/Makefile @@ -48,15 +48,19 @@ setup-ci: #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys2 sudo chmod 777 -R /home/github/.ssh sudo chmod 666 /home/github/.ssh/authorized_keys - nano /etc/ssh/sshd_config - #AllowUsers github - #Match User github - #PasswordAuthentication no - #AllowTCPForwarding no - #X11Forwarding no + echo "" && \ + echo 'Add this politics for github user: [press Enter]' && \ + echo 'AllowUsers github' && \ + 'Match User github' && \ + 'PasswordAuthentication no' && \ + 'AllowTCPForwarding no' && \ + 'X11Forwarding no' && \ + echo '[press Enter...]' && \ + read ENTER + edit /etc/ssh/sshd_config echo "" && \ echo 'Add this public rsa key to Deploy keys in your github directory: [press Enter]' && \ - read ENTER && \ + read ENTER sudo less /home/github/.ssh/id_rsa all: From 01b10effa267ba579bdead4c12d45ed0cb146386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:24:24 +0300 Subject: [PATCH 06/33] fix --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ce74471..2b4176c 100644 --- a/Makefile +++ b/Makefile @@ -51,10 +51,10 @@ setup-ci: echo "" && \ echo 'Add this politics for github user: [press Enter]' && \ echo 'AllowUsers github' && \ - 'Match User github' && \ - 'PasswordAuthentication no' && \ - 'AllowTCPForwarding no' && \ - 'X11Forwarding no' && \ + echo 'Match User github' && \ + echo 'PasswordAuthentication no' && \ + echo 'AllowTCPForwarding no' && \ + echo 'X11Forwarding no' && \ echo '[press Enter...]' && \ read ENTER edit /etc/ssh/sshd_config From 7c9b905c7c80d19b5cdae83e0b45fff8bb724406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:25:42 +0300 Subject: [PATCH 07/33] fix --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2b4176c..b46be90 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ setup-ci: echo 'X11Forwarding no' && \ echo '[press Enter...]' && \ read ENTER - edit /etc/ssh/sshd_config + nano /etc/ssh/sshd_config echo "" && \ echo 'Add this public rsa key to Deploy keys in your github directory: [press Enter]' && \ read ENTER @@ -65,7 +65,7 @@ setup-ci: all: cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env - edit ./docker-deploy/.env + nano ./docker-deploy/.env make generate-scripts make set-auto-renewing-certs make setup-ci From 3a4a118f80db882a13007b9ab2c489b5743f3801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:30:49 +0300 Subject: [PATCH 08/33] fix --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b46be90..d64ff82 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,7 @@ setup-ci: # Add user if not exists id -u github &>/dev/null || sudo adduser github sudo -u github ssh-keygen + chown -R github $$(pwd) #ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"\ sudo cat /home/github/.ssh/id_rsa.pub >> /home/github/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys @@ -59,9 +60,8 @@ setup-ci: read ENTER nano /etc/ssh/sshd_config echo "" && \ - echo 'Add this public rsa key to Deploy keys in your github directory: [press Enter]' && \ - read ENTER - sudo less /home/github/.ssh/id_rsa + echo 'Add this public rsa key to Deploy keys in your github directory: ' && \ + sudo cat /home/github/.ssh/id_rsa.pub all: cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env From 3a8451d1e2c2c79d93c8b93837e77085e5799b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:32:33 +0300 Subject: [PATCH 09/33] fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d64ff82..2316928 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ setup-ci: # Add user if not exists id -u github &>/dev/null || sudo adduser github sudo -u github ssh-keygen - chown -R github $$(pwd) + sudo chown -R github $$(pwd) #ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"\ sudo cat /home/github/.ssh/id_rsa.pub >> /home/github/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys From fe81d05457ff3d63cac0c21cd912351a6d0efacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:37:39 +0300 Subject: [PATCH 10/33] fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2316928..daa1907 100644 --- a/Makefile +++ b/Makefile @@ -39,10 +39,10 @@ update: echo "Frontend updated successfully" setup-ci: + sudo chown -R github:legend . # Add user if not exists id -u github &>/dev/null || sudo adduser github sudo -u github ssh-keygen - sudo chown -R github $$(pwd) #ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"\ sudo cat /home/github/.ssh/id_rsa.pub >> /home/github/.ssh/authorized_keys #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys From c19c4b0b6ca1447e64a8b708eb853d7ec363fa30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 29 Jan 2024 23:59:47 +0300 Subject: [PATCH 11/33] Write README --- README.md | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index e75394f..f2ed8bd 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,20 @@ -# Фронтенд интерфейса оператора (отбора/подпитки) +![GithubCI](https://github.com/sergtyapkin/vue-frontend-template/actions/workflows/deploy.yml/badge.svg) -## Установка из исходников +# Фронентд с авто-деплоем на _Nginx_ и получением сертификатов _Letsencript_ -### 1. Установить зависимости: -`yarn` +Всё делается через команды `make` -### 2. Сборка -- #### В прод: `yarn dist` -- #### Для разработки: `yarn dev` - -## Установка и запуск через Docker - -### Сборка из исходников -``` -make build -``` - -### Загрузка из Docker Container Registry -``` -docker login git.sberrobots.ru:8443 -make pull +### 1. Клонируем: +```SHELL +git clone ``` -### Запуск -``` -make run -``` -Страница будет доступна по адресу `https://localhost:8000` +### 2. Настраиваем вообще всё. +В самом начале нужно будет настроить `.env` файл, прописать правильный `DOMAIN_URL` +```SHELL +cd +make all +```` -### Остановка -``` -make stop -``` +Всё. Наслаждаемся тем, что за нас всё сделали, сайт раздаётся, сертификаты обновляются. +Теперь `Github CI` сам будет проверять, собирается ли контейнер при **Pull Request**'ах, а при **Push**'ах в ветку `master` будет автоматически выполняться `make update` на сервере и обновлять деплой. From 92485be71c7a04141cf5da6d60b944a8f04cd2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:13:50 +0300 Subject: [PATCH 12/33] Write README --- .github/workflows/deploy.yml | 8 ++++-- Makefile | 49 ++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 17a9d8e..783b6a6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,10 +8,14 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@master + + - name: Deploy to server + uses: appleboy/ssh-action@master with: host: ${{ vars.DEPLOY_HOST }} - username: github + username: legend key: ${{ secrets.SSH_DEPLOY_KEY }} script: | cd /home/vue-frontend-template diff --git a/Makefile b/Makefile index daa1907..a7ff130 100644 --- a/Makefile +++ b/Makefile @@ -39,29 +39,34 @@ update: echo "Frontend updated successfully" setup-ci: - sudo chown -R github:legend . - # Add user if not exists - id -u github &>/dev/null || sudo adduser github - sudo -u github ssh-keygen - #ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"\ - sudo cat /home/github/.ssh/id_rsa.pub >> /home/github/.ssh/authorized_keys - #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys - #cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys2 - sudo chmod 777 -R /home/github/.ssh - sudo chmod 666 /home/github/.ssh/authorized_keys - echo "" && \ - echo 'Add this politics for github user: [press Enter]' && \ - echo 'AllowUsers github' && \ - echo 'Match User github' && \ - echo 'PasswordAuthentication no' && \ - echo 'AllowTCPForwarding no' && \ - echo 'X11Forwarding no' && \ - echo '[press Enter...]' && \ + #id -u github &>/dev/null || sudo adduser github # Add user if not exists + #sudo chown -R github:legend . + #sudo -u github ssh-keygen + #sudo cat /home/github/.ssh/id_rsa.pub >> /home/github/.ssh/authorized_keys + #sudo chmod 777 -R /home/github/.ssh + #sudo chmod 666 /home/github/.ssh/authorized_keys + #sudo -u github ssh-keygen + #echo "" && \ +# echo 'Add this politics for github user: [press Enter]' && \ +# echo 'AllowUsers github' && \ +# echo 'Match User github' && \ +# echo 'PasswordAuthentication no' && \ +# echo 'AllowTCPForwarding no' && \ +# echo 'X11Forwarding no' && \ +# echo '[press Enter...]' && \ +# read ENTER + #nano /etc/ssh/sshd_config + #echo "" && \ +# echo 'Add this public rsa key to Deploy keys in your github directory: ' && \ +# sudo cat /home/github/.ssh/id_rsa.pub + ssh-keygen -f /tmp/tmp_key + sudo mkdir -r ~/.ssh + sudo cat /tmp/tmp_key.pub >> ~/.ssh/authorized_keys + echo '' && \ + echo 'Add this private rsa key secret deploy variables to SSH_DEPLOY_KEY on your github repo: ' && \ + echo '[press Enter...]' && \ read ENTER - nano /etc/ssh/sshd_config - echo "" && \ - echo 'Add this public rsa key to Deploy keys in your github directory: ' && \ - sudo cat /home/github/.ssh/id_rsa.pub + sudo less /tmp/tmp_key all: cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env From 0710ef4fcfd05582078827b66fbc17dcbef9ef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:19:30 +0300 Subject: [PATCH 13/33] fix mkdir --- .github/workflows/deploy.yml | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 783b6a6..4a5c1b3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,6 +3,7 @@ name: Makefile CI on: push: branches: [ "master" ] + repository_dispatch: jobs: deploy: diff --git a/Makefile b/Makefile index a7ff130..35be533 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ setup-ci: # echo 'Add this public rsa key to Deploy keys in your github directory: ' && \ # sudo cat /home/github/.ssh/id_rsa.pub ssh-keygen -f /tmp/tmp_key - sudo mkdir -r ~/.ssh + sudo mkdir -p ~/.ssh sudo cat /tmp/tmp_key.pub >> ~/.ssh/authorized_keys echo '' && \ echo 'Add this private rsa key secret deploy variables to SSH_DEPLOY_KEY on your github repo: ' && \ From ceaf1725fde9a3f5a6c554d9d49245ad7e4aac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:20:08 +0300 Subject: [PATCH 14/33] fix path --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4a5c1b3..99e55e2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,5 +19,5 @@ jobs: username: legend key: ${{ secrets.SSH_DEPLOY_KEY }} script: | - cd /home/vue-frontend-template + cd ~/vue-frontend-template sudo make update From 67cb4302dce27202a05e48f1dd936b87e956a4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:30:33 +0300 Subject: [PATCH 15/33] fix deploy.yml --- .github/workflows/deploy.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 99e55e2..91c6091 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,11 +13,12 @@ jobs: uses: actions/checkout@master - name: Deploy to server + if: ${{ !env.ACT }} uses: appleboy/ssh-action@master with: host: ${{ vars.DEPLOY_HOST }} - username: legend + username: ${{ secrets.SERVER_USERNAME }} key: ${{ secrets.SSH_DEPLOY_KEY }} script: | - cd ~/vue-frontend-template + cd ${{ vars.PROJECT_PATH }} sudo make update From 96b86e57568ec838c8c15ab0471e2b61eedcae5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:40:58 +0300 Subject: [PATCH 16/33] fix deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 91c6091..7be2d04 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,7 +14,7 @@ jobs: - name: Deploy to server if: ${{ !env.ACT }} - uses: appleboy/ssh-action@master + uses: appleboy/ssh-action@v1.0.3 with: host: ${{ vars.DEPLOY_HOST }} username: ${{ secrets.SERVER_USERNAME }} From 72506d697573e2947c45a1a77ee329c9c6dc0621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:44:33 +0300 Subject: [PATCH 17/33] fix deploy.yml --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7be2d04..20e5925 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,6 +8,7 @@ on: jobs: deploy: runs-on: ubuntu-latest + environment: deploy steps: - name: Checkout uses: actions/checkout@master From 1c50147e9d136388aeaaddd8f103343af05794cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:52:27 +0300 Subject: [PATCH 18/33] fix deploy.yml --- Makefile | 4 +++- README.md | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 35be533..2e6ed88 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,17 @@ #TAG ?= $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match) -include docker-deploy/.env generate-certs: + include docker-deploy/.env cd docker-deploy && \ docker compose down && \ docker compose up -d nginx-certbot && \ docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d $(DOMAIN_URL) renew-certs: + include docker-deploy/.env cd docker-deploy && \ docker compose run --rm certbot renew set-auto-renewing-certs: + include docker-deploy/.env sudo apt-get update sudo apt-get install cron echo "----------------------------------------------------------------------------------------------" && \ diff --git a/README.md b/README.md index f2ed8bd..6d1023e 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ ### 1. Клонируем: ```SHELL -git clone +git clone git@github.com:SergTyapkin/vue-frontend-template.git ``` ### 2. Настраиваем вообще всё. В самом начале нужно будет настроить `.env` файл, прописать правильный `DOMAIN_URL` ```SHELL -cd +cd vue-frontend-template make all ```` From 2f50fb50cb963a9afdcab5af4bfd24e64574d7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:54:36 +0300 Subject: [PATCH 19/33] fix Make --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2e6ed88..6e74e91 100644 --- a/Makefile +++ b/Makefile @@ -72,8 +72,12 @@ setup-ci: all: cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env + echo '' && \ + echo 'Edit .env file. Write right DOMAIN_URL!' && \ + echo '[press Enter...]' && \ + read ENTER nano ./docker-deploy/.env - make generate-scripts + make generate-certs make set-auto-renewing-certs make setup-ci make update From 6e7bcb93eeba7d2639e93714d8e44b468cdb743f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 00:58:47 +0300 Subject: [PATCH 20/33] fix Make --- Makefile | 4 +--- docker-deploy/.env.example | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6e74e91..fb0d591 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,15 @@ #TAG ?= $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match) +-include ./docker-deploy/.env generate-certs: - include docker-deploy/.env cd docker-deploy && \ docker compose down && \ docker compose up -d nginx-certbot && \ docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d $(DOMAIN_URL) renew-certs: - include docker-deploy/.env cd docker-deploy && \ docker compose run --rm certbot renew set-auto-renewing-certs: - include docker-deploy/.env sudo apt-get update sudo apt-get install cron echo "----------------------------------------------------------------------------------------------" && \ diff --git a/docker-deploy/.env.example b/docker-deploy/.env.example index 3ed6e10..22e983c 100644 --- a/docker-deploy/.env.example +++ b/docker-deploy/.env.example @@ -1,6 +1,5 @@ NODE_RELEASE=18 -# Nginx not alpine. Must have 'envsubst' inside -NGINX_RELEASE=1.23.3 +NGINX_RELEASE=1.23.3-alpine FRONTEND_COMPOSE_NAME=frontend-compose API_PORT=3000 DOMAIN_URL=your.domain From 92c27ca8dff3c979ad0899ce6542a97e7fe3df74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:01:35 +0300 Subject: [PATCH 21/33] fix Make --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index fb0d591..b4dff09 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,10 @@ setup-ci: sudo less /tmp/tmp_key all: + # add user to docker group + sudo groupadd docker + sudo usermod -aG docker $USER + newgrp docker cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env echo '' && \ echo 'Edit .env file. Write right DOMAIN_URL!' && \ From 2d2e7483a6c931b76b3a39bee6a3e2d147e75296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:04:19 +0300 Subject: [PATCH 22/33] fix Make --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b4dff09..5c5c9a5 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ setup-ci: all: # add user to docker group - sudo groupadd docker + getent group docker || sudo groupadd docker # Add group if not exists sudo usermod -aG docker $USER newgrp docker cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env From aae6a932b2e06fd77a55d4b36bc2762216e98371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:04:46 +0300 Subject: [PATCH 23/33] fix Make --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5c5c9a5..c458637 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ setup-ci: all: # add user to docker group getent group docker || sudo groupadd docker # Add group if not exists - sudo usermod -aG docker $USER + sudo usermod -aG docker ${USER} newgrp docker cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env echo '' && \ From 3aa43af7e82374bea90fc0e4312621ac1f2e8f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:07:38 +0300 Subject: [PATCH 24/33] fix Make --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index c458637..45f7733 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ all: getent group docker || sudo groupadd docker # Add group if not exists sudo usermod -aG docker ${USER} newgrp docker + sudo systemctl restart docker cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env echo '' && \ echo 'Edit .env file. Write right DOMAIN_URL!' && \ From 58ef3777b8e24e68471d6b572aaddd0c2525c2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:10:43 +0300 Subject: [PATCH 25/33] fix Make --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 45f7733..3da1899 100644 --- a/Makefile +++ b/Makefile @@ -68,12 +68,14 @@ setup-ci: read ENTER sudo less /tmp/tmp_key -all: +set-not-sudo-docker: # add user to docker group getent group docker || sudo groupadd docker # Add group if not exists sudo usermod -aG docker ${USER} newgrp docker sudo systemctl restart docker + +all: cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env echo '' && \ echo 'Edit .env file. Write right DOMAIN_URL!' && \ From c1a7bc4ba2de27c9928fe6a197923f58df01dec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:30:48 +0300 Subject: [PATCH 26/33] =?UTF-8?q?=D0=98=D0=B7=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D1=81=D1=8F=20=D0=BE=D1=82=20sudo=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20make?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- .gitlab-ci.yml | 31 ------------------------------- Makefile | 12 +++++++++--- 3 files changed, 10 insertions(+), 35 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 20e5925..6caa58c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,4 +22,4 @@ jobs: key: ${{ secrets.SSH_DEPLOY_KEY }} script: | cd ${{ vars.PROJECT_PATH }} - sudo make update + make update diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ddace6a..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,31 +0,0 @@ -stages: - - build - -docker-build-branch: - stage: build - image: docker:20.10.17 - services: - - docker:20.10.17-dind - variables: - GIT_SUBMODULE_STRATEGY: recursive - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build -f $CI_PROJECT_DIR/Dockerfile -t $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH . - - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH - rules: - - if: $CI_COMMIT_BRANCH - -docker-build-tag: - stage: build - image: docker:20.10.17 - services: - - docker:20.10.17-dind - variables: - GIT_SUBMODULE_STRATEGY: recursive - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build -f $CI_PROJECT_DIR/Dockerfile -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG . - - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG - rules: - - if: $CI_COMMIT_TAG - diff --git a/Makefile b/Makefile index 3da1899..882b468 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ set-auto-renewing-certs: echo "" && \ echo "0 0 1 * * cd $$(pwd) && make run renew-certs >> ./certbot-renew.log" && \ echo "" && \ - echo "Copy that command and press [Enter]. Then add this string in end of opened file." && \ + echo "Copy that command and [press Enter]. Then add this string in end of opened file." && \ read ENTER crontab -e @@ -26,6 +26,10 @@ run: docker compose down && \ docker compose up -d nginx +down: + cd docker-deploy && \ + docker compose down + build: cd docker-deploy && \ docker compose build --no-cache --progress=plain nginx @@ -64,11 +68,11 @@ setup-ci: sudo cat /tmp/tmp_key.pub >> ~/.ssh/authorized_keys echo '' && \ echo 'Add this private rsa key secret deploy variables to SSH_DEPLOY_KEY on your github repo: ' && \ - echo '[press Enter...]' && \ + echo '[To see key press Enter...]' && \ read ENTER sudo less /tmp/tmp_key -set-not-sudo-docker: +set-docker-not-sudo: # add user to docker group getent group docker || sudo groupadd docker # Add group if not exists sudo usermod -aG docker ${USER} @@ -84,5 +88,7 @@ all: nano ./docker-deploy/.env make generate-certs make set-auto-renewing-certs + make down make setup-ci + sudo chmod ug+rwx -R /home/legend/vue-frontend-template/docker-deploy/certbot/ make update From 4fe894f4ebc95961de77832605a1224787e93f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:32:34 +0300 Subject: [PATCH 27/33] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=82=D0=B5=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d1023e..b526d7d 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,4 @@ make all ```` Всё. Наслаждаемся тем, что за нас всё сделали, сайт раздаётся, сертификаты обновляются. -Теперь `Github CI` сам будет проверять, собирается ли контейнер при **Pull Request**'ах, а при **Push**'ах в ветку `master` будет автоматически выполняться `make update` на сервере и обновлять деплой. +Теперь `Github CI` сам будет проверять, собирается ли контейнер при **Pull Request**'ах, а при **Push**'ах в ветку `master` будет автоматически выполняться `make update` на сервере и обновлять деплой! From 5f6bcf0096c162ac9e067e653bbabb92ee76b2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 01:49:05 +0300 Subject: [PATCH 28/33] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=BA=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 43 ++++++++++++++++++++++++++++++------------- README.md | 5 +++-- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 882b468..0dd7670 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,17 @@ #TAG ?= $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match) -include ./docker-deploy/.env +build: + cd docker-deploy && \ + docker compose build --no-cache --progress=plain nginx +run: + cd docker-deploy && \ + docker compose down && \ + docker compose up -d nginx +down: + cd docker-deploy && \ + docker compose down + generate-certs: cd docker-deploy && \ docker compose down && \ @@ -21,19 +32,6 @@ set-auto-renewing-certs: read ENTER crontab -e -run: - cd docker-deploy && \ - docker compose down && \ - docker compose up -d nginx - -down: - cd docker-deploy && \ - docker compose down - -build: - cd docker-deploy && \ - docker compose build --no-cache --progress=plain nginx - update: git fetch --all git reset --hard origin/master @@ -72,6 +70,23 @@ setup-ci: read ENTER sudo less /tmp/tmp_key +install-docker-if-not-exists: # fully copied from https://docs.docker.com/engine/install/ubuntu/ + if command -v docker &> /dev/null; then echo 'docker already installed' && exit 1; fi # exit if docker already exists + sudo apt-get update + sudo apt-get install ca-certificates curl + sudo install -m 0755 -d /etc/apt/keyrings + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc + sudo chmod a+r /etc/apt/keyrings/docker.asc + # Add the repository to Apt sources: + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get update + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + + make set-docker-not-sudo + set-docker-not-sudo: # add user to docker group getent group docker || sudo groupadd docker # Add group if not exists @@ -79,7 +94,9 @@ set-docker-not-sudo: newgrp docker sudo systemctl restart docker + all: + make install-docker-if-not-exists cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env echo '' && \ echo 'Edit .env file. Write right DOMAIN_URL!' && \ diff --git a/README.md b/README.md index b526d7d..fd32393 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ ![GithubCI](https://github.com/sergtyapkin/vue-frontend-template/actions/workflows/deploy.yml/badge.svg) -# Фронентд с авто-деплоем на _Nginx_ и получением сертификатов _Letsencript_ +# Веб-вервис в докере с авто-деплоем на _Nginx_ и получением сертификатов _Letsencript_ Всё делается через команды `make` -### 1. Клонируем: +### 1. Клонируем репозиторий: ```SHELL git clone git@github.com:SergTyapkin/vue-frontend-template.git + ``` ### 2. Настраиваем вообще всё. From 40281a23b03a50f72251a61ade13df9dc6b20988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 02:30:13 +0300 Subject: [PATCH 29/33] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BB=20make?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 5 ++++- Makefile | 15 +++++++++++---- README.md | 12 +++++++++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52e7ec1..860a4a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,10 +4,13 @@ on: pull_request: branches: [ "*" ] +env: + API_PORT: 0 + DOMAIN_URL: example.com + jobs: build: runs-on: ubuntu-latest - environment: build steps: - uses: actions/checkout@v3 diff --git a/Makefile b/Makefile index 0dd7670..b847671 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ setup-ci: sudo mkdir -p ~/.ssh sudo cat /tmp/tmp_key.pub >> ~/.ssh/authorized_keys echo '' && \ - echo 'Add this private rsa key secret deploy variables to SSH_DEPLOY_KEY on your github repo: ' && \ + echo 'Add this private rsa key secret deploy environment variables to SSH_DEPLOY_KEY on your github repo: ' && \ echo '[To see key press Enter...]' && \ read ENTER sudo less /tmp/tmp_key @@ -94,18 +94,25 @@ set-docker-not-sudo: newgrp docker sudo systemctl restart docker - -all: - make install-docker-if-not-exists +setup-env-file: cp --no-clobber ./docker-deploy/.env.example ./docker-deploy/.env echo '' && \ echo 'Edit .env file. Write right DOMAIN_URL!' && \ echo '[press Enter...]' && \ read ENTER nano ./docker-deploy/.env + +all: + make install-docker-if-not-exists + make setup-env-file make generate-certs make set-auto-renewing-certs make down make setup-ci sudo chmod ug+rwx -R /home/legend/vue-frontend-template/docker-deploy/certbot/ make update + echo 'Now read README.md and setup another deploy environments variables.' && \ + echo 'It seems like values must be:' && \ + echo 'SERVER_USERNAME=$$(whoami) # ! MUST BE SECRET VARIABLE !' && \ + echo 'DEPLOY_HOST=$$(cat ./docker-deploy/.env | grep DOMAIN_URL | sed "s/.*=//") # NOT SECURE' && \ + echo 'PROJECT_PATH=$$(pwd) # NOT SECURE' diff --git a/README.md b/README.md index fd32393..7c6db3d 100644 --- a/README.md +++ b/README.md @@ -17,5 +17,15 @@ cd vue-frontend-template make all ```` -Всё. Наслаждаемся тем, что за нас всё сделали, сайт раздаётся, сертификаты обновляются. +Всё. Наслаждаемся тем, что за нас всё сделали, установили докер, сайт раздаётся, сертификаты обновляются. Теперь `Github CI` сам будет проверять, собирается ли контейнер при **Pull Request**'ах, а при **Push**'ах в ветку `master` будет автоматически выполняться `make update` на сервере и обновлять деплой! + +## Полный список действий скриптов +1. Устанавливает `docker`, если его ещё нет +2. Добавляет текущего пользователя в группу `Docker`, чтобы запускать его без `sudo` +3. Предлагает настроить `.env` файл +4. Получает сертификаты Letsencrypt +5. Устанавливает и настраивает `cron` на ежемесячное обновление сертификатов +6. Создаёт пару SSH ключей, публичный добавляет в `~/.ssh/authorized_keys`, приватный выводит в консоль, его нужно добавить как секретную переменную среды `SSH_DEPLOY_KEY` в настройках Github. +7. Собирает приложение из последнего коммита в ветку `master`, запускает финальный docker-контейнер с ним + From 8c1dc50253d4e57bed3cae84e56a03872f7e9463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 02:32:36 +0300 Subject: [PATCH 30/33] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BB=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7c6db3d..7b3e997 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,8 @@ make all 6. Создаёт пару SSH ключей, публичный добавляет в `~/.ssh/authorized_keys`, приватный выводит в консоль, его нужно добавить как секретную переменную среды `SSH_DEPLOY_KEY` в настройках Github. 7. Собирает приложение из последнего коммита в ветку `master`, запускает финальный docker-контейнер с ним +### 3. Установка переменных +1. Заходим в `Settings` -> `Environments`, создаём новое окружение под названием `deploy` (важно). +![](/README_res/1.png) +2. Создаём внутри окружения все необходимые переменные. Их выведет `make all` после завершения выполнения, или можно прописать самому. +![](/README_res/2.png) From 3e0e10b0e64a2bc34820e550e3e2d12cb11cb36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 02:41:43 +0300 Subject: [PATCH 31/33] Fix docker --- Makefile | 29 +++++++++++++++-------------- README.md | 1 - 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index b847671..c1d0634 100644 --- a/Makefile +++ b/Makefile @@ -71,21 +71,22 @@ setup-ci: sudo less /tmp/tmp_key install-docker-if-not-exists: # fully copied from https://docs.docker.com/engine/install/ubuntu/ - if command -v docker &> /dev/null; then echo 'docker already installed' && exit 1; fi # exit if docker already exists - sudo apt-get update - sudo apt-get install ca-certificates curl - sudo install -m 0755 -d /etc/apt/keyrings - sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc - sudo chmod a+r /etc/apt/keyrings/docker.asc - # Add the repository to Apt sources: - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ - $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ - sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - sudo apt-get update - sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + if ! command -v docker &> /dev/null; then + sudo apt-get update; + sudo apt-get install ca-certificates curl; + sudo install -m 0755 -d /etc/apt/keyrings; + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc; + sudo chmod a+r /etc/apt/keyrings/docker.asc; + # Add the repository to Apt sources: + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$${VERSION_CODENAME}") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null; + sudo apt-get update; + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin; - make set-docker-not-sudo + make set-docker-not-sudo; + fi set-docker-not-sudo: # add user to docker group diff --git a/README.md b/README.md index 7b3e997..7dbbd59 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ ### 1. Клонируем репозиторий: ```SHELL git clone git@github.com:SergTyapkin/vue-frontend-template.git - ``` ### 2. Настраиваем вообще всё. From a41ad7789341b66b8cdf59470d4a404fdaba46db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 02:57:35 +0300 Subject: [PATCH 32/33] Fix docker --- Makefile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index c1d0634..8d839cf 100644 --- a/Makefile +++ b/Makefile @@ -71,21 +71,22 @@ setup-ci: sudo less /tmp/tmp_key install-docker-if-not-exists: # fully copied from https://docs.docker.com/engine/install/ubuntu/ - if ! command -v docker &> /dev/null; then - sudo apt-get update; - sudo apt-get install ca-certificates curl; - sudo install -m 0755 -d /etc/apt/keyrings; - sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc; - sudo chmod a+r /etc/apt/keyrings/docker.asc; - # Add the repository to Apt sources: + if ! command -v docker; then \ + sudo apt-get update; \ + sudo apt-get install -y --no-install-recommended ca-certificates curl; \ + sudo install -m 0755 -d /etc/apt/keyrings; \ + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc; \ + sudo chmod a+r /etc/apt/keyrings/docker.asc; \ + # Add the repository to Apt sources: \ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$${VERSION_CODENAME}") stable" | \ - sudo tee /etc/apt/sources.list.d/docker.list > /dev/null; - sudo apt-get update; - sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin; - - make set-docker-not-sudo; + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null; \ + sudo apt-get update; \ + sudo apt-get install -y --no-install-recommended docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin; \ + make set-docker-not-sudo; \ + else \ + echo "Docker already installed!"; \ fi set-docker-not-sudo: From 90f9f3e673c83e03c6830e4da02bfe7beb68345e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A2=D1=8F=D0=BF?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 30 Jan 2024 03:08:14 +0300 Subject: [PATCH 33/33] Finally all --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8d839cf..6185327 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,6 @@ all: make update echo 'Now read README.md and setup another deploy environments variables.' && \ echo 'It seems like values must be:' && \ - echo 'SERVER_USERNAME=$$(whoami) # ! MUST BE SECRET VARIABLE !' && \ - echo 'DEPLOY_HOST=$$(cat ./docker-deploy/.env | grep DOMAIN_URL | sed "s/.*=//") # NOT SECURE' && \ - echo 'PROJECT_PATH=$$(pwd) # NOT SECURE' + echo 'SERVER_USERNAME=$$(whoami) \# ! MUST BE SECRET VARIABLE !' && \ + echo 'DEPLOY_HOST=$$(cat ./docker-deploy/.env | grep DOMAIN_URL | sed "s/.*=//") \# NOT SECURE' && \ + echo 'PROJECT_PATH=$$(pwd) \# NOT SECURE'