-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Dockerfile that allows configuration through environment variables
- Loading branch information
Kevin Pankonen
committed
Jun 16, 2017
1 parent
33d45a7
commit cbbd64b
Showing
7 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM alpine:3.4 | ||
|
||
RUN apk --update upgrade \ | ||
&& apk add curl ca-certificates \ | ||
&& update-ca-certificates \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
COPY ldr /usr/bin/ | ||
COPY docker-entrypoint.sh /usr/bin/ | ||
|
||
ENTRYPOINT ["docker-entrypoint.sh"] | ||
|
||
EXPOSE 8030 | ||
CMD ["ldr"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine:3.4 | ||
|
||
RUN apk --update upgrade \ | ||
&& apk add go godep \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
WORKDIR /build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/sh | ||
if [ ! -f /etc/ld-relay.conf ]; then | ||
# only create /etc/ld-relay.conf if it doesn't exist already | ||
|
||
if ! env | grep -q LD_ENV_ ; then | ||
echo "WARNING: at least one LD_ENV_ should be set" >&2 | ||
fi | ||
|
||
echo " | ||
[main] | ||
streamUri = \"${STREAM_URI:-https://stream.launchdarkly.com}\" | ||
baseUri = \"${BASE_URI:-https://app.launchdarkly.com}\" | ||
exitOnError = ${EXIT_ON_ERROR:-false} | ||
port = ${PORT:-8030} | ||
heartbeatIntervalSecs = ${HEARTBEAT_INTERVAL:-15} | ||
" > /etc/ld-relay.conf | ||
|
||
if [ "$USE_REDIS" = 1 ]; then | ||
if echo "$REDIS_PORT" | grep -q 'tcp://'; then | ||
# REDIS_PORT gets set to tcp://$docker_ip:6379 when linking to a redis container | ||
# default to using those values if they exist | ||
REDIS_HOST_PART="${REDIS_PORT%:*}" | ||
REDIS_HOST="${REDIS_HOST_PART##*/}" | ||
REDIS_PORT="${REDIS_PORT##*:}" | ||
fi | ||
|
||
echo " | ||
[redis] | ||
host = \"${REDIS_HOST:-redis}\" | ||
port = ${REDIS_PORT:-6379} | ||
localTtl = ${REDIS_TTL:-30000} | ||
" >> /etc/ld-relay.conf | ||
fi | ||
|
||
if [ "$USE_EVENTS" = 1 ]; then | ||
echo " | ||
[events] | ||
eventsUri = \"${EVENTS_HOST:-https://events.launchdarkly.com}\" | ||
sendEvents = ${EVENTS_SEND:-true} | ||
flushIntervalSecs = ${EVENTS_FLUSH_INTERVAL:-5} | ||
samplingInterval = ${EVENTS_SAMPLING_INTERVAL:-0} | ||
capacity = ${EVENTS_CAPACITY:-10000} | ||
" >> /etc/ld-relay.conf | ||
fi | ||
|
||
for environment in $(env | grep LD_ENV_ ); do | ||
env_name="$(echo "$environment" | sed 's/^LD_ENV_//' | cut -d'=' -f1)" | ||
env_key="$(eval echo "\$$(echo "$environment" | cut -d'=' -f1)")" | ||
env_prefix="$(eval echo "\$LD_PREFIX_${env_name}")" | ||
|
||
echo " | ||
[environment \"$env_name\"] | ||
apiKey = \"$env_key\"" >> /etc/ld-relay.conf | ||
|
||
if [ -n "$env_prefix" ]; then | ||
echo "prefix = \"$env_prefix\"" >> /etc/ld-relay.conf | ||
fi | ||
done | ||
|
||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ -n "$CIRCLE_TAG" ]; then | ||
TAG="$CIRCLE_TAG" | ||
elif | ||
TAG="$CIRCLE_BRANCH" | ||
fi | ||
|
||
if [ -z "$TAG" ]; then | ||
echo "Skipping: unable to determine branch or tag" | ||
exit | ||
fi | ||
|
||
if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ] || [ -z "$DOCKER_REPO" ]; then | ||
echo "Skipping: DOCKER_USERNAME, DOCKER_PASSWORD, DOCKER_REPO environment variables not set" | ||
exit | ||
fi | ||
|
||
# dockerhub requires an email address, but doesn't use it for anything | ||
echo "[email protected]" | docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" | ||
docker tag "ld-relay:$CIRCLE_BUILD_NUM" "$DOCKER_REPO:$TAG" | ||
docker push "$DOCKER_REPO:$TAG" | ||
|
||
if [ "$TAG" = "master" ]; then | ||
# tag the master branch as latest | ||
docker tag "$DOCKER_REPO:$TAG" "$DOCKER_REPO:latest" | ||
docker push "$DOCKER_REPO:latest" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters