The source, configs and deployments of the DockerCon 2022 talk all in one place.
MIT License
This repo contains all the source, configurations, deployment tweaks that were presented as a talk to DockerCon 2022.
To run the entire stack all in one place, just head to the entire-platform
directory and run docker-compose up -d
.
The design of the platform is simple and straightforward, containing three apps that are all web-apps listening on a HTTP port.
Service2 can also contact Service3 for a query in which it caches for future reference. The invalidation of the cache is nothing special; it expires after 10 minutes (configurable).
The third service is a sample CRUD app that is talking to PostgreSQL for its processing.
Here's an overview of the system:
Each service has its own directory in here, but in real-life applications, each of the following directories would have their own repository:
Also, the traefik
directory contains the gateway/reverse-proxy and it's
generally just for the ease of access, and not necessarily a service for its
own.
Additionally, for ease of access, also the entire-platform
directory is
placed next to others, but, again, in real life scenarios, it would have had
its own repository.
IMPORTANT NOTE: Don't forget to update your docker-compose binary to v2.
You will need to add these two entries to your /etc/hosts
file, regardless of
which approach you choose:
127.0.0.1 svc.dockercon2022.com
127.0.0.1 svc-crud.dockercon2022.com
This is to tell our local DNS resolver to send the traffics of the mentioned
domains to the local machine (and ultimately to the traefik
service).
individual-services
directory.traefik
directory and bringdocker-compose up -d
. Now you're able to head to this link to seeserviceN
directory where N
is the number of the servicedocker-compose up -d
).Head to the entire-platform
directory and bring up the apps, as easy as
docker-compose up -d
.
These are the URLs you can access, whichever approach you choose:
Service | Endpoint | Considerations |
---|---|---|
service1 | http://svc.dockercon2022.com/v1/ | |
service2 | http://svc.dockercon2022.com/v2/ | |
service2-copy | http://svc.dockercon2022.com/v3/ | Only entire-platform
|
service3 | http://svc-crud.dockercon2022.com/v1/ |
The talk consists of three main components:
docker-compose.yml
file. The example for both approachesDockerfile
inside service1
directorycompose-svc2.yml
file inside entire-platform
env_file
directive in your docker-compose.yml
files because otherwiseDockerfile
but because of the fact that the operation team mightdocker-compose.yml
forCOMPOSE_FILE
to specify which files you would like to include for a-f compose-file.yml
from yourrestart
is a very good directive to have in your docker-compose, don'textra_hosts
/etc/hosts
file to forward the traffic from inside asvc2
& svc2-copy
in the entire-platform
directory for differenttmux
and -d
flag when you want to bring up your application. YouCOMPOSE_FILE
variable matters; try to place the definitions.env
insideentire-platform
directory for an example.env_file
in your compose files for different services,.env
file. That way, whenever you wantCOMPOSE_PROJECT_NAME
to group your stack under a unified hierarchy.As a sample, the AWS CloudFormation sample template of how the real life stack
would be deployed has been placed inside the source code. In order to not
pollute the config, only a single service has a cloud-formation:
individual-services/service1/cloudformation-templates/service1-dev.yml
Also, the complete stack CloudFormation template has also been placed inside
the following directory:
entire-platform/cloudformation-templates/stack-dev.yml