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

Clean up python dependencies #1429

Merged
merged 3 commits into from
May 2, 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
23 changes: 15 additions & 8 deletions django/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# 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
WORKDIR /code/cantusdb_project

COPY cantusdb_project .
# 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/"

# define the default command to run when starting the container
CMD ["gunicorn", "--chdir", "cantusdb", "--bind", ":8000", "cantusdb.wsgi:application", "--workers", "5"]
CMD ["gunicorn", "--bind", ":8000", "cantusdb.wsgi:application", "--workers", "5"]
42 changes: 0 additions & 42 deletions django/cantusdb_project/requirements.txt

This file was deleted.

14 changes: 14 additions & 0 deletions django/install-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

pip install poetry==1.8.2

poetry config virtualenvs.in-project true # Creates a virtualenv in the project directory
poetry config virtualenvs.options.always-copy true # Ensures no symlinking in the virtualenv
poetry config virtualenvs.options.no-pip true # Don't install pip in the virtualenv
poetry config virtualenvs.options.no-setuptools true # Don't install setuptools in the virtualenv

if [ $1 = "DEVELOPMENT" ]; then
poetry install --no-cache --with debug
else
poetry install --no-cache
fi
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ version: '3'
services:
django:
build:
context: ./django
context: .
dockerfile: ./django/Dockerfile
volumes:
- ./:/code/
- ./django/cantusdb_project:/code/cantusdb_project
- static_volume:/resources/static
- media_volume:/resources/media
- api_cache_volume:/resources/api_cache
Expand Down
Loading