Skip to content

Commit

Permalink
chore: improve cd and ci pipeline automation
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Nov 5, 2023
1 parent 3f4e5e9 commit 09bfa39
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 93 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/django-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: django-cd

on:
workflow_call:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build against'
required: true
default: 'latest'
push:
tags: "*"

jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set Tag
id: set-tag
run: |
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
echo "::set-output name=tag::${{ github.event.inputs.tag }}"
else
echo "::set-output name=tag::${{ github.event.ref_name }}"
fi
- name: Build Docker Image
run: docker build . --tag ghcr.io/${{ github.repository }}:${{ steps.set-tag.outputs.tag }}
working-directory: .

- name: Push Docker Image to GitHub Packages
run: docker push ghcr.io/${{ github.repository }}:${{ steps.set-tag.outputs.tag }}

3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

8 changes: 5 additions & 3 deletions .idea/anitrend.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions .idea/runConfigurations/server.xml

This file was deleted.

23 changes: 0 additions & 23 deletions .idea/runConfigurations/test.xml

This file was deleted.

23 changes: 0 additions & 23 deletions .idea/runConfigurations/worker.xml

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,5 @@ COPY . /usr/src/app/

RUN mkdir tmp

# Stage 2: Django Server stage
FROM builder AS django-server

# Expose the port your Django app will run on
EXPOSE 8800

# Start Django server
CMD /usr/src/app/start-server.sh

# Stage 3: Django Q Cluster stage
FROM builder AS django-q-cluster

# Start Django Q scheduler and worker
CMD /usr/src/app/start-q.sh
2 changes: 1 addition & 1 deletion app/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .common import *

ALLOWED_HOSTS = ["graphql.anitrend.co"]
ALLOWED_HOSTS = ["graphql.anitrend.co", "0.0.0.0"]

DATABASES = {
"default": {
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3'
services:
django-server:
image: anitrend:0.1
ports:
- 8800:8800
networks:
- traefik-network
environment:
DJANGO_SETTINGS_MODULE: "app.settings.development"
labels:
- "traefik.enable=true"
- "traefik.http.routers.django-server.rule=Host(`anitrend.localhost`)"
- "traefik.http.routers.django-server.entrypoints=web"
- "traefik.http.routers.django-server.middlewares=django-server-stripprefix"
- "traefik.http.services.django-server.loadbalancer.server.port=8800"
depends_on:
- db

django-q-cluster:
image: anitrend:0.1
networks:
- traefik-network
environment:
DJANGO_SETTINGS_MODULE: "app.settings.development"


networks:
default:
name: traefik
external: true
2 changes: 1 addition & 1 deletion docker-compose.yml → docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
django-server:
build:
context: .
dockerfile: Dockerfile
dockerfile: Dockerfile.prod
ports:
- 8800:8800
networks:
Expand Down

0 comments on commit 09bfa39

Please sign in to comment.