Изменил(а) на '.drone.yml'

main
vladimirkutkovoy 1 year ago
parent c44e99d01d
commit dcb4ff1eb0
  1. 51
      .drone.yml

@ -1,30 +1,36 @@
kind: pipeline kind: pipeline
name: default type: docker
name: build-and-deploy
steps: steps:
- name: build # 1. Install dependencies and build the project
image: node - name: install_and_build
image: node:18 # Используем подходящий образ Node.js
commands: commands:
- npm install - npm install
- npm run build - npm run build
volumes:
- name: build
path: /drone/src
- name: deploy # 2. Deploy Docker container with Nginx and copy build files
image: alpine - name: deploy
environment: image: docker:24.0.2 # Используем образ Docker для управления контейнерами
HOST: blog.example.ru volumes:
USER: droneci - name: build
WEB_DIR: /var/www/blog.example.ru/ path: /drone/src
SSH_KEY: - name: docker_socket
from_secret: ssh_key path: /var/run/docker.sock
commands: commands:
- apk add --no-cache rsync openssh # 2.1 Останавливаем и удаляем старый контейнер Nginx (если есть)
- mkdir ~/.ssh/ - docker stop my-nginx-site || true
- chmod 0700 ~/.ssh - docker rm my-nginx-site || true
- echo -e "$SSH_KEY" > ~/.ssh/id_rsa
- chmod 0600 ~/.ssh/id_rsa # 2.2 Запускаем новый контейнер Nginx
- echo StrictHostKeyChecking no >> ~/.ssh/config - docker run -d --name my-nginx-site -p 80:80 nginx:stable-alpine
- chmod 0600 ~/.ssh/config
- rsync -rvzc --chmod=g=rwX --delete public/ $USER@$HOST:$WEB_DIR # 2.3 Копируем сгенерированные файлы в контейнер Nginx
- docker cp /drone/src/build/. my-nginx-site:/usr/share/nginx/html/
- name: telegram notification - name: telegram notification
image: appleboy/drone-telegram image: appleboy/drone-telegram
@ -54,3 +60,10 @@ steps:
``` ```
🌐 {{ build.link }} 🌐 {{ build.link }}
{{/success}} {{/success}}
volumes:
- name: build
temp: {}
- name: docker_socket
host:
path: /var/run/docker.sock
Loading…
Cancel
Save