From 5be702c4f0719f23d67d650444f8487455752a05 Mon Sep 17 00:00:00 2001 From: Sergey Tyapkin Date: Tue, 30 Jan 2024 01:31:10 +0300 Subject: [PATCH] Dev (#6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * Write README * Write README * fix mkdir * fix path * fix deploy.yml * fix deploy.yml * fix deploy.yml * fix deploy.yml * fix Make * fix Make * fix Make * fix Make * fix Make * fix Make * fix Make * Избавился от sudo для make --- .github/workflows/deploy.yml | 2 +- .gitlab-ci.yml | 31 ------------------------------- Makefile | 25 +++++++++++++++++++++---- README.md | 4 ++-- docker-deploy/.env.example | 3 +-- 5 files changed, 25 insertions(+), 40 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 35be533..882b468 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ #TAG ?= $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match) -include docker-deploy/.env +-include ./docker-deploy/.env generate-certs: cd docker-deploy && \ @@ -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,14 +68,27 @@ 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-docker-not-sudo: + # 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!' && \ + echo '[press Enter...]' && \ + read ENTER nano ./docker-deploy/.env - make generate-scripts + 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 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 ```` 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