Skip to content
Open
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
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.git
.github
.gitignore
**/__pycache__
**/*.egg-info
pip-wheel-metadata
**/node_modules
Dockerfile
makefile
pip-wheel-metadata
README.md
58 changes: 43 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 0 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand Down
8 changes: 0 additions & 8 deletions setup.py

This file was deleted.