Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an additional service for traefik 2 testing #127

Draft
wants to merge 1 commit into
base: 0.4.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

@andytson-inviqa andytson-inviqa May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directory needs to avoid being mounted, as the only way to specify tls certificate now is through the files provider. Why was it needed? @dcole-inviqa

- ./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