Skip to content

Commit

Permalink
Add an additional service for traefik 2 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
andytson-inviqa committed May 13, 2022
1 parent 7621db9 commit 06aa463
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/workspace/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ command('global service proxy (enable|disable|restart)', 'global service proxy')
#!bash|=
ws.service proxy ={input.command(4)}
command('global service proxy2 (enable|disable|restart)', 'global service proxy2'):
description: Actions for Traefik proxy2 (my127.site)
exec: |
#!bash|=
ws.service proxy2 ={input.command(4)}
command('global service tracing (start|stop|restart)', 'global service tracing'): |
#!bash|=
ws.service tracing ={input.command(4)}
Expand Down
1 change: 1 addition & 0 deletions home/service/proxy2/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TRAEFIK_NETWORK=my127ws
27 changes: 27 additions & 0 deletions home/service/proxy2/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3'
services:
traefik:
container_name: my127ws-proxy2
build: traefik
restart: unless-stopped
ports:
- 80:80
- 443:443
labels:
- traefik.enable=true
- traefik.http.routers.traefik.rule=Host(`my127.site`)
- traefik.http.services.traefik.loadbalancer.server.port=8080
- co.elastic.logs/module=traefik
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ~/.config/my127ws/proxy:/config
- ./traefik/root/tls:/tls
networks:
- private
- shared
networks:
private:
external: false
shared:
external:
name: $TRAEFIK_NETWORK
64 changes: 64 additions & 0 deletions home/service/proxy2/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

set -e

DIR=""

main()
{
if [ "$1" = "enable" ]; then
enable
exit
fi

if [ "$1" = "disable" ]; then
disable
exit
fi

if [ "$1" = "restart" ]; then
restart
exit
fi
}

enable()
(
cd "$DIR"

if ! docker ps | grep my127ws-proxy2 > /dev/null; then

if [ ! -d "traefik/root/tls" ]; then
run mkdir -p traefik/root/tls
fi

run curl --fail --location --output traefik/root/tls/my127.site.crt "$(ws global config get global.service.proxy.https.crt)"
run curl --fail --location --output traefik/root/tls/my127.site.key "$(ws global config get global.service.proxy.https.key)"
run docker-compose -p my127ws-proxy2 up --force-recreate --build -d traefik
fi
)

disable()
(
cd "$DIR"

if docker ps | grep my127ws-proxy2 > /dev/null; then
run docker-compose -p my127ws-proxy2 rm --stop --force traefik
fi
)

restart()
{
disable
enable
}

bootstrap()
{
DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=../../lib/sidekick.sh
source "$DIR/../../lib/sidekick.sh"
}

bootstrap
main "$@"
3 changes: 3 additions & 0 deletions home/service/proxy2/traefik/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM traefik:2.7

COPY root /
Empty file.
6 changes: 6 additions & 0 deletions home/service/proxy2/traefik/root/config/tls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tls:
stores:
default:
defaultCertificate:
certFile: /tls/my127.site.crt
keyFile: /tls/my127.site.key
Empty file.
26 changes: 26 additions & 0 deletions home/service/proxy2/traefik/root/traefik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
providers:
file:
directory: /config
watch: true
docker:
exposedByDefault: false

api:
dashboard: true
insecure: true

accessLog: {}
log: {}

entryPoints:
http:
address: ":80"
https:
address: ":443"
http:
tls: {}

inactive.tracing:
jaeger:
samplingServerURL: http://jaeger:5778/sampling
localAgentHostPort: jaeger:6831

0 comments on commit 06aa463

Please sign in to comment.