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

Use Poetry for dependency management #578

Closed
wants to merge 2 commits into from
Closed
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
37 changes: 24 additions & 13 deletions deploy/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
FROM python:3.8-alpine
FROM python:3.8-alpine as base

LABEL maintainer="[email protected]"

RUN apk add --no-cache postgresql-client postgresql-dev libmagic
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.1.13

COPY requirements.txt docker/plugins/requirements-*.txt /tmp/
RUN apk add --no-cache -t build libffi libffi-dev py3-cffi build-base python3-dev automake m4 autoconf libtool gcc g++ musl-dev libffi-dev openssl-dev cargo \
&& BUILD_LIB=1 pip --no-cache-dir install -r /tmp/requirements.txt \
&& ls /tmp/requirements-*.txt | xargs -i,, pip --no-cache-dir install -r ,, \
&& apk del build
FROM base as builder

# Copy backend files
COPY docker/ setup.py MANIFEST.in requirements.txt /app/
WORKDIR /app
# Install build-time Alpine dependencies
RUN apk add --no-cache postgresql-client postgresql-dev libmagic && \
apk add --no-cache libffi libffi-dev py3-cffi build-base python3-dev automake m4 autoconf libtool gcc g++ musl-dev libffi-dev openssl-dev cargo && \
pip install "poetry==$POETRY_VERSION"
# Create virtualenv and install build-time Python dependencies
RUN python3 -m venv /app/.venv && /app/.venv/bin/pip install wheel
# Copy MWDB Core code
COPY pyproject.toml poetry.lock poetry.toml README.md /app/
COPY mwdb /app/mwdb/
# Install project into /app/.venv (in-project=true)
RUN BUILD_LIB=1 poetry install -n --no-dev

# Install mwdb-core package
RUN pip install /app
FROM base as final

WORKDIR /app
RUN apk add --no-cache postgresql-client postgresql-dev libmagic
# Copy backend files
COPY docker/ /app/
COPY mwdb /app/mwdb/
COPY --from=builder /app/.venv /app/.venv
# Create a /app/uploads directory
# Give +r to everything in /app and +x for directories
# Give rwx permissions to /app/uploads for the current user
Expand All @@ -28,6 +41,4 @@ RUN mkdir -p /app/uploads/ && \

ENV PYTHONPATH=/app
ENV FLASK_APP=/app/mwdb/app.py
WORKDIR /app

CMD ["/app/start.sh"]
2 changes: 1 addition & 1 deletion docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ until psql "$MWDB_POSTGRES_URI" -c "\q" ; do
done

echo "Configuring mwdb-core instance"
. /app/.venv/bin/activate
mwdb-core configure --quiet basic

exec uwsgi --ini /app/uwsgi.ini
Loading