From 7eaa6568dc31753f4ab3ff78e48163b5da54a291 Mon Sep 17 00:00:00 2001
From: Philipp Borucki
Date: Tue, 9 Jan 2024 23:58:38 +0100
Subject: [PATCH] refactor(docker): remove load balancer
---
.github/workflows/docker-push-registry.yml | 2 +-
docker-compose.dev.native.yml | 96 -------------------
docker-compose.dev.yml | 87 +++++++++++------
docker-compose.native.yml | 55 -----------
docker-compose.push.yml | 1 -
docker-compose.yml | 78 ++++++++++-----
.../config/proxyConfig.docker.native.yaml | 27 ------
.../config/proxyConfig.docker.yaml | 4 +-
8 files changed, 119 insertions(+), 231 deletions(-)
delete mode 100644 docker-compose.dev.native.yml
delete mode 100644 docker-compose.native.yml
delete mode 100644 src/http-proxy-service/config/proxyConfig.docker.native.yaml
diff --git a/.github/workflows/docker-push-registry.yml b/.github/workflows/docker-push-registry.yml
index da1c2abd..634beeaf 100644
--- a/.github/workflows/docker-push-registry.yml
+++ b/.github/workflows/docker-push-registry.yml
@@ -31,7 +31,7 @@ jobs:
- name: Check and set release version
run: |
- echo "RELEASE_VERSION=$(git tag -l --format='%(contents:subject)'${GITHUB_REF#refs/*/})" >> $GITHUB_ENV
+ echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "RELEASE_VERSION: '$RELEASE_VERSION'"
- if: ${{ env.RELEASE_VERSION != '' && contains(github.ref, 'main') }}
diff --git a/docker-compose.dev.native.yml b/docker-compose.dev.native.yml
deleted file mode 100644
index deccdda0..00000000
--- a/docker-compose.dev.native.yml
+++ /dev/null
@@ -1,96 +0,0 @@
-version: "3.8"
-
-services:
- proxy:
- build:
- context: ./
- dockerfile: ./src/http-proxy-service/Dockerfile
- environment:
- - PROXY_CONFIG_PATH=./config/proxyConfig.docker.native.yaml
- volumes:
- - ./src/http-proxy-service/config:/config
- ports:
- - "8080:8080"
- depends_on:
- - web
-
- web:
- build:
- context: ./
- dockerfile: ./src/web-service/Dockerfile
- ports:
- - "3000:3000"
- depends_on:
- - products
- - shoppinglists
- - users
-
- products:
- build:
- context: ./
- dockerfile: ./src/product-service/Dockerfile
- ports:
- - "3003:3003"
- - "50053:50053"
- env_file:
- - ./src/product-service/.env
- depends_on:
- database:
- condition: service_healthy
-
- users:
- build:
- context: ./
- dockerfile: ./src/user-service/Dockerfile
- ports:
- - "3001:3001"
- - "50051:50051"
- env_file:
- - ./src/user-service/.env
- volumes:
- - ./src/user-service/privateKey.pem:/privateKey.pem
- depends_on:
- database:
- condition: service_healthy
-
- shoppinglists:
- build:
- context: ./
- dockerfile: ./src/shoppinglist-service/Dockerfile
- ports:
- - "3002:3002"
- env_file:
- - ./src/shoppinglist-service/.env
- depends_on:
- database:
- condition: service_healthy
-
- database:
- image: rqlite/rqlite:8.15.0
- ports:
- - "4001:4001"
- command: ["-node-id", "1", "-auth", "/run/secrets/config.json", "-http-adv-addr", "database:4001"]
- configs:
- - source: database
- target: config.json
- healthcheck:
- test: ["CMD-SHELL", "wget -q --spider http://localhost:4001/readyz || exit 1"]
- interval: 5s
- retries: 5
- start_period: 30s
- start_interval: 1s
-
-configs:
- database:
- content: |
- [
- {
- "username": "user",
- "password": "password",
- "perms": [ "all" ]
- },
- {
- "username": "*",
- "perms": ["ready"]
- }
- ]
\ No newline at end of file
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index b092552f..31406252 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -1,3 +1,5 @@
+version: "3.8"
+
services:
proxy:
build:
@@ -5,59 +7,90 @@ services:
dockerfile: ./src/http-proxy-service/Dockerfile
environment:
- PROXY_CONFIG_PATH=./config/proxyConfig.docker.yaml
+ volumes:
+ - ./src/http-proxy-service/config:/config
ports:
- - 8080:8080
+ - "8080:8080"
depends_on:
- - lbweb
- networks:
- - dev-network
+ - web
- lbweb:
+ web:
build:
context: ./
- dockerfile: ./src/load-balancer-service/Dockerfile
- environment:
- - LOAD_BALANCER_CONFIG_PATH=./config/config.web-service.dev.yaml
+ dockerfile: ./src/web-service/Dockerfile
ports:
- - 3000:3000
- volumes:
- - /var/run/docker.sock:/var/run/docker.sock
+ - "3000:3000"
depends_on:
- products
- shoppinglists
- users
- networks:
- - dev-network
products:
build:
context: ./
dockerfile: ./src/product-service/Dockerfile
ports:
- - 3003:3003
- - 50053:50053
- networks:
- - dev-network
+ - "3003:3003"
+ - "50053:50053"
+ env_file:
+ - ./src/product-service/.env
+ depends_on:
+ database:
+ condition: service_healthy
users:
build:
context: ./
dockerfile: ./src/user-service/Dockerfile
ports:
- - 3001:3001
- - 50051:50051
- networks:
- - dev-network
+ - "3001:3001"
+ - "50051:50051"
+ env_file:
+ - ./src/user-service/.env
+ volumes:
+ - ./src/user-service/privateKey.pem:/privateKey.pem
+ depends_on:
+ database:
+ condition: service_healthy
shoppinglists:
build:
context: ./
dockerfile: ./src/shoppinglist-service/Dockerfile
ports:
- - 3002:3002
- networks:
- - dev-network
+ - "3002:3002"
+ env_file:
+ - ./src/shoppinglist-service/.env
+ depends_on:
+ database:
+ condition: service_healthy
+
+ database:
+ image: rqlite/rqlite:8.15.0
+ ports:
+ - "4001:4001"
+ command: ["-node-id", "1", "-auth", "/run/secrets/config.json", "-http-adv-addr", "database:4001"]
+ configs:
+ - source: database
+ target: config.json
+ healthcheck:
+ test: ["CMD-SHELL", "wget -q --spider http://localhost:4001/readyz || exit 1"]
+ interval: 5s
+ retries: 5
+ start_period: 30s
+ start_interval: 1s
-networks:
- dev-network:
- name: dev-network
\ No newline at end of file
+configs:
+ database:
+ content: |
+ [
+ {
+ "username": "user",
+ "password": "password",
+ "perms": [ "all" ]
+ },
+ {
+ "username": "*",
+ "perms": ["ready"]
+ }
+ ]
\ No newline at end of file
diff --git a/docker-compose.native.yml b/docker-compose.native.yml
deleted file mode 100644
index 71cf7958..00000000
--- a/docker-compose.native.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-services:
- proxy:
- image: onyxmoon/pw-http-proxy-service:latest
- environment:
- - PROXY_CONFIG_PATH=./config/proxyConfig.docker.native.yaml
- ports:
- - 8080:8080
- - 443:8443
- depends_on:
- - web
- networks:
- - public
- - internal
-
- web:
- image: onyxmoon/pw-web-service:latest
- ports:
- - 3000:3000
- depends_on:
- - products
- - shoppinglists
- - users
- networks:
- - internal
-
- products:
- image: onyxmoon/pw-product-service:latest
- ports:
- - 3003:3003
- - 50053:50053
- networks:
- - internal
-
- users:
- image: onyxmoon/pw-user-service:latest
- ports:
- - 3001:3001
- - 50051:50051
- networks:
- - internal
-
- shoppinglists:
- image: onyxmoon/pw-shoppinglist-service:latest
- ports:
- - 3002:3002
- networks:
- - internal
-
-
-networks:
- public:
- driver: bridge
- internal:
- driver: bridge
- internal: true
\ No newline at end of file
diff --git a/docker-compose.push.yml b/docker-compose.push.yml
index e8da0625..26630919 100644
--- a/docker-compose.push.yml
+++ b/docker-compose.push.yml
@@ -17,7 +17,6 @@ services:
dockerfile: ./src/web-service/Dockerfile
image: onyxmoon/pw-web-service:${RELEASE_VERSION:-latest}
-
products:
build:
context: ./
diff --git a/docker-compose.yml b/docker-compose.yml
index 906f8ea4..29f043d7 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,30 +1,24 @@
+version: "3.8"
+
services:
proxy:
- build:
- context: ./
- dockerfile: ./src/http-proxy-service/Dockerfile
image: onyxmoon/pw-http-proxy-service:latest
environment:
- PROXY_CONFIG_PATH=./config/proxyConfig.docker.yaml
+ volumes:
+ - ./src/http-proxy-service/config:/config
ports:
- 8080:8080
depends_on:
- - load-balancer-web
+ - web
networks:
- public
- internal
- load-balancer-web:
- build:
- context: ./
- dockerfile: ./src/load-balancer-service/Dockerfile
- image: onyxmoon/pw-load-balancer-service:latest
- environment:
- - LOAD_BALANCER_CONFIG_PATH=./config/config.web-service.yaml
+ web:
+ image: onyxmoon/pw-web-service:latest
ports:
- 3000:3000
- volumes:
- - /var/run/docker.sock:/var/run/docker.sock
depends_on:
- products
- shoppinglists
@@ -33,36 +27,76 @@ services:
- internal
products:
- build:
- context: ./
- dockerfile: ./src/product-service/Dockerfile
image: onyxmoon/pw-product-service:latest
+ env_file:
+ - ./src/product-service/.env
ports:
- 3003:3003
- 50053:50053
networks:
- internal
+ depends_on:
+ database:
+ condition: service_healthy
users:
- build:
- context: ./
- dockerfile: ./src/user-service/Dockerfile
image: onyxmoon/pw-user-service:latest
+ env_file:
+ - ./src/user-service/.env
ports:
- 3001:3001
- 50051:50051
+ volumes:
+ - ./src/user-service/privateKey.pem:/privateKey.pem
networks:
- internal
+ depends_on:
+ database:
+ condition: service_healthy
shoppinglists:
- build:
- context: ./
- dockerfile: ./src/shoppinglist-service/Dockerfile
image: onyxmoon/pw-shoppinglist-service:latest
+ env_file:
+ - ./src/shoppinglist-service/.env
ports:
- 3002:3002
networks:
- internal
+ depends_on:
+ database:
+ condition: service_healthy
+
+ database:
+ image: rqlite/rqlite:8.15.0
+ ports:
+ - "4001:4001"
+ command: [ "-node-id", "1", "-auth", "/run/secrets/config.json", "-http-adv-addr", "database:4001" ]
+ configs:
+ - source: database
+ target: config.json
+ networks:
+ - internal
+ healthcheck:
+ test: [ "CMD-SHELL", "wget -q --spider http://localhost:4001/readyz || exit 1" ]
+ interval: 5s
+ retries: 5
+ start_period: 30s
+ start_interval: 1s
+
+ configs:
+ database:
+ content: |
+ [
+ {
+ "username": "user",
+ "password": "password",
+ "perms": [ "all" ]
+ },
+ {
+ "username": "*",
+ "perms": ["ready"]
+ }
+ ]
networks:
diff --git a/src/http-proxy-service/config/proxyConfig.docker.native.yaml b/src/http-proxy-service/config/proxyConfig.docker.native.yaml
deleted file mode 100644
index e860074a..00000000
--- a/src/http-proxy-service/config/proxyConfig.docker.native.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-proxy:
- listenAddress: 0.0.0.0:8080
- proxyRoutes:
- - name: User Service (User Info)
- context: /api/v1/user
- target: http://users:3001/api/v1/user
- - name: User Service (Login)
- context: /api/v1/authentication/login
- target: http://users:3001/api/v1/authentication/login
- - name: User Service (Registration)
- context: /api/v1/authentication/register
- target: http://users:3001/api/v1/authentication/register
- - name: Shoppinglist Service (Lists)
- context: /api/v1/shoppinglist
- target: http://shoppinglists:3002/api/v1/shoppinglist
- - name: Shoppinglist Service (Entries)
- context: /api/v1/shoppinglistentries
- target: http://shoppinglists:3002/api/v1/shoppinglistentries
- - name: Product Service (Products)
- context: /api/v1/product
- target: http://products:3003/api/v1/product
- - name: Product Service (Prices)
- context: /api/v1/price
- target: http://products:3003/api/v1/price
- - name: Web Service
- context: /
- target: http://web:3000
\ No newline at end of file
diff --git a/src/http-proxy-service/config/proxyConfig.docker.yaml b/src/http-proxy-service/config/proxyConfig.docker.yaml
index 864e5e71..e860074a 100644
--- a/src/http-proxy-service/config/proxyConfig.docker.yaml
+++ b/src/http-proxy-service/config/proxyConfig.docker.yaml
@@ -22,6 +22,6 @@ proxy:
- name: Product Service (Prices)
context: /api/v1/price
target: http://products:3003/api/v1/price
- - name: Load Balancer Web Service
+ - name: Web Service
context: /
- target: http://lbweb:3000
\ No newline at end of file
+ target: http://web:3000
\ No newline at end of file