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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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