Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
STACK_NAME: aws-hacks-2024
STACK_NAME: aws-hacks

jobs:
build:
Expand All @@ -25,22 +25,22 @@ 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:
registry: ${{ env.REGISTRY }}
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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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"
32 changes: 18 additions & 14 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 4 additions & 4 deletions deployment/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
restart_policy:
condition: on-failure
networks:
- aws-hacks-2024
- aws-hacks
redis:
image: redis:6-alpine
ports:
Expand All @@ -30,8 +30,8 @@ services:
restart_policy:
condition: on-failure
networks:
- aws-hacks-2024
- aws-hacks

networks:
aws-hacks-2024:
driver: overlay
aws-hacks:
driver: overlay
12 changes: 5 additions & 7 deletions development/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
24 changes: 9 additions & 15 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Loading