Browse Source

Use poetry in Dockerfiles

pull/1689/head
Hironsan 3 years ago
parent
commit
dadb96a1d6
3 changed files with 15 additions and 9 deletions
  1. 3
      backend/config/settings/base.py
  2. 8
      docker/Dockerfile
  3. 13
      docker/Dockerfile.prod

3
backend/config/settings/base.py

@ -107,7 +107,8 @@ STATIC_ROOT = path.join(BASE_DIR, "staticfiles")
STATICFILES_DIRS = [
path.join(BASE_DIR, "client/dist/static"),
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
# STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATICFILES_STORAGE = "whitenoise.storage.CompressedStaticFilesStorage"
# Auth settings
AUTHENTICATION_BACKENDS = [

8
docker/Dockerfile

@ -21,15 +21,17 @@ RUN apt-get update \
unixodbc-dev=2.* \
g++=4:* \
libssl-dev=1.* \
curl \
&& apt-get clean
WORKDIR /tmp
COPY Pipfile* /tmp/
COPY pyproject.toml /tmp/
# hadolint ignore=DL3013
RUN pip install --upgrade pip \
&& pip install --no-cache-dir --upgrade pipenv \
&& pipenv lock -r > /requirements.txt \
&& curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - \
&& PATH="${PATH}:$HOME/.poetry/bin" \
&& poetry export --without-hashes -o /requirements.txt \
&& echo "psycopg2-binary==2.8.6" >> /requirements.txt \
&& echo "django-heroku==0.3.1" >> /requirements.txt \
&& pip install --no-cache-dir -r /requirements.txt \

13
docker/Dockerfile.prod

@ -11,7 +11,7 @@ ENV PYTHONUNBUFFERED 1
RUN groupadd -g 61000 doccano \
&& useradd -g 61000 -l -M -s /bin/false -u 61000 doccano
COPY --chown=doccano:doccano ./Pipfile* /backend/
COPY --chown=doccano:doccano pyproject.toml poetry.lock /backend/
# hadolint ignore=DL3013
RUN apt-get update \
@ -20,10 +20,13 @@ RUN apt-get update \
libpq-dev=11.* \
unixodbc-dev=2.* \
g++=4:* \
curl \
&& pip install --upgrade pip \
&& pip install --no-cache-dir pipenv \
&& pipenv install --system --deploy \
&& pip uninstall -y pipenv virtualenv-clone virtualenv \
&& curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - \
&& PATH="${PATH}:$HOME/.poetry/bin" \
&& poetry config virtualenvs.create false \
&& poetry install --no-dev --no-root \
&& poetry add psycopg2-binary \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
@ -34,7 +37,7 @@ RUN mkdir -p /backend/staticfiles \
&& chown -R doccano:doccano /backend/
COPY --chown=doccano:doccano ./backend/ /backend/
RUN ls /backend
USER doccano:doccano
VOLUME /backend/staticfiles

Loading…
Cancel
Save