From 9b8169625864bf7a9454a1de17bc4af8ae26fcf4 Mon Sep 17 00:00:00 2001 From: Eric Malloy Date: Thu, 21 Feb 2019 15:19:07 -0500 Subject: [PATCH 1/3] initial simple mcrouter dockerfile, fetch a package and install --- .../scripts/docker/Dockerfile.ubuntu-packaged | 19 +++++++++++++++++++ .../etc/apt/sources.list.d/10-mcrouter.list | 1 + 2 files changed, 20 insertions(+) create mode 100644 mcrouter/scripts/docker/Dockerfile.ubuntu-packaged create mode 100644 mcrouter/scripts/docker/container/ubuntu-packaged/etc/apt/sources.list.d/10-mcrouter.list diff --git a/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged b/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged new file mode 100644 index 000000000..800774eec --- /dev/null +++ b/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged @@ -0,0 +1,19 @@ +FROM ubuntu:xenial + +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update && \ + apt-get install -yq \ + wget \ + apt-transport-https + +COPY ["container/ubuntu-packaged/", "/"] + +RUN wget -qO- \ + https://facebook.github.io/mcrouter/debrepo/xenial/PUBLIC.KEY \ + | apt-key add \ + && DEBIAN_FRONTEND=noninteractive \ + apt-get update \ + && \ + apt-get install -yq mcrouter --no-install-recommends \ + && apt-get purge -y --autoremove -o APT::AutoRemove::RecommendsImportant=false wget apt-transport-https \ + && apt-get autoremove && apt-get autoclean && rm -rf /var/lib/apt-lists/* diff --git a/mcrouter/scripts/docker/container/ubuntu-packaged/etc/apt/sources.list.d/10-mcrouter.list b/mcrouter/scripts/docker/container/ubuntu-packaged/etc/apt/sources.list.d/10-mcrouter.list new file mode 100644 index 000000000..f18bfff75 --- /dev/null +++ b/mcrouter/scripts/docker/container/ubuntu-packaged/etc/apt/sources.list.d/10-mcrouter.list @@ -0,0 +1 @@ +deb https://facebook.github.io/mcrouter/debrepo/xenial xenial contrib From 40dd7b4cb0c2fbe3a46b67b8c6b1651d438bafc4 Mon Sep 17 00:00:00 2001 From: Eric Malloy Date: Fri, 22 Feb 2019 11:23:16 -0500 Subject: [PATCH 2/3] add entrypoint, if MCROUTER_CONFIG_PATH undefined then use the default one written to /etc/mcrouter/mcrouter.json simplify entrypoint. bundle the default mcrouter.json with the Docker image, and now allow to point at an alternative location for the mcrouter json config file --- .../scripts/docker/Dockerfile.ubuntu-packaged | 14 +++++++++----- .../container/ubuntu-packaged/mcrouter.json | 10 ++++++++++ .../usr/local/bin/entrypoint.sh | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 mcrouter/scripts/docker/container/ubuntu-packaged/mcrouter.json create mode 100755 mcrouter/scripts/docker/container/ubuntu-packaged/usr/local/bin/entrypoint.sh diff --git a/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged b/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged index 800774eec..5eb940f9e 100644 --- a/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged +++ b/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged @@ -1,10 +1,12 @@ FROM ubuntu:xenial -RUN DEBIAN_FRONTEND=noninteractive \ - apt-get update && \ - apt-get install -yq \ - wget \ - apt-transport-https +RUN set -xe \ + && buildDeps=" \ + wget \ + apt-transport-https" \ + && DEBIAN_FRONTEND=noninteractive \ + apt-get update \ + && apt-get install -y $buildDeps COPY ["container/ubuntu-packaged/", "/"] @@ -17,3 +19,5 @@ RUN wget -qO- \ apt-get install -yq mcrouter --no-install-recommends \ && apt-get purge -y --autoremove -o APT::AutoRemove::RecommendsImportant=false wget apt-transport-https \ && apt-get autoremove && apt-get autoclean && rm -rf /var/lib/apt-lists/* + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/mcrouter/scripts/docker/container/ubuntu-packaged/mcrouter.json b/mcrouter/scripts/docker/container/ubuntu-packaged/mcrouter.json new file mode 100644 index 000000000..fef6236fb --- /dev/null +++ b/mcrouter/scripts/docker/container/ubuntu-packaged/mcrouter.json @@ -0,0 +1,10 @@ +{ + "pools": { + "A": { + "servers": [ + "127.0.0.1:5001" + ] + } + }, + "route": "PoolRoute|A" +} diff --git a/mcrouter/scripts/docker/container/ubuntu-packaged/usr/local/bin/entrypoint.sh b/mcrouter/scripts/docker/container/ubuntu-packaged/usr/local/bin/entrypoint.sh new file mode 100755 index 000000000..f430fbc36 --- /dev/null +++ b/mcrouter/scripts/docker/container/ubuntu-packaged/usr/local/bin/entrypoint.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -o errexit + + +function run_mcrouter() { + local CONFIG_PATH=$1 + mcrouter \ + --config file:${CONFIG_PATH} \ + -p "${MCROUTER_LISTEN_PORT:-5000}" +} + + +if [ -z "${MCROUTER_CONFIG_PATH}" ]; then + echo "MCROUTER_CONFIG_PATH undefined! Using bundled default ..." + export MCROUTER_CONFIG_PATH=/etc/mcrouter/mcrouter.json +fi + +run_mcrouter "${MCROUTER_CONFIG_PATH}" "$@" From 8152ee754dda1598d241b39c1c12a786462c1b1b Mon Sep 17 00:00:00 2001 From: Eric Malloy Date: Tue, 26 Feb 2019 14:06:54 -0500 Subject: [PATCH 3/3] add MCROUTER_LISTEN_PORT as Dockerfile ENV explicitly list and COPY files into the docker image fs --- .../scripts/docker/Dockerfile.ubuntu-packaged | 18 +++++++++++++++++- .../apt/sources.list.d => }/10-mcrouter.list | 0 .../{usr/local/bin => }/entrypoint.sh | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) rename mcrouter/scripts/docker/container/ubuntu-packaged/{etc/apt/sources.list.d => }/10-mcrouter.list (100%) rename mcrouter/scripts/docker/container/ubuntu-packaged/{usr/local/bin => }/entrypoint.sh (87%) diff --git a/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged b/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged index 5eb940f9e..ac02b584e 100644 --- a/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged +++ b/mcrouter/scripts/docker/Dockerfile.ubuntu-packaged @@ -8,7 +8,20 @@ RUN set -xe \ apt-get update \ && apt-get install -y $buildDeps -COPY ["container/ubuntu-packaged/", "/"] + +COPY ["container/ubuntu-packaged/entrypoint.sh", \ + "/usr/local/bin/" \ + ] + +COPY ["container/ubuntu-packaged/10-mcrouter.list", \ + "/etc/apt/sources.list.d/" \ + ] + +COPY ["container/ubuntu-packaged/mcrouter.json", \ + "/etc/mcrouter/" \ + ] + + RUN wget -qO- \ https://facebook.github.io/mcrouter/debrepo/xenial/PUBLIC.KEY \ @@ -20,4 +33,7 @@ RUN wget -qO- \ && apt-get purge -y --autoremove -o APT::AutoRemove::RecommendsImportant=false wget apt-transport-https \ && apt-get autoremove && apt-get autoclean && rm -rf /var/lib/apt-lists/* + +ENV MCROUTER_LISTEN_PORT 5000 + ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/mcrouter/scripts/docker/container/ubuntu-packaged/etc/apt/sources.list.d/10-mcrouter.list b/mcrouter/scripts/docker/container/ubuntu-packaged/10-mcrouter.list similarity index 100% rename from mcrouter/scripts/docker/container/ubuntu-packaged/etc/apt/sources.list.d/10-mcrouter.list rename to mcrouter/scripts/docker/container/ubuntu-packaged/10-mcrouter.list diff --git a/mcrouter/scripts/docker/container/ubuntu-packaged/usr/local/bin/entrypoint.sh b/mcrouter/scripts/docker/container/ubuntu-packaged/entrypoint.sh similarity index 87% rename from mcrouter/scripts/docker/container/ubuntu-packaged/usr/local/bin/entrypoint.sh rename to mcrouter/scripts/docker/container/ubuntu-packaged/entrypoint.sh index f430fbc36..ff847c712 100755 --- a/mcrouter/scripts/docker/container/ubuntu-packaged/usr/local/bin/entrypoint.sh +++ b/mcrouter/scripts/docker/container/ubuntu-packaged/entrypoint.sh @@ -6,7 +6,8 @@ function run_mcrouter() { local CONFIG_PATH=$1 mcrouter \ --config file:${CONFIG_PATH} \ - -p "${MCROUTER_LISTEN_PORT:-5000}" + -p "${MCROUTER_LISTEN_PORT:-5000}" \ + "$@" }