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

main
vladimirkutkovoy 1 year ago
parent c44e99d01d
commit dcb4ff1eb0
  1. 63
      .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
commands: image: node:18 # Используем подходящий образ Node.js
- npm install commands:
- npm run build - npm install
- npm run build
- name: deploy volumes:
image: alpine - name: build
environment: path: /drone/src
HOST: blog.example.ru
USER: droneci # 2. Deploy Docker container with Nginx and copy build files
WEB_DIR: /var/www/blog.example.ru/ - name: deploy
SSH_KEY: image: docker:24.0.2 # Используем образ Docker для управления контейнерами
from_secret: ssh_key volumes:
commands: - name: build
- apk add --no-cache rsync openssh path: /drone/src
- mkdir ~/.ssh/ - name: docker_socket
- chmod 0700 ~/.ssh path: /var/run/docker.sock
- echo -e "$SSH_KEY" > ~/.ssh/id_rsa commands:
- chmod 0600 ~/.ssh/id_rsa # 2.1 Останавливаем и удаляем старый контейнер Nginx (если есть)
- echo StrictHostKeyChecking no >> ~/.ssh/config - docker stop my-nginx-site || true
- chmod 0600 ~/.ssh/config - docker rm my-nginx-site || true
- rsync -rvzc --chmod=g=rwX --delete public/ $USER@$HOST:$WEB_DIR
# 2.2 Запускаем новый контейнер Nginx
- docker run -d --name my-nginx-site -p 80:80 nginx:stable-alpine
# 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
@ -53,4 +59,11 @@ steps:
{{commit.message}} {{commit.message}}
``` ```
🌐 {{ build.link }} 🌐 {{ build.link }}
{{/success}} {{/success}}
volumes:
- name: build
temp: {}
- name: docker_socket
host:
path: /var/run/docker.sock
Loading…
Cancel
Save