Refactors Dockerfile again. Installs gunicorn. Don't run gunicorn until the container starts up.
This commit is contained in:
parent
a633cc7c09
commit
c88b6847f2
|
@ -2,4 +2,4 @@
|
|||
__pycache__/
|
||||
app.db
|
||||
static/.webassets-cache*
|
||||
pb/static/*.css
|
||||
static/*.css
|
||||
|
|
63
Dockerfile
63
Dockerfile
|
@ -1,48 +1,31 @@
|
|||
#
|
||||
# https://medium.com/@greut/building-a-python-package-a-docker-image-using-pipenv-233d8793b6cc
|
||||
# https://github.com/greut/pipenv-to-wheel
|
||||
#
|
||||
FROM kennethreitz/pipenv as pipenv
|
||||
FROM python:3.7-slim
|
||||
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
|
||||
RUN pipenv install --dev \
|
||||
&& pipenv lock -r > requirements.txt \
|
||||
&& pipenv run python setup.py bdist_wheel
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
FROM ubuntu:bionic
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
COPY --from=pipenv /app/dist/*.whl .
|
||||
COPY Pipfile Pipfile.lock /app/
|
||||
|
||||
RUN set -xe \
|
||||
&& apt-get update -q \
|
||||
&& apt-get install -y -q \
|
||||
python3-minimal \
|
||||
python3-wheel \
|
||||
python3-pip \
|
||||
gunicorn3 \
|
||||
postgresql-client \
|
||||
&& python3 -m pip install *.whl \
|
||||
&& apt-get remove -y python3-pip python3-wheel \
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -f *.whl \
|
||||
&& rm -rf /root/.cache \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p /app \
|
||||
&& useradd _gunicorn --no-create-home --user-group
|
||||
&& pip install pipenv
|
||||
&& apt-get update -q \
|
||||
&& apt-get install -y -q \
|
||||
gcc python3-dev libssl-dev \
|
||||
curl postgresql-client git-core \
|
||||
gunicorn3 postgresql-client \
|
||||
&& pipenv install --dev \
|
||||
&& apt-get remove -y gcc python3-dev libssl-dev \
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p /app \
|
||||
&& useradd _gunicorn --no-create-home --user-group
|
||||
|
||||
COPY . /app/
|
||||
USER _gunicorn
|
||||
|
||||
COPY ./static /app/static
|
||||
COPY ./docker_run.sh /app/
|
||||
COPY ./wait-for-it.sh /app/
|
||||
WORKDIR /app
|
||||
ENV FLASK_APP=/app/pb/__init__.py
|
||||
|
||||
CMD ["gunicorn3", \
|
||||
"--bind", "0.0.0.0:8000", \
|
||||
"pb:app"]
|
||||
# Don't run gunicorn until the DC/OS container actually starts.
|
||||
# Otherwise, environment variables will not be availabele.
|
||||
#CMD ["pipenv", "run", "gunicorn", \
|
||||
# "--bind", "0.0.0.0:8000", \
|
||||
# "-e", "SCRIPT_NAME=/api", \
|
||||
# "crc:app"]
|
||||
|
|
1
Pipfile
1
Pipfile
|
@ -22,6 +22,7 @@ marshmallow-sqlalchemy = "*"
|
|||
wtforms-alchemy = "*"
|
||||
psycopg2-binary = "*"
|
||||
pyscss = "*"
|
||||
gunicorn = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.7"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "6d81da4e1f722cf965aeff5e24c86278b5df745f0eadaa2b401d54e7f836c654"
|
||||
"sha256": "22303ab4362e0b95f21f7c949b2d43a4ec58b42add20699c159d2a7cc3eaf0be"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
|
@ -200,6 +200,14 @@
|
|||
"markers": "platform_python_implementation == 'CPython'",
|
||||
"version": "==0.4.15"
|
||||
},
|
||||
"gunicorn": {
|
||||
"hashes": [
|
||||
"sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626",
|
||||
"sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==20.0.4"
|
||||
},
|
||||
"idna": {
|
||||
"hashes": [
|
||||
"sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
|
||||
|
@ -217,7 +225,6 @@
|
|||
},
|
||||
"infinity": {
|
||||
"hashes": [
|
||||
"sha256:91069282767a8695b880feda218948aafc1b89fddddd9b1b156792d9de8f6234",
|
||||
"sha256:dc4aa138d7e366fc00d2e741e32c78a0fecd16b74f8daeb3f7408b459668005c"
|
||||
],
|
||||
"version": "==1.4"
|
||||
|
|
Loading…
Reference in New Issue