Skip to content

Commit

Permalink
add entrypoint, if MCROUTER_CONFIG_PATH undefined then use the defaul…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
emalloy committed Feb 27, 2019
1 parent 9b81696 commit 40dd7b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mcrouter/scripts/docker/Dockerfile.ubuntu-packaged
Original file line number Diff line number Diff line change
@@ -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/", "/"]

Expand All @@ -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"]
10 changes: 10 additions & 0 deletions mcrouter/scripts/docker/container/ubuntu-packaged/mcrouter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"pools": {
"A": {
"servers": [
"127.0.0.1:5001"
]
}
},
"route": "PoolRoute|A"
}
Original file line number Diff line number Diff line change
@@ -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}" "$@"

0 comments on commit 40dd7b4

Please sign in to comment.