mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2025-04-28 02:31:15 +08:00
Update deployment
This commit is contained in:
parent
2770ac035d
commit
aa9d67fdba
5 changed files with 59 additions and 40 deletions
22
.woodpecker/.build.yml
Normal file
22
.woodpecker/.build.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
labels:
|
||||
platform: linux/arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: docker
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
commands:
|
||||
- docker build -t "$REGISTRY_IMAGE_TAG" .
|
||||
- echo "$FORGEJO_REGISTRY_PASSWORD" | docker login "$FORGEJO_REGISTRY_URL" --password-stdin -u "$FORGEJO_REGISTRY_USERNAME"
|
||||
- docker push "$REGISTRY_IMAGE_TAG"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
secrets:
|
||||
[
|
||||
FORGEJO_REGISTRY_URL,
|
||||
FORGEJO_REGISTRY_USERNAME,
|
||||
FORGEJO_REGISTRY_PASSWORD,
|
||||
REGISTRY_IMAGE_TAG,
|
||||
]
|
30
.woodpecker/.deploy.yml
Normal file
30
.woodpecker/.deploy.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
steps:
|
||||
- name: deploy
|
||||
image: docker
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
commands:
|
||||
- mkdir -p /root/.ssh/
|
||||
- echo "$WOODPECKER_SSH_KEY" | tr -d '\r' > /root/.ssh/id_rsa
|
||||
- chmod 600 /root/.ssh/id_rsa
|
||||
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
|
||||
- ssh "$SSH_HOST" '
|
||||
cd "$PROJECT_DIRECTORY";
|
||||
docker-compose down;
|
||||
docker image rm "$REGISTRY_IMAGE_TAG" || true;
|
||||
docker volume rm "$DOCKER_DB_VOLUME" || true;
|
||||
docker pull "$REGISTRY_IMAGE_TAG";
|
||||
docker-compose up -d;
|
||||
docker image prune -af;'
|
||||
secrets:
|
||||
[
|
||||
SSH_HOST,
|
||||
PROJECT_DIRECTORY,
|
||||
WOODPECKER_SSH_KEY,
|
||||
REGISTRY_IMAGE_TAG,
|
||||
DOCKER_DB_VOLUME,
|
||||
]
|
||||
|
||||
depends_on:
|
||||
- build
|
Loading…
Add table
Add a link
Reference in a new issue