From bc419872ece3fc3849a805573050869db44840ec Mon Sep 17 00:00:00 2001 From: Kian Cross Date: Wed, 6 Jan 2021 18:11:27 +0000 Subject: [PATCH] Updat Podman config (#115) --- Makefile.docker | 1 + Makefile.podman | 30 +++++++--- configs/kube-deployment.yml | 111 ++++++++++++++++++++++++++++-------- 3 files changed, 111 insertions(+), 31 deletions(-) diff --git a/Makefile.docker b/Makefile.docker index 98234d90..37fc3db7 100644 --- a/Makefile.docker +++ b/Makefile.docker @@ -11,6 +11,7 @@ DOCKER_COMPOSE_COMMAND:=docker-compose \ .PHONY: start start: + yarn install $(DOCKER_COMPOSE_COMMAND) up --build -d .PHONY: stop diff --git a/Makefile.podman b/Makefile.podman index ead04f01..3b34e5c7 100644 --- a/Makefile.podman +++ b/Makefile.podman @@ -11,7 +11,7 @@ POD_NAME:=unifed PODMAN_COMMAND:=podman .PHONY: start -start: unifed-backend unifed-frontend reset +start: yarn-install unifed-backend-internal unifed-backend-federation unifed-frontend reset @# Podman doesn't support passing an environment file :( $(PODMAN_COMMAND) play kube <(source ./$(CONFIG_PATH); \ variable_names=$$(grep -v '^\s*#.*$$' $(CONFIG_PATH) | grep -v '^\s*$$' | cut -f1 -d=); \ @@ -31,13 +31,27 @@ stop: .PHONY: logs logs: - $(PODMAN_COMMAND) logs $$($(PODMAN_COMMAND) ps | \ - grep "localhost/unifed-backend.*unifed-backend" | awk '{print $$1}') - -.PHONY: unifed-backend -unifed-backend: - $(PODMAN_COMMAND) build -f Dockerfile.backend -t unifed-backend . + @$(PODMAN_COMMAND) logs -n $$($(PODMAN_COMMAND) ps | \ + grep "localhost/unifed-.*unifed-.*" | awk '{print $$1}') | \ + awk '{ \ + if ($$1 == "unifed-frontend") {printf "\033[0;31m"}; \ + if ($$1 == "unifed-backend-internal") {printf "\033[0;34m"}; \ + if ($$1 == "unifed-backend-federation") {printf "\033[0;32m"}; \ + printf $$1 "\033[0m"; $$1 = ""; print $$0 \ + }' + +.PHONY: yarn-install +yarn-install: + yarn install + +.PHONY: unifed-backend-internal +unifed-backend-internal: + $(PODMAN_COMMAND) build -f configs/backend-internal.Dockerfile -t unifed-backend-internal . + +.PHONY: unifed-backend-federation +unifed-backend-federation: + $(PODMAN_COMMAND) build -f configs/backend-federation.Dockerfile -t unifed-backend-federation . .PHONY: unifed-frontend unifed-frontend: - $(PODMAN_COMMAND) build -f Dockerfile.frontend -t unifed-frontend . + $(PODMAN_COMMAND) build -f configs/frontend.Dockerfile -t unifed-frontend . diff --git a/configs/kube-deployment.yml b/configs/kube-deployment.yml index 61579d28..6da14588 100644 --- a/configs/kube-deployment.yml +++ b/configs/kube-deployment.yml @@ -15,7 +15,8 @@ spec: hostAliases: - ip: "127.0.0.1" hostnames: - - "backend" + - "backend-internal" + - "backend-federation" - "frontend" - "mongo" @@ -30,8 +31,6 @@ spec: value: ${MONGO_ADMIN_USERNAME} - name: MONGO_INITDB_ROOT_PASSWORD value: ${MONGO_ADMIN_PASSWORD} - - name: MONGO_INITDB_DATABASE - value: ${MONGO_DATABASE} - name: nginx image: docker.io/corfr/nginx-dnsmasq @@ -61,45 +60,91 @@ spec: - name: ME_CONFIG_BASICAUTH_PASSWORD value: ${MONGO_INSPECT_PASSWORD} - - name: backend - image: localhost/unifed-backend + - name: backend-internal + image: localhost/unifed-backend-internal volumeMounts: - - mountPath: /usr/src/unifed/packages/backend/src - name: backend + - mountPath: /usr/src/unifed/packages/backend-internal-server/src + name: backend-internal-server + - mountPath: /usr/src/unifed/packages/backend-core/src + name: backend-core + - mountPath: /usr/src/unifed/packages/backend-federation-client/src + name: backend-federation-client + - mountPath: /usr/src/unifed/packages/shared/src + name: shared env: - - name: SMTP_USERNAME + - name: UNIFED_SMTP_USERNAME value: ${SMTP_USERNAME} - - name: SMTP_PASSWORD + - name: UNIFED_SMTP_PASSWORD value: ${SMTP_PASSWORD} - - name: SMTP_HOST + - name: UNIFED_SMTP_HOST value: ${SMTP_HOST} - - name: SMTP_PORT + - name: UNIFED_SMTP_PORT value: ${SMTP_PORT} - - name: MONGO_HOSTNAME + - name: UNIFED_MONGO_HOSTNAME value: mongo - - name: MONGO_PORT + - name: UNIFED_MONGO_PORT value: 27017 - - name: MONGO_DATABASE - value: ${MONGO_DATABASE} - - name: MONGO_USERNAME + - name: UNIFED_MONGO_DATABASE + value: unifed-internal + - name: UNIFED_MONGO_USERNAME value: user - - name: MONGO_PASSWORD + - name: UNIFED_MONGO_PASSWORD value: pass - - name: JWT_SECRET + - name: UNIFED_JWT_SECRET value: ${JWT_SECRET} - - name: SITE_HOST + - name: UNIFED_SITE_HOST value: ${SITE_HOST} - - name: SITE_PROTOCOL + - name: UNIFED_SITE_PROTOCOL value: ${SITE_PROTOCOL} - - name: APPLICATION_NAME + - name: UNIFED_APPLICATION_NAME value: ${APPLICATION_NAME} + - name: UNIFED_LOGGING_LEVEL + value: ${LOGGING_LEVEL} + - name: UNIFED_SERVER_PORT + value: 7080 + - name: NODE_ENV + value: ${NODE_ENV} + - name: backend-federation + image: localhost/unifed-backend-federation + volumeMounts: + - mountPath: /usr/src/unifed/packages/backend-federation-server/src + name: backend-federation-server + - mountPath: /usr/src/unifed/packages/backend-core/src + name: backend-core + - mountPath: /usr/src/unifed/packages/shared/src + name: shared + env: + - name: UNIFED_MONGO_HOSTNAME + value: mongo + - name: UNIFED_MONGO_PORT + value: 27017 + - name: UNIFED_MONGO_DATABASE + value: unifed-federation + - name: UNIFED_MONGO_USERNAME + value: user + - name: UNIFED_MONGO_PASSWORD + value: pass + - name: UNIFED_SITE_HOST + value: ${SITE_HOST} + - name: UNIFED_SITE_PROTOCOL + value: ${SITE_PROTOCOL} + - name: UNIFED_APPLICATION_NAME + value: ${APPLICATION_NAME} + - name: UNIFED_LOGGING_LEVEL + value: ${LOGGING_LEVEL} + - name: UNIFED_SERVER_PORT + value: 7081 + - name: NODE_ENV + value: ${NODE_ENV} - name: frontend image: localhost/unifed-frontend volumeMounts: - mountPath: /usr/src/unifed/packages/frontend/src name: frontend + - mountPath: /usr/src/unifed/packages/shared/src + name: shared volumes: - name: frontend @@ -107,9 +152,29 @@ spec: path: ./packages/frontend/src type: Directory - - name: backend + - name: shared + hostPath: + path: ./packages/shared/src + type: Directory + + - name: backend-internal-server + hostpath: + path: ./packages/backend-internal-server/src + type: Directory + + - name: backend-federation-server + hostpath: + path: ./packages/backend-federation-server/src + type: Directory + + - name: backend-federation-client + hostpath: + path: ./packages/backend-federation-client/src + type: Directory + + - name: backend-core hostpath: - path: ./packages/backend/src + path: ./packages/backend-core/src type: Directory - name: nginx-conf