mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-16 19:59:24 +08:00
Update deployment
This commit is contained in:
parent
2770ac035d
commit
aa9d67fdba
5 changed files with 59 additions and 40 deletions
|
@ -1,33 +0,0 @@
|
|||
# .woodpecker.yml
|
||||
steps:
|
||||
- name: build
|
||||
image: docker
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
commands:
|
||||
- docker build --platform linux/arm64 --no-cache -t "$IMAGE" .
|
||||
- echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" --password-stdin -u "$REGISTRY_USERNAME"
|
||||
- docker push "$IMAGE"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
secrets: [REGISTRY, REGISTRY_USERNAME, REGISTRY_PASSWORD, IMAGE]
|
||||
- name: deploy
|
||||
image: docker
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
commands:
|
||||
- mkdir -p /root/.ssh/
|
||||
- echo "$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 "$REMOTE_HOST" "
|
||||
cd $PROJECT_DIRECTORY;
|
||||
docker-compose -f docker-compose.demo.yml down;
|
||||
docker image rm "$IMAGE" || true;
|
||||
docker volume rm "$VOLUME" || true;
|
||||
docker pull "$IMAGE";
|
||||
docker compose -f docker-compose.demo.yml up -d;
|
||||
docker image prune -af;"
|
||||
secrets: [SSH_KEY, REMOTE_HOST, PROJECT_DIRECTORY, IMAGE, VOLUME]
|
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
|
|
@ -1,6 +1,6 @@
|
|||
## DRF-Template
|
||||
|
||||
![Build Status](https://woodpecker.06222001.xyz/api/badges/1/status.svg)
|
||||
![Build Status](https://woodpecker.06222001.xyz/api/badges/2/status.svg)
|
||||
![Demo Page Status](https://stats.06222001.xyz/api/badge/119/status)
|
||||
|
||||
This is a Django template that I personally use for my projects. This covers the following
|
||||
|
@ -27,7 +27,7 @@ When using `docker-compose.dev.yml`, the entire project directory is mounted ont
|
|||
|
||||
### Deployment
|
||||
|
||||
A sample `docker-compose.demo.yml` is provided which I use in hosting the demo. DEBUG should be set to False when deploying as to not expose the URLs fro Celery Flower and the Django Silk Profiler. The local Inbucket container is not present so make sure to specify an external SMTP server to process emails properly.
|
||||
A sample `docker-compose.yml` is provided which I use in hosting the demo. DEBUG should be set to False when deploying as to not expose the URLs fro Celery Flower and the Django Silk Profiler. The local Inbucket container is not present so make sure to specify an external SMTP server to process emails properly.
|
||||
|
||||
### URLs
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ services:
|
|||
# Django Backend
|
||||
django:
|
||||
env_file: .env
|
||||
image: keannu125/drf-template:latest
|
||||
image: git.06222001.xyz/keannu125/drf_template:latest
|
||||
ports:
|
||||
- "${BACKEND_PORT}:8000"
|
||||
environment:
|
||||
|
@ -17,7 +17,7 @@ services:
|
|||
env_file: .env
|
||||
environment:
|
||||
- RUN_TYPE=worker
|
||||
image: keannu125/drf-template:latest
|
||||
image: git.06222001.xyz/keannu125/drf_template:latest
|
||||
depends_on:
|
||||
- django
|
||||
- postgres
|
||||
|
@ -31,7 +31,7 @@ services:
|
|||
env_file: .env
|
||||
environment:
|
||||
- RUN_TYPE=beat
|
||||
image: keannu125/drf-template:latest
|
||||
image: git.06222001.xyz/keannu125/drf_template:latest
|
||||
depends_on:
|
||||
- celery
|
||||
- django
|
||||
|
@ -48,7 +48,7 @@ services:
|
|||
- POSTGRES_USER=${DB_USERNAME}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
- db_data:/var/lib/postgresql/data
|
||||
command: postgres -c max_connections=200
|
||||
|
||||
# DB Bouncer
|
||||
|
@ -77,4 +77,4 @@ services:
|
|||
command: listen --forward-to django:8000/api/v1/stripe/webhook/
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db_data:
|
Loading…
Reference in a new issue