Builds Docker image as WSGI + gunicorn
This commit is contained in:
parent
4eaee57076
commit
be1d54bbc5
54
Dockerfile
54
Dockerfile
|
@ -1,23 +1,45 @@
|
|||
FROM python:3.6.9-slim
|
||||
#
|
||||
# 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
|
||||
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
|
||||
COPY Pipfile Pipfile.lock /app/
|
||||
RUN pipenv install --dev \
|
||||
&& pipenv lock -r > requirements.txt \
|
||||
&& pipenv run python setup.py bdist_wheel
|
||||
|
||||
RUN pip install pipenv && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc python3-dev libssl-dev \
|
||||
curl postgresql-client git-core && \
|
||||
pipenv install --dev && \
|
||||
apt-get remove -y gcc python3-dev libssl-dev && \
|
||||
apt-get purge -y --auto-remove && \
|
||||
rm -rf /var/lib/apt/lists/ *
|
||||
# ----------------------------------------------------------------------------
|
||||
FROM ubuntu:bionic
|
||||
|
||||
COPY . /app/
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
ENV FLASK_APP=/app/crc/__init__.py
|
||||
CMD ["pipenv", "run", "python", "/app/run.py"]
|
||||
COPY --from=pipenv /app/dist/*.whl .
|
||||
|
||||
# expose ports
|
||||
EXPOSE 5000
|
||||
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
|
||||
|
||||
USER _gunicorn
|
||||
ADD static /app/static
|
||||
WORKDIR /app
|
||||
|
||||
CMD ["gunicorn3", \
|
||||
"--bind", "0.0.0.0:8000", \
|
||||
"crc:app"]
|
||||
|
|
1
Pipfile
1
Pipfile
|
@ -5,6 +5,7 @@ verify_ssl = true
|
|||
|
||||
[dev-packages]
|
||||
pytest = "*"
|
||||
pbr = "*"
|
||||
|
||||
[packages]
|
||||
connexion = {extras = ["swagger-ui"],version = "*"}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "1ca737db75750ea4351c15b4b0b26155d90bc5522705ed293a0c2773600b6a0a"
|
||||
"sha256": "61f93d8163e543498cc8d8d87e474f3676d386ac99749a110f62fc92e651febb"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
|
@ -235,11 +235,11 @@
|
|||
},
|
||||
"docxtpl": {
|
||||
"hashes": [
|
||||
"sha256:16a76d360c12f7da3a28821fc740b9a84b891895233493ff0b002ffaa6026905",
|
||||
"sha256:f19adf2a713a753c1e056ef0ce395bc8da62d495b091ebf9fe67dfc6d1115f9f"
|
||||
"sha256:0e031ea5da63339f2bac0fd7eb7b3b137303571a9a92c950501148240ea22047",
|
||||
"sha256:45f04661b9ab1fd66b975a0a547b30c8811f457bef2f85249c2f3c5784a00052"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.9.2"
|
||||
"version": "==0.10.0"
|
||||
},
|
||||
"et-xmlfile": {
|
||||
"hashes": [
|
||||
|
@ -911,6 +911,14 @@
|
|||
],
|
||||
"version": "==20.4"
|
||||
},
|
||||
"pbr": {
|
||||
"hashes": [
|
||||
"sha256:07f558fece33b05caf857474a366dfcc00562bca13dd8b47b2b3e22d9f9bf55c",
|
||||
"sha256:579170e23f8e0c2f24b0de612f71f648eccb79fb1322c814ae6b3c07b5ba23e8"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==5.4.5"
|
||||
},
|
||||
"pluggy": {
|
||||
"hashes": [
|
||||
"sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0",
|
||||
|
|
Loading…
Reference in New Issue