From 13f9adfa53a2333aa9fcc4dc3aea625ddf8ad675 Mon Sep 17 00:00:00 2001 From: Anthony Lin Date: Fri, 22 Dec 2017 16:18:48 +0000 Subject: [PATCH] Update Shipyard Dockerfile This P.S. will allow user to execute Shipyard CLI using a Shipyard docker container. The updates made to the Dockerfile and entrypoint.sh are aligned with those in Armada and Drydock. Change-Id: I59ccd2d41fab19781f51334cb1a69b69a48d3c49 --- docs/source/client_user_guide.rst | 23 +++++++++++++++++++++++ entrypoint.sh | 24 +++++++++++++++++------- images/shipyard/Dockerfile | 22 +++++++++++++--------- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/docs/source/client_user_guide.rst b/docs/source/client_user_guide.rst index bd0ab9ff..14b166b3 100644 --- a/docs/source/client_user_guide.rst +++ b/docs/source/client_user_guide.rst @@ -171,6 +171,29 @@ response:: the value that Keystone returns when service lookup is done for the public URL for Shipyard. +Running Shipyard CLI with Docker Container +------------------------------------------ +It is also possible to execute Shipyard CLI using docker container + +Note that we will need to pass the relevant environment information as well +as the Shipyard command that we wish to execute as part of the ``docker run`` +command. In this example we will execute the ``get actions`` command:: + + sudo docker run -e 'OS_AUTH_URL=http://keystone-api.ucp.svc.cluster.local:80/v3' \ + -e 'OS_PASSWORD=password' -e 'OS_PROJECT_DOMAIN_NAME=default' \ + -e 'OS_PROJECT_NAME=service' -e 'OS_USERNAME=shipyard' \ + -e 'OS_USER_DOMAIN_NAME=default' -e 'OS_IDENTITY_API_VERSION=3' \ + --rm --net=host attcomdev/shipyard:latest get actions + +The output will resemble the following:: + + + CMD=shipyard + + PORT=9000 + + '[' get = server ']' + + exec shipyard get actions + Name Action Lifecycle + deploy_site action/01C1Z4HQM8RFG823EQT3EAYE4X Processing + Use Case: Ingest Site Design ---------------------------- Shipyard serves as the entrypoint for a deployment of the Undercloud Platform diff --git a/entrypoint.sh b/entrypoint.sh index 4b59c5f1..2f6475d7 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -14,10 +14,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Start shipyard application -exec uwsgi \ - --http :9000 \ - --paste config:/etc/shipyard/api-paste.ini \ - --enable-threads \ - -L \ - --pyargv "--config-file /etc/shipyard/shipyard.conf" \ No newline at end of file +set -ex + +CMD="shipyard" +PORT="9000" + +if [ "$1" = 'server' ]; then + # Start shipyard application + exec uwsgi \ + --http :${PORT} \ + --paste config:/etc/shipyard/api-paste.ini \ + --enable-threads \ + -L \ + --pyargv "--config-file /etc/shipyard/shipyard.conf" +else + # Execute shipyard command + exec ${CMD} $@ +fi diff --git a/images/shipyard/Dockerfile b/images/shipyard/Dockerfile index 6b1d8d3b..0b9bd86a 100644 --- a/images/shipyard/Dockerfile +++ b/images/shipyard/Dockerfile @@ -16,6 +16,8 @@ FROM ubuntu:16.04 ENV DEBIAN_FRONTEND noninteractive ENV container docker +ENV LC_ALL C.UTF-8 +ENV LANG C.UTF-8 RUN set -x && \ apt-get -qq update && \ @@ -47,15 +49,17 @@ RUN set -x && \ /usr/share/doc \ /usr/share/doc-base -# Copy dependency requirements -COPY ./requirements.txt /tmp/ -RUN pip3 install -r /tmp/requirements.txt - # Create shipyard user RUN useradd -ms /bin/bash shipyard # Clone the shipyard repository -COPY ./ /home/shipyard/shipyard +COPY . /home/shipyard/shipyard + +# Set work directory +# Install dependency requirements and packages +WORKDIR /home/shipyard/shipyard +RUN pip3 install -r requirements.txt +RUN python3 setup.py install # Copy entrypoint.sh to /home/shipyard COPY entrypoint.sh /home/shipyard/entrypoint.sh @@ -64,13 +68,13 @@ COPY entrypoint.sh /home/shipyard/entrypoint.sh RUN chown -R shipyard: /home/shipyard \ && chmod +x /home/shipyard/entrypoint.sh +# Set user to shipyard +USER shipyard + # Expose port 9000 for application EXPOSE 9000 -# Set work directory -USER shipyard -WORKDIR /home/shipyard/shipyard - # Execute entrypoint ENTRYPOINT ["/home/shipyard/entrypoint.sh"] +CMD ["server"]