Skip to content

Commit

Permalink
Merge pull request #1437 from DDMAL/staging
Browse files Browse the repository at this point in the history
Merge staging into production, 2 May 2024
  • Loading branch information
dchiller authored May 17, 2024
2 parents d6546ea + 94cde34 commit cfd2fd6
Show file tree
Hide file tree
Showing 52 changed files with 2,784 additions and 648 deletions.
2 changes: 1 addition & 1 deletion config/nginx/conf.d/cantusdb.conf.development
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ server {
location = /504.html {
root /;
}
}
}
96 changes: 0 additions & 96 deletions config/nginx/conf.d/cantusdb.conf.production

This file was deleted.

96 changes: 0 additions & 96 deletions config/nginx/conf.d/cantusdb.conf.staging

This file was deleted.

11 changes: 0 additions & 11 deletions cron/cron.txt.production

This file was deleted.

11 changes: 0 additions & 11 deletions cron/cron.txt.staging

This file was deleted.

4 changes: 2 additions & 2 deletions cron/management/manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Note: This script is set up to run on the production server. If you want to run it on your local machine, you will need to change the paths.

DOCKER_COMPOSE_FILE=/home/ubuntu/code/CantusDB/docker-compose.yml # This is the path to the docker-compose file.
COMMAND=$1 # This is the command to execute.
DOCKER_COMPOSE_FILE=$1 # This is the path to the docker-compose file.
COMMAND=$2 # This is the command to execute.

/usr/local/bin/docker-compose -f $DOCKER_COMPOSE_FILE exec -T django python manage.py $COMMAND
4 changes: 2 additions & 2 deletions cron/postgres/db_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Note: This script is set up to run on the production server. If you want to run it on your local machine, you will need to change the paths.

BACKUP_DIR=/home/ubuntu/backups/postgres/ # This is the directory where the backups will be stored.
BACKUP_DIR=$1 # This is the directory where the backups will be stored.
BACKUP_FILENAME=$(date "+%Y-%m-%dT%H:%M:%S").sql.gz # This is the name of the backup file.


Expand Down Expand Up @@ -51,4 +51,4 @@ fi
# Retain an annual backup on the first day of the year
if [ $DAY_OF_MONTH -eq 1 ] && [ $MONTH_OF_YEAR -eq 1 ]; then
cp $BACKUP_DIR/daily/$BACKUP_FILENAME $BACKUP_DIR/yearly
fi
fi
24 changes: 14 additions & 10 deletions django/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# start from an official image
# Download and install python dependencies in a container
FROM python:3.9 as dependency-install-container
ARG PROJECT_ENVIRONMENT
COPY ./poetry.lock ./pyproject.toml ./django/install-packages.sh /code/
WORKDIR /code
RUN chmod u+x /code/install-packages.sh && \
/code/install-packages.sh $PROJECT_ENVIRONMENT

# Copy our dependencies into the base image
FROM python:3.9
COPY --from=dependency-install-container /code/.venv /code/.venv

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

EXPOSE 8000

WORKDIR /code/django/cantusdb_project

COPY cantusdb_project/requirements.txt /code/django/cantusdb_project

RUN pip3 install -r requirements.txt

COPY cantusdb_project .
WORKDIR /code/cantusdb_project

# define the default command to run when starting the container
CMD ["gunicorn", "--chdir", "cantusdb", "--bind", ":8000", "cantusdb.wsgi:application", "--workers", "5"]
# Add our python environment binaries and package files to the path
ENV PATH="$PATH:/code/.venv/bin/" \
PYTHONPATH="$PYTHONPATH:/code/.venv/lib/python3.9/site-packages/"
11 changes: 2 additions & 9 deletions django/cantusdb_project/cantusdb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,10 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False # this is switched to True below when PROJECT_ENVIRONMENT=="DEVELOPMENT"

ALLOWED_HOSTS = [os.getenv("CANTUSDB_HOST")]
CSRF_TRUSTED_ORIGINS = [f'https://{os.getenv("CANTUSDB_HOST")}']
if PROJECT_ENVIRONMENT == "DEVELOPMENT":
ALLOWED_HOSTS = os.getenv("CANTUSDB_HOSTS_DEVELOPMENT").split(" ")
CSRF_TRUSTED_ORIGINS = os.getenv("CANTUSDB_ORIGINS_DEVELOPMENT").split(" ")
DEBUG = True
if PROJECT_ENVIRONMENT == "STAGING":
ALLOWED_HOSTS = os.getenv("CANTUSDB_HOSTS_STAGING").split(" ")
CSRF_TRUSTED_ORIGINS = os.getenv("CANTUSDB_ORIGINS_STAGING").split(" ")
if PROJECT_ENVIRONMENT == "PRODUCTION":
ALLOWED_HOSTS = os.getenv("CANTUSDB_HOSTS_PRODUCTION").split(" ")
CSRF_TRUSTED_ORIGINS = os.getenv("CANTUSDB_ORIGINS_PRODUCTION").split(" ")


# Application definition

Expand Down
Loading

0 comments on commit cfd2fd6

Please sign in to comment.