Create docker app for deploy http hello server with conf.d, etcd and waiting script
This commit is contained in:
parent
d1b602a8ec
commit
af7b0773ec
30
test.dockerapp/docker-compose.yml
Normal file
30
test.dockerapp/docker-compose.yml
Normal file
@ -0,0 +1,30 @@
|
||||
version: "3.6"
|
||||
services:
|
||||
hello:
|
||||
build:
|
||||
context: ./test.dockerapp/http-echo-confd/
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
httpEchoServerVersion: ${image-version}
|
||||
alpineVersion: ${alpine-version}
|
||||
environment:
|
||||
HTTPTEXT: ${response-text}
|
||||
# etcdWait parameter
|
||||
PLATFORM: ${etcdWait-platform}
|
||||
MAX_RETRY: ${etcdWait-max-retry}
|
||||
SLEEP_TIME: ${etcdWait-sleep-time}
|
||||
ports:
|
||||
- ${echo-port}:5678
|
||||
|
||||
etcd:
|
||||
image: bitnami/etcd
|
||||
environment:
|
||||
- ALLOW_NONE_AUTHENTICATION=yes
|
||||
# - ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379
|
||||
restart: always
|
||||
ports:
|
||||
- "2379:2379/tcp"
|
||||
|
||||
volumes:
|
||||
data-volume:
|
||||
driver: local
|
26
test.dockerapp/http-echo-confd/Dockerfile
Normal file
26
test.dockerapp/http-echo-confd/Dockerfile
Normal file
@ -0,0 +1,26 @@
|
||||
ARG httpEchoServerVersion="latest"
|
||||
ARG alpineVersion=3.7
|
||||
FROM hashicorp/http-echo:${httpEchoServerVersion} as echo
|
||||
|
||||
EXPOSE 2379
|
||||
|
||||
FROM golang:alpine${alpineVersion}
|
||||
|
||||
ENV HTTPTEXT=${HTTPTEXT:-"Hello word"}
|
||||
ENV ETCDCTL_API=${etcdApiVersion:-3}
|
||||
ENV ETCD_VERSION=${etcdVersion:-3.3.11}
|
||||
|
||||
COPY --from=echo /http-echo /usr/local/bin/http-echo
|
||||
ADD ./etcdWait.sh /usr/bin/etcdWait
|
||||
|
||||
ARG etcdFolder=etcd-v$ETCD_VERSION-linux-amd64
|
||||
|
||||
RUN apk add --no-cache wget && \
|
||||
wget https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-darwin-amd64 -o /usr/local/bin/confd && \
|
||||
wget https://github.com/coreos/etcd/releases/download/v$ETCD_VERSION/${etcdFolder}.tar.gz && \
|
||||
tar -zxvf ${etcdFolder}.tar.gz && \
|
||||
mv $(pwd)/${etcdFolder}/etcdctl /usr/local/bin/etcdctl && \
|
||||
chmod +x /usr/bin/etcdWait
|
||||
|
||||
# confd -onetime -backend etcd && cat /tmp/myScript.conf &&
|
||||
CMD etcdWait && http-echo -text="$HTTPTEXT"
|
24
test.dockerapp/http-echo-confd/etcdWait.sh
Normal file
24
test.dockerapp/http-echo-confd/etcdWait.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
PLATFORM=${PLATFORM:-"vm"}
|
||||
SLEEP_TIME=${SLEEP_TIME:-"5"}
|
||||
MAX_RETRY=${MAX_RETRY:-"10"}
|
||||
RETRY=1
|
||||
|
||||
# check loaded status
|
||||
# @param $1 : platform's key
|
||||
check_status()
|
||||
{
|
||||
ETCD_READY=$(etcdctl --endpoints http://etcd:2379 get /${1}/etcd/loaded)
|
||||
}
|
||||
|
||||
# ETCDCTL_API=3 should be defined as a global variable
|
||||
check_status ${PLATFORM}
|
||||
while [[ -z "${ETCD_READY}" && ${RETRY} -le ${MAX_RETRY} ]]; do
|
||||
echo "Waiting for ECTD init ... (try number ${RETRY})";
|
||||
check_status ${PLATFORM}
|
||||
sleep ${SLEEP_TIME};
|
||||
|
||||
RETRY=$(expr ${RETRY} + 1)
|
||||
done
|
||||
echo "ECTD init ready."
|
12
test.dockerapp/metadata.yml
Normal file
12
test.dockerapp/metadata.yml
Normal file
@ -0,0 +1,12 @@
|
||||
# Version of the application
|
||||
version: 0.1.0
|
||||
# Name of the application
|
||||
name: test
|
||||
# A short description of the application
|
||||
description:
|
||||
# Namespace to use when pushing to a registry. This is typically your Hub username.
|
||||
namespace: antoine
|
||||
# List of application maintainers with name and email for each
|
||||
maintainers:
|
||||
- name: test
|
||||
email: antoine.roux@zenika.com
|
13
test.dockerapp/parameters.yml
Normal file
13
test.dockerapp/parameters.yml
Normal file
@ -0,0 +1,13 @@
|
||||
echo-port: 5678
|
||||
etcd-port: 2379
|
||||
|
||||
etcdWait-platform: dev
|
||||
etcdWait-max-retry: 100
|
||||
etcdWait-sleep-time: 2
|
||||
|
||||
response-text: Hello world custom
|
||||
|
||||
etcdApiVersion: 3.3
|
||||
etcd-version: 3.3.11
|
||||
image-version: latest
|
||||
alpine-version: 3.7
|
Loading…
Reference in New Issue
Block a user