From 4efe40d184c28a9b8ec174f299b6523a80941c2a Mon Sep 17 00:00:00 2001 From: Scott Hussey Date: Wed, 28 Jun 2017 11:24:24 -0500 Subject: [PATCH] Update Dockerfile to better pattern Add requirements layer Add entrypoint.sh script to support future CLI Change Dockerfile to use ENTRYPOINT --- Dockerfile | 29 +++++++++++++++++++++++------ entrypoint.sh | 12 ++++++++++++ requirements-direct.txt | 10 ++++++++++ requirements.txt | 5 ----- 4 files changed, 45 insertions(+), 11 deletions(-) create mode 100755 entrypoint.sh create mode 100644 requirements-direct.txt delete mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile index a2bac38d..434e6c37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,20 +13,37 @@ # limitations under the License. FROM ubuntu:16.04 +ARG VERSION + ENV DEBIAN_FRONTEND noninteractive ENV container docker RUN apt -qq update && \ - apt -y install git netbase python3-minimal python3-setuptools python3-pip python3-dev ca-certificates gcc g++ make libffi-dev libssl-dev --no-install-recommends + apt -y install git \ + netbase \ + python3-minimal \ + python3-setuptools \ + python3-pip \ + python3-dev \ + ca-certificates \ + gcc \ + g++ \ + make \ + libffi-dev \ + libssl-dev --no-install-recommends -# Need to configure proxies? - -RUN git clone https://github.com/sh8121att/drydock /tmp/drydock +# Copy direct dependency requirements only to build a dependency layer +COPY ./requirements-direct.txt /tmp/drydock/ +RUN pip3 install -r /tmp/drydock/requirements-direct.txt +COPY . /tmp/drydock WORKDIR /tmp/drydock - RUN python3 setup.py install EXPOSE 9000 -CMD ["/usr/bin/uwsgi","--http",":9000","-w","drydock_provisioner.drydock","--callable","drydock","--enable-threads","-L"] \ No newline at end of file +COPY examples/drydock.conf /etc/drydock/drydock.conf + +ENTRYPOINT ["./entrypoint.sh"] + +CMD ["server"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..c9933790 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +CMD="drydock" +PORT="8000" + +set -e + +if [ "$1" = 'server' ]; then + exec uwsgi --http :${PORT} -w drydock_provisioner.drydock --callable drydock --enable-threads -L --pyargv "--config-file /etc/drydock/drydock.conf" +fi + +exec ${CMD} $@ diff --git a/requirements-direct.txt b/requirements-direct.txt new file mode 100644 index 00000000..bf099b84 --- /dev/null +++ b/requirements-direct.txt @@ -0,0 +1,10 @@ +PyYAML +pyghmi>=1.0.18 +netaddr +falcon +oslo.versionedobjects>=1.23.0 +requests +oauthlib +uwsgi>1.4 +bson===0.4.7 +oslo.config diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1a33ec11..00000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -PyYAML==3.12 -oauth==1.0.1 -requests-oauthlib==0.8.0 -netaddr==0.7.19 -python-libmaas==0.4.1 \ No newline at end of file