The Docker Compose file in this repository contains an instance of
Traefik for development purposes. It allows you to access
microservices through your browser using a hostname (such as
accounts.test.leviy.com) and to run multiple microservices at the same time
without port binding conflicts.
git clone [email protected]:leviy/workspace.git
cd workspace
docker compose up -dThe Docker Compose file contains the restart: always directive so Docker will
restart the container every time you boot your machine. If for some reason you
need to start another container or project that needs to bind to port 80, you
can stop the containers using:
docker compose stopWhen the containers are running, the Traefik dashboard can be found at
http://localhost:8080/dashboard/. Other microservices can register themselves to
Traefik by adding the following to their docker-compose.yml:
version: '3'
services:
microservice-name:
image: nginx
networks:
- workspace
- default
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik-public"
- "traefik.http.routers.microservice-name.rule=Host(`microservice-name.test.leviy.com`)"
networks:
traefik-public:
aliases:
- microservice-name.test.leviy.com
networks:
traefik-public:
external: trueServices that need to access the workspace for either reverse proxying or to access any of the services provided by it should be
put in the traefik-public network.
When started, Traefik will automatically detect this service and start routing
traffic to it.
To see it in action simply open http://microservice-name.test.leviy.com in a
browser.