feat(haproxy): Add config
This commit is contained in:
parent
a62dcd794c
commit
290c5c302b
32
haproxy/README.md
Normal file
32
haproxy/README.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Docker Compose
|
||||||
|
|
||||||
|
## Environment
|
||||||
|
|
||||||
|
Prepare an environment file following the example in [env/fqdn_context.env.example](env/fqdn_context.env.example):
|
||||||
|
```
|
||||||
|
CONTEXT=foodstuffs_hongkong
|
||||||
|
DOCKER_SUBNET=172.24.23.0/24
|
||||||
|
HAPROXY_VERSION=latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Var `${DOCKER_SUBNET}` is optional and defaults to `${DOCKER_SUBNET-172.24.23.0/24}`. Treat `CONTEXT` as a team name, purpose or scope. If the same Docker application can run multiple times and serve different tenants then `CONTEXT` is what distinguishes one instance from the other. Here `foodstuffs_hongkong` indicates for example a Hong Kong-based foodstuffs team of some sort.
|
||||||
|
|
||||||
|
## Vars
|
||||||
|
|
||||||
|
Define Docker Compose variables, use the `COMPOSE_ENV_FILE` defined above in [Environment](#environment):
|
||||||
|
```
|
||||||
|
export COMPOSE_DIR='/opt/containers' # Or wherever this repo is checked out
|
||||||
|
export COMPOSE_FILE="${COMPOSE_DIR}"'/docker-compose.yml'
|
||||||
|
export COMPOSE_ENV_FILE=<add accordingly>
|
||||||
|
```
|
||||||
|
|
||||||
|
Run like so:
|
||||||
|
```
|
||||||
|
docker compose --file "${COMPOSE_FILE}" --env-file "${COMPOSE_ENV_FILE}" up --detach
|
||||||
|
```
|
||||||
|
|
||||||
|
Log entries will just be something along the lines of:
|
||||||
|
```
|
||||||
|
haproxy-CONTEXT | [NOTICE] (1) : New worker (8) forked
|
||||||
|
haproxy-CONTEXT | [NOTICE] (1) : Loading success.
|
||||||
|
```
|
14
haproxy/build-context/Dockerfile
Normal file
14
haproxy/build-context/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# For the remainder of this Dockerfile EXAMPLE_ARG_FOR_DOCKERFILE will be
|
||||||
|
# available with a value of 'must_be_available_in_dockerfile', check out the env
|
||||||
|
# file at 'env/fully.qualified.domain.name.example' for reference.
|
||||||
|
# ARG EXAMPLE_ARG_FOR_DOCKERFILE
|
||||||
|
|
||||||
|
# Another env var, this one's needed in the example build step below:
|
||||||
|
# ARG HAPROXY_VERSION
|
||||||
|
|
||||||
|
# Example
|
||||||
|
# FROM "haproxy:${HAPROXY_VERSION}"
|
||||||
|
# RUN apt-get update && \
|
||||||
|
# apt-get -y install \
|
||||||
|
# somepackage-6.q16-6-extra && \
|
||||||
|
# rm -rf /var/lib/apt/lists/*
|
0
haproxy/build-context/docker-data/.gitkeep
Normal file
0
haproxy/build-context/docker-data/.gitkeep
Normal file
0
haproxy/build-context/docker-data/haproxy.cfg
Normal file
0
haproxy/build-context/docker-data/haproxy.cfg
Normal file
0
haproxy/build-context/extras/.gitkeep
Normal file
0
haproxy/build-context/extras/.gitkeep
Normal file
11
haproxy/common-settings.yml
Normal file
11
haproxy/common-settings.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
services:
|
||||||
|
common-settings:
|
||||||
|
environment:
|
||||||
|
TZ: "${TIMEZONE:-Etc/UTC}"
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "10"
|
||||||
|
compress: "true"
|
||||||
|
restart: "${RESTARTPOLICY:-unless-stopped}"
|
9
haproxy/docker-compose.override.yml
Normal file
9
haproxy/docker-compose.override.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
haproxy-build:
|
||||||
|
image: "haproxy:${HAPROXY_VERSION}"
|
||||||
|
profiles: ["build"]
|
||||||
|
build:
|
||||||
|
context: "build-context/haproxy"
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
HAPROXY_VERSION: "${HAPROXY_VERSION}"
|
25
haproxy/docker-compose.yml
Normal file
25
haproxy/docker-compose.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
services:
|
||||||
|
haproxy:
|
||||||
|
image: "haproxy:${HAPROXY_VERSION}"
|
||||||
|
container_name: "haproxy-${CONTEXT}"
|
||||||
|
networks:
|
||||||
|
haproxy-default:
|
||||||
|
extends:
|
||||||
|
file: common-settings.yml
|
||||||
|
service: common-settings
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
volumes:
|
||||||
|
- /opt/docker-data/haproxy-${CONTEXT}/config/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
|
||||||
|
|
||||||
|
networks:
|
||||||
|
haproxy-default:
|
||||||
|
name: haproxy-${CONTEXT}
|
||||||
|
driver: bridge
|
||||||
|
driver_opts:
|
||||||
|
com.docker.network.enable_ipv6: "false"
|
||||||
|
ipam:
|
||||||
|
driver: default
|
||||||
|
config:
|
||||||
|
- subnet: ${DOCKER_SUBNET-172.24.23.0/24}
|
6
haproxy/env/fqdn_context.env.example
vendored
Normal file
6
haproxy/env/fqdn_context.env.example
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# This file is maintained by remco and populated with data from HashiCorp
|
||||||
|
# Vault. Changes not done in Vault will be reverted when file gets rendered.
|
||||||
|
|
||||||
|
CONTEXT=
|
||||||
|
DOCKER_SUBNET=
|
||||||
|
HAPROXY_VERSION=
|
Loading…
x
Reference in New Issue
Block a user