Skip to content

Commit

Permalink
Merge pull request #2 from ABI-Deployment-Thesis/ruiar/add-traefik
Browse files Browse the repository at this point in the history
feat(traefik): add traefik
  • Loading branch information
ruigomes99 authored Aug 30, 2024
2 parents 3ab0537 + 19824c1 commit f5b84ea
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 19 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ jobs:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7

- name: Get latest Docker Compose version
id: get-compose-version
run: |
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
echo "COMPOSE_VERSION=${COMPOSE_VERSION}" >> $GITHUB_ENV
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
curl -L "https://github.com/docker/compose/releases/download/${{ env.COMPOSE_VERSION }}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
- name: Verify Docker Compose installation
run: docker-compose --version

- name: Run Development Docker Compose
run: docker-compose up -d
- name: Run Docker Compose
run: docker-compose up -d

- name: Run Traefik Docker Compose
run: docker-compose -f docker-compose.traefik.yaml up -d
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ docker-compose:

# Run Docker Compose in detached mode (background)
docker-compose-d:
docker-compose up --build -d
docker-compose up --build -d

# Run Docker Compose with Traefik to build and start services
docker-compose-traefik:
docker-compose -f docker-compose.traefik.yaml up --build

# Run Docker Compose with Traefik in detached mode (background)
docker-compose-traefik-d:
docker-compose -f docker-compose.traefik.yaml up --build -d
206 changes: 206 additions & 0 deletions docker-compose.traefik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
services:
# traefik service
traefik:
image: traefik@sha256:ec1a82940b8e00eaeef33fb4113aa1d1573b2ebb6440e10c023743fe96f08475 #v3.1.2
container_name: traefik
restart: always
command:
- "--api.insecure=true"
- "--providers.docker=true"
ports:
- "80:80"
- "8081:8080"
deploy:
resources:
limits:
cpus: "0.1"
memory: "128M"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- traefik

# MongoDB service
mongo_db:
image: mongo@sha256:3b120f4dd854327f26ec51511e109be61f8f21329a53efa3646aa9212b8266d3 #7.0.14-rc0
container_name: core_db
restart: always
ports:
- 27017:27017
labels:
- "traefik.enable=false"
deploy:
resources:
limits:
cpus: "0.2"
memory: "512M"
volumes:
- mongo_db:/data/db
networks:
- traefik

# RabbitMQ service
rabbitmq:
image: rabbitmq@sha256:611107e29cce05c2acd968325d5dcbde7e2fee404970f1ead75fdb22be2821b3 #3.13.6-management-alpine
container_name: rabbitmq
ports:
- "5672:5672"
- "15672:15672" # RabbitMQ Management UI
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
labels:
- "traefik.enable=false"
deploy:
resources:
limits:
cpus: "0.3"
memory: "256M"
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
timeout: 30s
retries: 10
volumes:
- rabbitmq_data:/var/lib/rabbitmq
networks:
- traefik

# Node Access Cotrol service
access_control:
image: ghcr.io/abi-deployment-thesis/access-control@sha256:ae3d2081f3cecf0eb9d5a5082e1b8fe1045b89946bfdad07a30e6d502c9f1ccb #v1.0.1
ports:
- 3001
environment:
HTTP_PORT: 3001
MONGO_DB_URL: mongodb://core_db:27017/AccessControl?retryWrites=true&w=majority
BCRYPT_SALT: 10
JWT_SESSION_PASS: password
labels:
- "traefik.http.routers.access_control.rule=Host(`access-control.localhost`)"
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: "256M"
depends_on:
- traefik
- mongo_db
networks:
- traefik

# Node Model Management service
model_management:
image: ghcr.io/abi-deployment-thesis/model-management@sha256:a87059ddb39e2a5704faeac22000f97c1011155686e7c4665b6f3a9ade9974ed #v1.0.0
ports:
- 3002
environment:
HTTP_PORT: 3002
GRPC_PORT: 50052
MONGO_DB_URL: mongodb://core_db:27017/ModelManagement?retryWrites=true&w=majority
JWT_SESSION_PASS: password
STORAGE_URL: /uploads
labels:
- "traefik.http.routers.model_management.rule=Host(`model-management.localhost`)"
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: "256M"
depends_on:
- traefik
- mongo_db
volumes:
- ./uploads:/uploads
networks:
- traefik

# Node Model Runner service
model_runner:
image: ghcr.io/abi-deployment-thesis/model-runner@sha256:f8512e4bd25a2361dbc3d84f924acc9880fbb2780212c7e2014bc0ec06ae4381 #v1.0.0
ports:
- 3003
environment:
HTTP_PORT: 3003
GRPC_PORT: 50053
GRPC_MODEL_MGMT_HOST: model_management:50052
HTTP_MODEL_MGMT_HOST: model_management:3002
GRPC_STABLE: "false"
RABBITMQ_HOST: rabbitmq
RABBITMQ_DOCKER_ENGINE_QUEUE: docker_queue
MONGO_DB_URL: mongodb://core_db:27017/ModelRunner?retryWrites=true&w=majority
JWT_SESSION_PASS: password
STORAGE_URL: /uploads
labels:
- "traefik.http.routers.model_runner.rule=Host(`model-runner.localhost`)"
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: "256M"
depends_on:
- traefik
- mongo_db
volumes:
- ./uploads:/uploads
networks:
- traefik

