diff --git a/.drone.yml b/.drone.yml index 3977763..8cb5831 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,5 @@ # drone 会自动先拉取代码 # 再按顺序执行 pipeline 配置中定义的任务 ---- kind: pipeline type: docker @@ -32,9 +31,10 @@ steps: script: - cd /var/www/todo - git fetch + - git checkout ${DRONE_BRANCH} - git reset --hard ${DRONE_COMMIT} - docker-compose down - - docker-compose up -d --build + - docker-compose up -d --build --force-recreate - docker image prune -f when: event: @@ -42,5 +42,96 @@ steps: - push - custom +--- + +kind: pipeline +type: docker +name: develop + +platform: + os: linux + arch: amd64 + +trigger: + branch: + include: + - develop + +clone: + disable: true + +steps: +- name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: host + username: root + key: + from_secret: ssh_key + port: 22 + script_stop: true + script: + - cd /var/www/todo + - git fetch + - git checkout ${DRONE_BRANCH} + - git reset --hard ${DRONE_COMMIT} + - docker-compose down + - docker-compose up -d --build --force-recreate + - docker image prune -f + when: + event: + include: + - pull_request + action: + include: + - opened + - reopened + - synchronized +--- + +kind: pipeline +type: docker +name: main-pull-request-staging + +platform: + os: linux + arch: amd64 + +trigger: + branch: + include: + - main + +clone: + disable: true + +steps: +- name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: host + username: root + key: + from_secret: ssh_key + port: 22 + script_stop: true + script: + - cd /var/www/todo + - git fetch + - git checkout ${DRONE_BRANCH} + - git reset --hard ${DRONE_COMMIT} + - docker-compose down + - docker-compose up -d --build --force-recreate + - docker image prune -f + when: + event: + - pull_request + action: + include: + - opened + - reopened + - synchronized diff --git a/Dockerfile b/Dockerfile index d567e17..f2187d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.11 -WORKDIR /app +#WORKDIR /app -CMD ["python3", "test.py"] \ No newline at end of file +# CMD ["python3", "test.py"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 094c8b2..6262d81 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,4 +12,12 @@ services: environment: TZ: "Asia/Shanghai" tty: true + working_dir: /app + command: ["python3", "test.py"] + networks: + - todo-service + +networks: + todo-service: + driver: bridge