Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
424 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# This is the same idea as Dockerfile, but this one uses pipenv with the Pipfile | ||
# and Pipfile.lock instead of requirements.txt. | ||
# | ||
######## | ||
# Python dependencies builder | ||
# | ||
FROM python:3-stretch AS builder | ||
|
||
# Always set a working directory | ||
WORKDIR /app | ||
# Sets utf-8 encoding for Python | ||
ENV LANG=C.UTF-8 | ||
# Turns off writing .pyc files. Superfluous on an ephemeral container. | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
# Seems to speed things up | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Ensures that the python and pip executables used | ||
# in the image will be those from our virtualenv. | ||
ENV PATH="/venv/bin:$PATH" | ||
|
||
# Install OS package dependencies. | ||
# Do all of this in one RUN to limit final image size. | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends gettext build-essential && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Setup the virtualenv | ||
RUN python -m venv /venv | ||
|
||
# Install Python deps | ||
RUN pip install pipenv | ||
COPY Pipfile Pipfile.lock ./ | ||
RUN pipenv install --system --deploy | ||
|
||
|
||
######## | ||
# slim app container | ||
# | ||
FROM python:3-slim-stretch AS app | ||
|
||
# Extra python env | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 | ||
ENV PATH="/venv/bin:$PATH" | ||
ENV PORT=8000 | ||
|
||
# add non-priviledged user | ||
RUN adduser --uid 1000 --disabled-password --gecos '' --no-create-home webdev | ||
|
||
WORKDIR /app | ||
EXPOSE 8000 | ||
CMD ["python", "app.py"] | ||
|
||
# copy in Python environment | ||
COPY --from=builder /venv /venv | ||
|
||
COPY ./static ./static | ||
COPY ./templates ./templates | ||
COPY ./app.py ./ | ||
|
||
RUN chown webdev.webdev -R . | ||
USER webdev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
responder = "*" | ||
|
||
[requires] | ||
python_version = "3.7" |
Oops, something went wrong.