Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement minor build fixes #871

Merged
merged 7 commits into from
May 31, 2024
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
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ COMPOSE_PROJECT_NAME=cantus
#When DEVELOPMENT is False, Django's DEBUG setting
#is False and app is served by gunicorn
DEVELOPMENT=False
#DJANGO_SECRET_KEY=**PROVIDE SECRET KEY HERE**

#Postgres authentication variables
POSTGRES_DB=cantus_db
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
RABBIT_USER: admin
RABBIT_PASSWORD: supersecurepassword99
PORT: "8000"
DJANGO_SECRET_KEY: verygoodandsecurekey123456123465@@123456
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

steps:
- uses: actions/checkout@v3
- run: docker compose build
Expand Down
8 changes: 4 additions & 4 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# syntax=docker/dockerfile:1
# Download and install python dependencies in a container
FROM python:3.12.3 as dependency-install-container
ARG APP_PORT
ARG DEVELOPMENT
COPY ./poetry.lock ./pyproject.toml ./app/install-packages.sh /code/
WORKDIR /code
RUN chmod u+x /code/install-packages.sh && \
/code/install-packages.sh $APP_PORT
/code/install-packages.sh $DEVELOPMENT

FROM python:3.12.3
COPY app/django-config.sh /code/
Expand All @@ -14,11 +14,11 @@ COPY app/production-mei-files/ /code/production-mei-files/
EXPOSE 8001

RUN chmod u+x /code/django-config.sh
RUN echo $(tr -dc A-Za-z0-9 </dev/urandom | head -c 64) >> /etc/key.txt
# Copy environment dependencies, but not poetry, to the django container
COPY --from=dependency-install-container /code/.venv /code/.venv
# Add our python environment binaries and package files to the path
ENV PATH="$PATH:/code/.venv/bin/" \
PYTHONPATH="$PYTHONPATH:/code/.venv/lib/python3.12/site-packages/"
PYTHONPATH="$PYTHONPATH:/code/.venv/lib/python3.12/site-packages/" \
DJANGO_SETTINGS_MODULE="cantusdata.settings"

WORKDIR /code/public
2 changes: 1 addition & 1 deletion app/install-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ poetry config virtualenvs.options.always-copy true
poetry config virtualenvs.options.no-pip true
poetry config virtualenvs.options.no-setuptools true

if [ $1 = "8000" ]; then
if [ $1 = "True" ]; then
poetry install --no-cache --with debug
else
poetry install --no-cache
Expand Down
4 changes: 1 addition & 3 deletions app/public/cantusdata/celery.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os
from celery import Celery

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cantusdata.settings")
app = Celery("cantusdata")
import cantusdata.settings as settings
from . import settings

app.config_from_object(settings, namespace="CELERY")
app.autodiscover_tasks()
Expand Down
9 changes: 5 additions & 4 deletions app/public/cantusdata/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
BASE_DIR = Path(__file__).resolve().parent.parent

# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
with open("/etc/key.txt", "r") as f:
SECRET_KEY = f.read().strip()
SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = is_development
Expand Down Expand Up @@ -47,9 +46,11 @@
"rest_framework",
"rest_framework.authtoken",
"cantusdata.CantusdataConfig",
"django_extensions",
)

if DEBUG:
INSTALLED_APPS += ("django_extensions",)

MIDDLEWARE = (
"django.middleware.security.SecurityMiddleware", # Migration: + django 3.1
"django.contrib.sessions.middleware.SessionMiddleware",
Expand Down Expand Up @@ -172,7 +173,7 @@
SECURE_HSTS_INCLUDE_SUBDOMAINS = is_production
SECURE_HSTS_PRELOAD = is_production

CELERY_BROKER_URL = f"amqp://{os.environ['RABBIT_USER']}:{os.environ['RABBIT_PASSWORD']}@cantus-rabbitmq-1:5672/{os.environ['RABBIT_VHOST']}"
CELERY_BROKER_URL = f"amqp://{os.environ.get('RABBIT_USER')}:{os.environ.get('RABBIT_PASSWORD')}@cantus-rabbitmq-1:5672/{os.environ.get('RABBIT_VHOST')}"
CELERY_RESULT_BACKEND = "django-db"
CELERY_RESULT_PERSISTENT = False
CELERY_RESULT_EXTENDED = True
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
context: .
dockerfile: ./app/Dockerfile
args:
APP_PORT: ${PORT}
DEVELOPMENT: ${DEVELOPMENT}
container_name: cantus-app-1
command: /code/django-config.sh
volumes:
Expand All @@ -19,6 +19,7 @@ services:
environment:
- APP_VERSION=${APP_VERSION}
- DEVELOPMENT=${DEVELOPMENT}
- DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
Expand Down
110 changes: 94 additions & 16 deletions poetry.lock

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

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ djangorestframework = "3.15.1"
gunicorn = "22.0.0"
lxml = "5.2.1"
markdown = "3.6"
psycopg = "3.1.18"
psycopg = {extras = ["binary"], version = "^3.1.18"}
requests = "2.31.0"
solrpy = "1.0.0"
solrpy = { git = "https://github.com/search5/solrpy", tag = "rel-1-0-0"}

[tool.poetry.group.debug]
optional = true
Expand Down
Loading