Skip to content

Commit

Permalink
Experimental PyPy version of Caluma
Browse files Browse the repository at this point in the history
This uses a separate Dockerfile, so users will still have the choice

Also we need to use a different psycopg2 implementation, as the cPython
version doesn't work with pypy
  • Loading branch information
David Vogt committed Jun 21, 2019
1 parent 8fead3a commit ef86bc0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions caluma/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import os
import re
import sys

import environ
from django.conf import global_settings

if hasattr(sys, "pypy_version_info"): # pragma: no cover
# in pypy, override psycopg2 with cffi version
from psycopg2cffi import compat

compat.register()


env = environ.Env()
django_root = environ.Path(__file__) - 2

Expand Down
35 changes: 35 additions & 0 deletions pypy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM pypy:3.6

# pypy image still has /usr/bin/python being cpython, we don't want that
RUN rm /usr/bin/python && cp /usr/local/bin/pypy3 /usr/local/bin/python

WORKDIR /app

RUN wget -q https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -P /usr/local/bin \
&& chmod +x /usr/local/bin/wait-for-it.sh \
&& mkdir -p /app \
&& useradd -u 901 -r caluma --create-home \
# all project specific folders need to be accessible by newly created user but also for unknown users (when UID is set manually). Such users are in group root.
&& chown -R caluma:root /home/caluma \
&& chmod -R 770 /home/caluma

# needs to be set for users with manually set UID
ENV HOME=/home/caluma

ENV PYTHONUNBUFFERED=1
ENV APP_HOME=/app
ENV DJANGO_SETTINGS_MODULE caluma.settings
ENV UWSGI_INI /app/uwsgi.ini

ARG REQUIREMENTS=requirements-pypy.txt
COPY requirements.txt requirements-dev.txt pypy/requirements-pypy.txt $APP_HOME/
RUN pip install --no-cache-dir --upgrade -r $REQUIREMENTS --disable-pip-version-check


USER caluma

COPY . $APP_HOME

EXPOSE 8000

CMD /bin/sh -c "wait-for-it.sh $DATABASE_HOST:${DATABASE_PORT:-5432} -- ./manage.py migrate && uwsgi"
2 changes: 2 additions & 0 deletions pypy/requirements-pypy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-f requirements.txt
psycopg2cffi==2.8.1

0 comments on commit ef86bc0

Please sign in to comment.