From fae15e5737efd3b98602da84f060993ed963f9f1 Mon Sep 17 00:00:00 2001 From: Blallo Date: Wed, 4 Sep 2019 12:36:01 +0200 Subject: [PATCH] Change entrypoint of dockerfile. Use environment variables for base_uri and config file. --- .dockerignore | 2 ++ Dockerfile | 4 ++-- entrypoint.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore index 8cdc7b4..d274de1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ /dist/* /bot.z_web/node_modules/* +/.*yaml +/.*yml diff --git a/Dockerfile b/Dockerfile index eb4e3d2..701280b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ COPY --from=node /opt /opt COPY --from=ff /opt/firefox-latest /opt/firefox-latest COPY --from=ff /opt/geckodriver* /opt/ COPY . /app +COPY entrypoint.sh /srv/ WORKDIR /app/bot.z_web RUN apt-get update \ && apt-get install -y $(apt-cache depends firefox-esr| awk '/Depends:/{print$2}') \ @@ -27,5 +28,4 @@ RUN python setup.py develop EXPOSE 3003 VOLUME ["/app/bot.z_web/node_modules"] -ENTRYPOINT ["z_app"] -CMD ["-a", "0.0.0.0"] +ENTRYPOINT ["/srv/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..00b433f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +CONF="/tmp/botz.yaml" + +if [ -z ${DEBUG} ]; then + _DEBUG="false" +else + _DEBUG="true" +fi + +if [ -z ${BASE_URI} ]; then + echo "Missing BASE_URI environment variable." + exit 1 +fi + +cat > ${CONF} <<-EOF +base_uri: ${BASE_URI} +debug: ${_DEBUG} +log: + level: ${DEBUG_LEVEL:-INFO} + syslog: false +http: + bind_addr: + - "0.0.0.0" + port: 3003 +EOF + +echo "--------------------------------------------" +echo " STARTING WITH CONFIG:" +echo "--------------------------------------------" +cat ${CONF} +echo "--------------------------------------------" + +z_app -c ${CONF}