# Python Docker Engine service
docker_engine:
image: ghcr.io/abi-deployment-thesis/docker-engine@sha256:b28253088583ff1ca86e187172a6eb0743f584ed6fe270efff48f7e43b63c517 #v1.0.1
environment:
GRPC_MODEL_RUNNER_HOST: model_runner:50053
RABBITMQ_HOST: rabbitmq
RABBITMQ_QUEUE: docker_queue
DOCKER_HOST: tcp://host.docker.internal:2375
DOCKER_TAG: docker-engine
CONTAINER_PREFIX: run_
labels:
- "traefik.enable=false"
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: "256M"
depends_on:
rabbitmq:
condition: service_healthy
volumes:
- ./uploads:/uploads
networks:
- traefik

# Node ABI Deployment Webapp service
# Note: This is for testing purposes only, which is why it is not included in the Traefik network
abi-deployment-webapp:
image: ghcr.io/abi-deployment-thesis/abi-deployment-webapp@sha256:060fe774721c944d1c5752d501a077914da5b05c201414d2896d28a287078483 #v1.0.1
ports:
- 8080:80
environment:
MY_APP_ACCESS_CONTROL_BASE_URL: http://access-control.localhost
MY_APP_MODEL_MANAGEMENT_BASE_URL: http://model-management.localhost
MY_APP_MODEL_RUNNER_BASE_URL: http://model-runner.localhost
labels:
- "traefik.enable=false"
deploy:
resources:
limits:
cpus: "0.1"
memory: "256M"
depends_on:
- access_control
- model_management
- model_runner

volumes:
mongo_db: {}
rabbitmq_data:

networks:
traefik:
external: false
48 changes: 34 additions & 14 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.9'

services:
# MongoDB service
mongo_db:
Expand All @@ -8,6 +6,11 @@ services:
restart: always
ports:
- 27017:27017
deploy:
resources:
limits:
cpus: "0.2"
memory: "512M"
volumes:
- mongo_db:/data/db

Expand All @@ -21,12 +24,22 @@ services:
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
deploy:
resources:
limits:
cpus: "0.3"
memory: "256M"
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
timeout: 30s
retries: 10
volumes:
- rabbitmq_data:/var/lib/rabbitmq

# Node Access Cotrol service
access_control:
image: ghcr.io/abi-deployment-thesis/access-control@sha256:db81bc06a9d846def9d5a6cc94bc3e4e35bbb14824d71480572a8f63db61f5f6 #v1.0.0
image: ghcr.io/abi-deployment-thesis/access-control@sha256:ae3d2081f3cecf0eb9d5a5082e1b8fe1045b89946bfdad07a30e6d502c9f1ccb #v1.0.1
ports:
- 3001:3001
environment:
Expand All @@ -35,9 +48,10 @@ services:
BCRYPT_SALT: 10
JWT_SESSION_PASS: password
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
cpus: "0.1"
memory: "256M"
depends_on:
- mongo_db
Expand All @@ -54,9 +68,10 @@ services:
JWT_SESSION_PASS: password
STORAGE_URL: /uploads
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
cpus: "0.1"
memory: "256M"
depends_on:
- mongo_db
Expand All @@ -80,20 +95,19 @@ services:
JWT_SESSION_PASS: password
STORAGE_URL: /uploads
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
cpus: "0.1"
memory: "256M"
depends_on:
- mongo_db
- rabbitmq
- model_management
volumes:
- ./uploads:/uploads

# Python Docker Engine service
docker_engine:
image: ghcr.io/abi-deployment-thesis/docker-engine@sha256:240fdf5a717db5287eaf2f11ef5ecea3774737c137ce27f21ea14dfd7746d984 #v1.0.0
image: ghcr.io/abi-deployment-thesis/docker-engine@sha256:b28253088583ff1ca86e187172a6eb0743f584ed6fe270efff48f7e43b63c517 #v1.0.1
environment:
GRPC_MODEL_RUNNER_HOST: model_runner:50053
RABBITMQ_HOST: rabbitmq
Expand All @@ -102,25 +116,31 @@ services:
DOCKER_TAG: docker-engine
CONTAINER_PREFIX: run_
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
cpus: "0.1"
memory: "256M"
depends_on:
- rabbitmq
- model_runner
rabbitmq:
condition: service_healthy
volumes:
- ./uploads:/uploads

# Node ABI Deployment Webapp service
# Note: This is for testing purposes only
abi-deployment-webapp:
image: ghcr.io/abi-deployment-thesis/abi-deployment-webapp@sha256:4435d1d92cc5f602f037f81b411ac29dbd9aa5d3dc41ae6e4189702ebe6c080b #v1.0.0
image: ghcr.io/abi-deployment-thesis/abi-deployment-webapp@sha256:060fe774721c944d1c5752d501a077914da5b05c201414d2896d28a287078483 #v1.0.1
ports:
- 8080:80
environment:
MY_APP_ACCESS_CONTROL_BASE_URL: http://localhost:3001
MY_APP_MODEL_MANAGEMENT_BASE_URL: http://localhost:3002
MY_APP_MODEL_RUNNER_BASE_URL: http://localhost:3003
deploy:
resources:
limits:
cpus: "0.5"
cpus: "0.1"
memory: "256M"
depends_on:
- access_control
Expand Down

0 comments on commit f5b84ea

Please sign in to comment.