diff --git a/.woodpecker.yml b/.woodpecker.yml deleted file mode 100644 index 8836806..0000000 --- a/.woodpecker.yml +++ /dev/null @@ -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] diff --git a/.woodpecker/.build.yml b/.woodpecker/.build.yml new file mode 100644 index 0000000..4d5f455 --- /dev/null +++ b/.woodpecker/.build.yml @@ -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, + ] diff --git a/.woodpecker/.deploy.yml b/.woodpecker/.deploy.yml new file mode 100644 index 0000000..2654df5 --- /dev/null +++ b/.woodpecker/.deploy.yml @@ -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 diff --git a/README.md b/README.md index 093c61b..9cff4a1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker-compose.demo.yml b/docker-compose.yml similarity index 87% rename from docker-compose.demo.yml rename to docker-compose.yml index 1bd5fc7..e935f1c 100644 --- a/docker-compose.demo.yml +++ b/docker-compose.yml @@ -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: