From 27d2b583bdc57fa3338a12d18829e154d58cf07c Mon Sep 17 00:00:00 2001 From: Gong Sophia Date: Wed, 24 Apr 2019 10:33:57 +0800 Subject: [PATCH] add haproxy container Signed-off-by: Gong Sophia --- .travis.yml | 1 + haproxy/Dockerfile | 18 ++++++++++++++++++ haproxy/README.md | 25 +++++++++++++++++++++++++ haproxy/docker-entrypoint.sh | 17 +++++++++++++++++ haproxy/haproxy.cfg | 16 ++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 haproxy/Dockerfile create mode 100644 haproxy/README.md create mode 100755 haproxy/docker-entrypoint.sh create mode 100644 haproxy/haproxy.cfg diff --git a/.travis.yml b/.travis.yml index c418994..f05c248 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ env: - DOCKERFILE_DIR=clr-installer-ci - DOCKERFILE_DIR=clr-sdk - DOCKERFILE_DIR=elasticsearch + - DOCKERFILE_DIR=haproxy - DOCKERFILE_DIR=httpd - DOCKERFILE_DIR=machine-learning-ui - DOCKERFILE_DIR=machine-learning diff --git a/haproxy/Dockerfile b/haproxy/Dockerfile new file mode 100644 index 0000000..e6c148d --- /dev/null +++ b/haproxy/Dockerfile @@ -0,0 +1,18 @@ +FROM clearlinux:latest +MAINTAINER sophia.gong@intel.com + +ARG swupd_args + +RUN swupd update --no-boot-update $swupd_args + +RUN swupd bundle-add haproxy $swupd_args \ + && rm -rf /var/lib/swupd \ + && mkdir -p /usr/local/etc/haproxy + +STOPSIGNAL SIGUSR1 + +COPY docker-entrypoint.sh / +COPY haproxy.cfg /usr/local/etc/haproxy + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"] diff --git a/haproxy/README.md b/haproxy/README.md new file mode 100644 index 0000000..c9bf466 --- /dev/null +++ b/haproxy/README.md @@ -0,0 +1,25 @@ +haproxy +========== +This provides a Clear Linux* haproxy instance. + +Build +----- +docker build -t clearlinux/haproxy . + +Or just pull it from Dockerhub +--------------------------- +docker pull clearlinux/haproxy + +start a haproxy instance +----------------------- +docker run --name some-haproxy -d -p 8080:80 clearlinux/haproxy + +use customized configuration file +--------------------- +Since no two users of haproxy are likely to configure it exactly alike, we provide /usr/local/etc/haproxy/haproxy.cfg as an example, user may need to customize their own and override this default. Please refer to [page](https://cbonte.github.io/haproxy-dconv/) for configure details. + +Extra Build ARGs +---------------- +- ``swupd_args`` Specifies [SWUPD](https://github.com/clearlinux/swupd-client/blob/master/docs/swupd.1.rst#options) flags + +Default build args in Docker are on: https://docs.docker.com/engine/reference/builder/#arg diff --git a/haproxy/docker-entrypoint.sh b/haproxy/docker-entrypoint.sh new file mode 100755 index 0000000..d492e9b --- /dev/null +++ b/haproxy/docker-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- haproxy "$@" +fi + +if [ "$1" = 'haproxy' ]; then + shift # "haproxy" + # if the user wants "haproxy", let's add a couple useful flags + # -W -- "master-worker mode" (similar to the old "haproxy-systemd-wrapper"; allows for reload via "SIGUSR2") + # -db -- disables background mode + set -- haproxy -W -db "$@" +fi + +exec "$@" diff --git a/haproxy/haproxy.cfg b/haproxy/haproxy.cfg new file mode 100644 index 0000000..c9285d6 --- /dev/null +++ b/haproxy/haproxy.cfg @@ -0,0 +1,16 @@ +global + daemon + maxconn 256 + +defaults + mode http + timeout connect 5000ms + timeout client 50000ms + timeout server 50000ms + +frontend http-in + bind *:80 + default_backend servers + +backend servers + server server1 127.0.0.1:8000 maxconn 32