-
Notifications
You must be signed in to change notification settings - Fork 3
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 #113 from ropable/master
Upgrade Django to 1.11, switch env management to Poetry, consolidate models & templates
- Loading branch information
Showing
88 changed files
with
2,017 additions
and
13,194 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 |
---|---|---|
@@ -1,28 +1,31 @@ | ||
FROM python:2.7.18-slim-buster | ||
FROM python:3.7.17-slim-buster as builder_base_penguins | ||
MAINTAINER [email protected] | ||
LABEL org.opencontainers.image.source https://github.com/dbca-wa/penguins | ||
|
||
WORKDIR /app | ||
RUN apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install --no-install-recommends -y wget gcc gdal-bin libsasl2-dev python-dev libssl-dev libxml2-dev libxslt1-dev \ | ||
&& apt-get install -y libmagic-dev gcc binutils gdal-bin proj-bin python3-dev libpq-dev gzip curl \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& pip install --upgrade pip | ||
COPY manage.py requirements.txt ./ | ||
RUN pip install --no-cache-dir --no-warn-conflicts -r requirements.txt \ | ||
# Update the Django <1.11 bug in django/contrib/gis/geos/libgeos.py | ||
# Reference: https://stackoverflow.com/questions/18643998/geodjango-geosexception-error | ||
&& sed -i -e "s/ver = geos_version().decode()/ver = geos_version().decode().split(' ')[0]/" /usr/local/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py | ||
|
||
# Added in Django 1.7, needed by azure_storage module. | ||
COPY utils/deconstruct.py /usr/local/lib/python2.7/site-packages/django/utils/ | ||
# Install Python libs using poetry. | ||
FROM builder_base_penguins as python_libs_penguins | ||
WORKDIR /app | ||
ENV POETRY_VERSION=1.2.2 | ||
RUN pip install "poetry==$POETRY_VERSION" | ||
COPY poetry.lock pyproject.toml /app/ | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry install --no-interaction --no-ansi --only main | ||
|
||
# Install the project. | ||
FROM python_libs_penguins | ||
COPY gunicorn.py manage.py ./ | ||
COPY observations ./observations | ||
COPY penguins ./penguins | ||
COPY utils ./utils | ||
RUN python manage.py collectstatic --noinput | ||
|
||
# Run the application as the www-data user. | ||
USER www-data | ||
HEALTHCHECK --interval=1m --timeout=5s --start-period=10s --retries=3 CMD ["wget", "-q", "-O", "-", "http://localhost:8080/"] | ||
EXPOSE 8080 | ||
CMD ["python", "manage.py", "runwsgiserver", "host=0.0.0.0", "port=8080", "staticserve=collectstatic"] | ||
CMD ["gunicorn", "penguins.wsgi", "--config", "gunicorn.py"] |
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 @@ | ||
# Gunicorn configuration settings. | ||
import multiprocessing | ||
|
||
bind = ":8080" | ||
# Don't start too many workers: | ||
workers = min(multiprocessing.cpu_count() * 2 + 1, 16) | ||
# Give workers an expiry: | ||
max_requests = 2048 | ||
max_requests_jitter = 256 | ||
preload_app = True | ||
# Set longer timeout for workers | ||
timeout = 600 | ||
# Disable access logging. | ||
accesslog = None |
Oops, something went wrong.