From 2034c0b72fd11e55678a4a41ac97a4a6ce34624d Mon Sep 17 00:00:00 2001 From: Aaron Gu Date: Sat, 28 Feb 2026 22:18:20 -0500 Subject: [PATCH] Update deployment files --- .github/workflows/deploy.yml | 24 +++++++++++----------- deployment/Dockerfile | 32 +++++++++++++++++------------- deployment/docker-compose.prod.yml | 8 ++++---- development/docker-compose.yml | 12 +++++------ environment.yml | 24 +++++++++------------- 5 files changed, 48 insertions(+), 52 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b91f53b..f33eb59 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,7 +8,7 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - STACK_NAME: aws-hacks-2024 + STACK_NAME: aws-hacks jobs: build: @@ -25,7 +25,7 @@ jobs: echo "GITHUB_SHA_SHORT=${GITHUB_SHA_SHORT}" >> $GITHUB_ENV echo "::set-output name=GITHUB_SHA_SHORT::${GITHUB_SHA_SHORT}" - name: Build image - run: docker-compose -f deployment/docker-compose.ci.yml build + run: docker compose -f deployment/docker-compose.ci.yml build - name: Docker login uses: docker/login-action@v1.10.0 with: @@ -33,14 +33,14 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Push image - run: docker-compose -f deployment/docker-compose.ci.yml push + run: docker compose -f deployment/docker-compose.ci.yml push deploy: runs-on: ubuntu-latest needs: [ build ] environment: name: production - url: https://hackstudentlife.ca + url: https://hackthestudentlife.ca defaults: run: working-directory: deployment @@ -49,10 +49,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.10.19 - name: Install python dependencies working-directory: hackathon_site run: | @@ -71,7 +71,7 @@ jobs: - name: Collect static working-directory: hackathon_site env: - SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} + SECRET_KEY: ${{ secrets.CI_SECRET_KEY }} run: python manage.py collectstatic - name: Build frontend working-directory: hackathon_site/dashboard/frontend @@ -81,7 +81,7 @@ jobs: - name: Set environment variables in .env run: | echo 'DEBUG=0' >> .env - echo 'SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}' >> .env + echo 'SECRET_KEY=${{ secrets.CI_SECRET_KEY }}' >> .env echo 'DB_NAME=${{ secrets.DB_NAME }}' >> .env echo 'DB_USER=${{ secrets.DB_USER }}' >> .env echo 'DB_PASSWORD=${{ secrets.DB_PASSWORD }}' >> .env @@ -96,7 +96,7 @@ jobs: echo 'RECAPTCHA_PUBLIC_KEY=${{ secrets.RECAPTCHA_PUBLIC_KEY }}' >> .env echo 'RECAPTCHA_PRIVATE_KEY=${{ secrets.RECAPTCHA_PRIVATE_KEY }}' >> .env - name: Transfer static files to the Swarm manager - uses: appleboy/scp-action@v0.1.1 + uses: appleboy/scp-action@v0.1.7 with: host: ${{ secrets.SWARM_MANAGER_IP }} username: ${{ secrets.SSH_USER }} @@ -113,7 +113,7 @@ jobs: echo "${{ secrets.SSH_PRIVATE_KEY }}" >> ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - name: Transfer frontend files to server - uses: appleboy/scp-action@v0.1.1 + uses: appleboy/scp-action@v0.1.7 with: host: ${{ secrets.SWARM_MANAGER_IP }} username: ${{ secrets.SSH_USER }} @@ -134,11 +134,11 @@ jobs: echo "Waiting for deployment..." sleep 30 chmod 777 docker-stack-wait.sh - ./docker-stack-wait.sh -t 300 ${{ env.STACK_NAME }} + ./docker-stack-wait.sh -t 600 ${{ env.STACK_NAME }} echo "Running migrations..." # TODO: It would be better to use docker-compose against the django service, # but there is currently a bug in docker-compose preventing running services # over an SSH host. IMAGE=${REGISTRY}/${IMAGE_NAME}/django:${GITHUB_SHA_SHORT} docker run --rm --env-file .env ${IMAGE} python manage.py migrate - echo "Deployment complete" + echo "Deployment complete" \ No newline at end of file diff --git a/deployment/Dockerfile b/deployment/Dockerfile index def1217..342a3dd 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -1,27 +1,31 @@ -FROM python:3.8-buster +FROM python:3.9-slim-bookworm -# Set working directory WORKDIR /usr/src/hackathon_site -# Set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 -# Set time zone +# Set timezone (install tzdata only if needed) +# If /usr/share/zoneinfo isn't present, uncomment the tzdata block. +# ARG DEBIAN_FRONTEND=noninteractive +# RUN apt-get update && apt-get install -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/* RUN cp /usr/share/zoneinfo/Canada/Eastern /etc/localtime \ && echo "America/Toronto" > /etc/timezone -# Install dependencies -RUN apt-get update && apt-get install -y postgresql-client +# System deps: psql client (brings libpq), then clean +RUN apt-get update \ + && apt-get install -y --no-install-recommends postgresql-client \ + && rm -rf /var/lib/apt/lists/* +# Python deps RUN pip install --upgrade pip -COPY hackathon_site/requirements.txt /usr/src/hackathon_site/requirements.txt -RUN pip install -r /usr/src/hackathon_site/requirements.txt +COPY hackathon_site/requirements.txt . +RUN pip install -r requirements.txt -# Copy app -COPY hackathon_site/ /usr/src/hackathon_site/ +# App +COPY hackathon_site/ . -# Copy entrypoint +# Entrypoint COPY deployment/entrypoint.sh /usr/src/entrypoint.sh RUN chmod +x /usr/src/entrypoint.sh -ENTRYPOINT ["/usr/src/entrypoint.sh"] +ENTRYPOINT ["/usr/src/entrypoint.sh"] \ No newline at end of file diff --git a/deployment/docker-compose.prod.yml b/deployment/docker-compose.prod.yml index e33b97c..438045c 100644 --- a/deployment/docker-compose.prod.yml +++ b/deployment/docker-compose.prod.yml @@ -17,7 +17,7 @@ services: restart_policy: condition: on-failure networks: - - aws-hacks-2024 + - aws-hacks redis: image: redis:6-alpine ports: @@ -30,8 +30,8 @@ services: restart_policy: condition: on-failure networks: - - aws-hacks-2024 + - aws-hacks networks: - aws-hacks-2024: - driver: overlay \ No newline at end of file + aws-hacks: + driver: overlay diff --git a/development/docker-compose.yml b/development/docker-compose.yml index 7425cdf..f782131 100644 --- a/development/docker-compose.yml +++ b/development/docker-compose.yml @@ -1,23 +1,21 @@ -version: '3' +version: "3" services: postgres: image: postgres:12.2 - container_name: aws-hacks_postgres + container_name: hackathon-template_postgres ports: - 5432:5432 environment: - POSTGRES_DB=hackathon_site - - POSTGRES_USER=postgres - POSTGRES_HOST_AUTH_METHOD=trust volumes: - - aws-postgres-data:/var/lib/postgresql/data - + - hackathon-template_postgres-data:/var/lib/postgresql/data redis: image: redis:6-alpine - container_name: aws-hacks_redis + container_name: hackathon-template_redis ports: - 6379:6379 volumes: - aws-postgres-data: + hackathon-template_postgres-data: diff --git a/environment.yml b/environment.yml index 75227b7..dbea2d0 100644 --- a/environment.yml +++ b/environment.yml @@ -5,7 +5,7 @@ channels: dependencies: # Core language and C‑library deps - - python=3.9 + - python>=3.10.19,<3.11 - libpq - psycopg2 # pre‑built, with libpq - pip # so we can install the rest via pip @@ -15,13 +15,11 @@ dependencies: - appdirs==1.4.3 - asgiref==3.8.1 - attrs==19.3.0 - - black==19.10b0 + - black==24.1.0 - certifi==2020.4.5.1 - chardet==3.0.4 - - click==7.1.2 + - click>=8.0.0 - confusable-homoglyphs==3.3.1 - - coreapi==2.3.3 - - coreschema==0.0.4 - defusedxml==0.7.1 - diff-match-patch==20241021 - dj-rest-auth==1.0.6 @@ -34,9 +32,8 @@ dependencies: - django-recaptcha==2.0.6 - django-redis==4.12.1 - django-registration==3.1.2 - - djangorestframework==3.11.2 - - dotenv==0.9.9 - - drf-yasg==1.17.1 + - djangorestframework==3.14.0 + - drf-spectacular[sidecar]==0.27.2 - et_xmlfile==2.0.0 - gunicorn==20.0.4 - idna==2.9 @@ -46,10 +43,9 @@ dependencies: - MarkupSafe==1.1.1 - odfpy==1.4.1 - openpyxl==3.1.5 - - packaging==20.4 - - pathspec==0.8.0 + - packaging>=22.0 + - pathspec==0.9.0 - Pillow==9.0.1 - - psycopg2-binary==2.9.10 # optional: you can remove this since conda’s psycopg2 is already installed - pyparsing==2.4.7 - python-dateutil==2.8.2 - python-dotenv==1.1.0 @@ -59,15 +55,13 @@ dependencies: - redis==3.5.3 - regex==2021.4.4 - requests==2.25.1 - - ruamel.yaml==0.16.10 - - ruamel.yaml.clib==0.2.12 + - ruamel.yaml==0.17.21 - six==1.15.0 - sqlparse==0.3.1 - tablib==3.7.0 - toml==0.10.0 - - typed_ast==1.4.1 - typing_extensions==4.12.2 - uritemplate==3.0.1 - urllib3==1.26.5 - xlrd==2.0.1 - - xlwt==1.3.0 + - xlwt==1.3.0 \ No newline at end of file