-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from TaskMasterErnest/main
Local Testing and Development Improvements, and Addressing Test Failures
- Loading branch information
Showing
11 changed files
with
184 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.log | ||
*.pot | ||
*.pyc | ||
.env* | ||
# __pycache__ | ||
db.sqlite3 | ||
venv | ||
virtualenv | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Django CI - Test Phase | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DJANGO_SUPERUSER_EMAIL: hello@smartlearn.com | ||
SECRET_KEY: "" | ||
POSTGRES_DB: dockerdc | ||
POSTGRES_PASSWORD: mysecret1@Passwd | ||
POSTGRES_USER: postgres | ||
POSTGRES_HOST: localhost | ||
POSTGRES_PORT: 5432 | ||
|
||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: [3.9] | ||
|
||
services: | ||
postgres_db: | ||
image: postgres:13 | ||
env: | ||
POSTGRES_DB: ${{ env.POSTGRES_DB }} | ||
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | ||
POSTGRES_USER: ${{ env.POSTGRES_USER }} | ||
POSTGRES_HOST: ${{ env.POSTGRES_HOST }} | ||
POSTGRES_PORT: 5432 | ||
# POSTGRES_HOST_AUTH_METHOD: trust | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run Tests | ||
run: | | ||
python manage.py test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.11-slim | ||
|
||
WORKDIR /api | ||
|
||
COPY . . | ||
|
||
# create a virtual env for the python application | ||
# this goes into the /opt dir | ||
RUN python3 -m venv /opt/venv | ||
|
||
# install requirements and run the entrypoint script | ||
RUN /opt/venv/bin/pip install -r requirements.txt && \ | ||
chmod +x entrypoint.sh | ||
|
||
EXPOSE 8080 | ||
|
||
# Start the application | ||
CMD ["/api/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ python manage.py migrate | |
if [[ $CREATE_SUPERUSER ]]; then | ||
python manage.py createsuperuser --no-input | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: "3.9" | ||
services: | ||
postgres_db: | ||
image: postgres:16 | ||
env_file: | ||
- .env | ||
expose: | ||
- 5432 | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data/ | ||
api: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.dev | ||
depends_on: | ||
- postgres_db | ||
image: smart_learn:v1 | ||
env_file: | ||
- .env | ||
ports: | ||
- "8080:8080" | ||
command: sh -c "chmod +x /api/migrate.sh && sh /api/migrate.sh && /api/entrypoint.sh" | ||
restart: always | ||
redis: | ||
image: redis:alpine | ||
env_file: | ||
- .env | ||
expose: | ||
- 6379 | ||
ports: | ||
- "6379:6379" | ||
|
||
volumes: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
# creating a default application port to run on | ||
APP_PORT=${PORT:-8080} | ||
cd /api/ | ||
/opt/venv/bin/gunicorn --worker-tmp-dir /dev/shm smart_learning.wsgi:application --bind "0.0.0.0:$APP_PORT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit # exit when there is an error error | ||
|
||
# provide the superuser email, or a default | ||
SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL:-"hello@smartlearn.com"} | ||
|
||
# enter working directory | ||
cd /api/ | ||
|
||
# use the virtual env to run the python commands | ||
/opt/venv/bin/python manage.py migrate --noinput | ||
|
||
/opt/venv/bin/python manage.py createsuperuser --email $SUPERUSER_EMAIL --noinput || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters