diff --git a/.github/workflows/django-cd.yml b/.github/workflows/django-cd.yml new file mode 100644 index 0000000..cf4e6d8 --- /dev/null +++ b/.github/workflows/django-cd.yml @@ -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 "tag=${{ github.event.inputs.tag }}" + else + echo "tag=${{ github.event.ref_name }}" + fi + + - name: Build Docker Image + run: docker build . --tag ghcr.io/${{ github.repository }}/anitrend:${{ steps.set-tag.outputs.tag }} + working-directory: . + + - name: Push Docker Image to GitHub Packages + run: docker push ghcr.io/${{ github.repository }}/anitrend:${{ steps.set-tag.outputs.tag }} + diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/anitrend.iml b/.idea/anitrend.iml index 397d297..dfa8244 100644 --- a/.idea/anitrend.iml +++ b/.idea/anitrend.iml @@ -1,10 +1,12 @@ - - - + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0e8efe4..bc4af67 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index d3cf6ed..5d35233 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/runConfigurations/server.xml b/.idea/runConfigurations/server.xml deleted file mode 100644 index 42057d4..0000000 --- a/.idea/runConfigurations/server.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/test.xml b/.idea/runConfigurations/test.xml deleted file mode 100644 index 55098d9..0000000 --- a/.idea/runConfigurations/test.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/worker.xml b/.idea/runConfigurations/worker.xml deleted file mode 100644 index 88d2a8f..0000000 --- a/.idea/runConfigurations/worker.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c2692d0..443d929 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/app/settings/production.py b/app/settings/production.py index d121221..1bebce3 100644 --- a/app/settings/production.py +++ b/app/settings/production.py @@ -12,7 +12,7 @@ from .common import * -ALLOWED_HOSTS = ["graphql.anitrend.co"] +ALLOWED_HOSTS = ["graphql.anitrend.co", "0.0.0.0"] DATABASES = { "default": { diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..7618cea --- /dev/null +++ b/docker-compose.dev.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.prod.yml similarity index 96% rename from docker-compose.yml rename to docker-compose.prod.yml index a241e05..11b71dd 100644 --- a/docker-compose.yml +++ b/docker-compose.prod.yml @@ -3,7 +3,7 @@ services: django-server: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.prod ports: - 8800:8800 networks: