diff --git a/.dockerignore b/.dockerignore index fb4e1e1..e062672 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,10 @@ .git +.github .gitignore **/__pycache__ **/*.egg-info -pip-wheel-metadata **/node_modules +Dockerfile +makefile +pip-wheel-metadata +README.md diff --git a/Dockerfile b/Dockerfile index be2c57f..20c6fdb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,58 @@ -FROM python:3.8-slim +FROM python:3.8.2-alpine3.11 AS poetry RUN mkdir /src WORKDIR /src -RUN apt-get update -RUN apt-get -y install curl gcc gnupg -RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list -RUN apt-get update -RUN apt-get -y install yarn +RUN apk update +RUN apk add build-base libffi-dev openssl-dev -RUN pip install --upgrade pip +RUN pip install poetry==1.0.5 +ADD pyproject.toml pyproject.toml +ADD poetry.lock poetry.lock +RUN poetry export -f requirements.txt -o requirements.txt -ADD requirements.txt requirements.txt -RUN pip install -r requirements.txt -ADD timeuntil timeuntil -ADD setup.py setup.py -RUN pip install -e . -WORKDIR /src/timeuntil/static/js +FROM python:3.8.2-alpine3.11 AS pip + +RUN mkdir /src +WORKDIR /src + +RUN apk update +RUN apk add build-base libffi-dev openssl-dev + +COPY --from=poetry /src/requirements.txt /src/requirements.txt +RUN pip install --no-cache-dir -r requirements.txt + + + +FROM alpine:3.11.5 AS yarn + +RUN mkdir /src +WORKDIR /src + +RUN apk update +RUN apk add yarn + +ADD timeuntil/static/js/package.json package.json +ADD timeuntil/static/js/yarn.lock yarn.lock RUN yarn install + + + +FROM python:3.8.2-alpine3.11 AS production + +RUN mkdir /src WORKDIR /src -ENV FLASK_APP timeuntil/app.py +ADD timeuntil timeuntil ADD uwsgi.yaml uwsgi.yaml + +COPY --from=pip /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages +COPY --from=pip /usr/local/bin /usr/local/bin +COPY --from=yarn /src/node_modules /src/timeuntil/static/js/node_modules + +ENV FLASK_APP timeuntil/app.py EXPOSE 5000 CMD uwsgi --socket 0.0.0.0:5000 --protocol=http --yaml uwsgi.yaml diff --git a/README.md b/README.md index 934bbe7..d81f9b2 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,3 @@ zone. - Activate the virtual environment - Install the app via `make install_locally` - Launch the app via `make run_locally` - -## Development guidelines - -The use of Poetry is experimental. There are still some limits when having to -build a container to run the app. Namely a minimal `setup.py` and a full list -of requirements are still needed. In particular, before each commit run -`make update_requirements` which uses Poetry to export the requirements list -used in the container. This step will be automated via git pre-commit hooks. diff --git a/makefile b/makefile index c78f0e0..75aa18a 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,3 @@ -update_requirements: - poetry export -f requirements.txt -o requirements.txt && \ - poetry export -f requirements.txt -o test_requirements.txt --dev - install_locally: pip install --upgrade pip && \ poetry install && \ diff --git a/setup.py b/setup.py deleted file mode 100644 index 17e62ef..0000000 --- a/setup.py +++ /dev/null @@ -1,8 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="timeuntil", - version="0.1.0", - include_package_data=True, - packages=find_packages(exclude=["tests"]), -)