From 0a94ccbd0f69def8993ffc5fbad47939525ccd90 Mon Sep 17 00:00:00 2001 From: Ole Date: Tue, 22 Oct 2024 21:21:13 +0200 Subject: [PATCH 1/4] fix: cleanup docker compose file --- docker-compose.yml | 43 +++++++++++++++++++++++++++++++------------ postgres-init.sql | 11 +++++++++++ 2 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 postgres-init.sql diff --git a/docker-compose.yml b/docker-compose.yml index 6b44671..07a8be2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,17 @@ services: postgres: image: postgres:latest - ports: + ports: - "5434:5432" volumes: - db_data:/var/lib/postgresql/data + - ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql environment: - POSTGRES_PASSWORD=admin - POSTGRES_USER=admin mongodb: image: mongodb/mongodb-community-server:latest - ports: + ports: - "27017:27017" environment: - MONGO_INITDB_ROOT_USERNAME=admin @@ -22,14 +23,14 @@ services: - "1025:1025" usernator: build: ./usernator - ports: + ports: - "3001:3000" - "3004:3001" environment: - DB_HOST=postgres - DB_PORT=5434 - - DB_USERNAME=usernator - - DB_PASSWORD=usernator + - DB_USERNAME=admin + - DB_PASSWORD=admin - DB_DATABASE=usernator - SMTP_HOST=maildev - SMTP_PORT=1025 @@ -45,7 +46,7 @@ services: context: ./authy args: - ARCH=aarch64 - ports: + ports: - "3002:3000" environment: - JWT_SECRET=secret @@ -59,13 +60,13 @@ services: context: ./tasky args: - ARCH=aarch64 - ports: + ports: - "3005:3000" - "3006:3001" environment: - DB_NAME=tasky - - DB_USERNAME=tasky - - DB_PASSWORD=tasky + - DB_USERNAME=admin + - DB_PASSWORD=admin - DB_HOST=postgres:5432 - USERNATOR_GRPC=http://usernator:3001 - MONGO_HOST="mongodb:27017" @@ -81,8 +82,8 @@ services: ports: - "3003:8000" environment: - - DATABASE_USERNAME=executor - - DATABASE_PASSWORD=executor + - DATABASE_USERNAME=admin + - DATABASE_PASSWORD=admin - DATABASE_HOST=postgres - DATABASE_PORT=5432 - DATABASE_NAME=executor @@ -102,5 +103,23 @@ services: - BACKEND_URL=http://executor:8000 depends_on: - executor + + + web: + build: + context: web/ + dockerfile: Dockerfile + ports: + - "4000:3000" + environment: + - API_URL=http://localhost:3002 + - EXECUTOR_UI_URL=http://localhost:3007 + depends_on: + - authy + - executor_ui + - tasky + - usernator + + volumes: - db_data: \ No newline at end of file + db_data: diff --git a/postgres-init.sql b/postgres-init.sql new file mode 100644 index 0000000..9ef633f --- /dev/null +++ b/postgres-init.sql @@ -0,0 +1,11 @@ +CREATE USER usernator WITH PASSWORD 'usernator'; +CREATE DATABASE usernator; +GRANT ALL PRIVILEGES ON DATABASE usernator TO usernator; + +CREATE USER tasky WITH PASSWORD 'tasky'; +CREATE DATABASE tasky; +GRANT ALL PRIVILEGES ON DATABASE tasky TO tasky; + +CREATE USER executor WITH PASSWORD 'executor'; +CREATE DATABASE executor; +GRANT ALL PRIVILEGES ON DATABASE executor TO executor; From 11c543a2c57e9c558d38f269b28ddff4340d8d84 Mon Sep 17 00:00:00 2001 From: Ole Date: Tue, 22 Oct 2024 21:25:44 +0200 Subject: [PATCH 2/4] fix: don't transfer build caches etc to docker context --- authy/.dockerignore | 1 + tasky/.dockerignore | 3 ++- web/.dockerignore | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 authy/.dockerignore create mode 100644 web/.dockerignore diff --git a/authy/.dockerignore b/authy/.dockerignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/authy/.dockerignore @@ -0,0 +1 @@ +target/ diff --git a/tasky/.dockerignore b/tasky/.dockerignore index 2eea525..b7f7b51 100644 --- a/tasky/.dockerignore +++ b/tasky/.dockerignore @@ -1 +1,2 @@ -.env \ No newline at end of file +.env +target/ diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 0000000..57ff971 --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +.next/ From 0a74bd04eb7f3ae8a5f93c8dc75b49d0f6480395 Mon Sep 17 00:00:00 2001 From: Ole Date: Tue, 22 Oct 2024 21:34:39 +0200 Subject: [PATCH 3/4] refactor: fix Dockerfile capitalization warning --- tasky/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasky/Dockerfile b/tasky/Dockerfile index f5811a2..69cf4ea 100644 --- a/tasky/Dockerfile +++ b/tasky/Dockerfile @@ -14,7 +14,7 @@ RUN rm ./target/release/deps/tasky* ENV IS_DOCKER="true" RUN cargo build --release -FROM busybox:1.35.0-uclibc as busybox +FROM busybox:1.35.0-uclibc AS busybox FROM gcr.io/distroless/cc-debian12 ARG ARCH=x86_64 From 010a910c7f43864c22c5eec9b6f51a6f5dc9e1ad Mon Sep 17 00:00:00 2001 From: Ole Date: Tue, 22 Oct 2024 23:46:10 +0200 Subject: [PATCH 4/4] [broken] fix: load correct env vars in web service --- docker-compose.yml | 40 +++++++++++++++---- postgres-init.sql | 5 +++ web/components/solution/ExecutorUIDisplay.tsx | 7 +++- web/next.config.mjs | 6 ++- web/service/ApiService.ts | 17 +++++--- 5 files changed, 58 insertions(+), 17 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 07a8be2..427b5ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: - "5434:5432" volumes: - db_data:/var/lib/postgresql/data - - ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql + - ./postgres-init.sql:/docker-entrypoint-initdb.d/init.sql environment: - POSTGRES_PASSWORD=admin - POSTGRES_USER=admin @@ -29,8 +29,8 @@ services: environment: - DB_HOST=postgres - DB_PORT=5434 - - DB_USERNAME=admin - - DB_PASSWORD=admin + - DB_USERNAME=usernator + - DB_PASSWORD=usernator - DB_DATABASE=usernator - SMTP_HOST=maildev - SMTP_PORT=1025 @@ -41,6 +41,14 @@ services: depends_on: - postgres - maildev + restart: on-failure:3 + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + authy: build: context: ./authy @@ -55,6 +63,14 @@ services: depends_on: - usernator - tasky + restart: on-failure:3 + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + tasky: build: context: ./tasky @@ -65,8 +81,8 @@ services: - "3006:3001" environment: - DB_NAME=tasky - - DB_USERNAME=admin - - DB_PASSWORD=admin + - DB_USERNAME=usernator + - DB_PASSWORD=usernator - DB_HOST=postgres:5432 - USERNATOR_GRPC=http://usernator:3001 - MONGO_HOST="mongodb:27017" @@ -77,13 +93,21 @@ services: depends_on: - usernator - postgres + restart: on-failure:3 + deploy: + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 3 + window: 120s + executor: build: ./executor ports: - "3003:8000" environment: - - DATABASE_USERNAME=admin - - DATABASE_PASSWORD=admin + - DATABASE_USERNAME=executor + - DATABASE_PASSWORD=executor - DATABASE_HOST=postgres - DATABASE_PORT=5432 - DATABASE_NAME=executor @@ -110,7 +134,7 @@ services: context: web/ dockerfile: Dockerfile ports: - - "4000:3000" + - "3000:3000" environment: - API_URL=http://localhost:3002 - EXECUTOR_UI_URL=http://localhost:3007 diff --git a/postgres-init.sql b/postgres-init.sql index 9ef633f..f66702a 100644 --- a/postgres-init.sql +++ b/postgres-init.sql @@ -9,3 +9,8 @@ GRANT ALL PRIVILEGES ON DATABASE tasky TO tasky; CREATE USER executor WITH PASSWORD 'executor'; CREATE DATABASE executor; GRANT ALL PRIVILEGES ON DATABASE executor TO executor; + + +ALTER USER usernator WITH SUPERUSER; +ALTER USER tasky WITH SUPERUSER; +ALTER USER executor WITH SUPERUSER; diff --git a/web/components/solution/ExecutorUIDisplay.tsx b/web/components/solution/ExecutorUIDisplay.tsx index 81e4d89..cf151a3 100644 --- a/web/components/solution/ExecutorUIDisplay.tsx +++ b/web/components/solution/ExecutorUIDisplay.tsx @@ -1,4 +1,5 @@ import { Modal } from "@mantine/core"; +import getConfig from "next/config"; export interface ExecutorUIDisplayProps { jobId: string; @@ -6,8 +7,10 @@ export interface ExecutorUIDisplayProps { } const ExecutorUIDisplay = ({ jobId, onClose }: ExecutorUIDisplayProps) => { - const apiUrl = process.env.NODE_ENV === "production" ? "https://executor.code-canvas.app" : "http://localhost:3007"; - + const apiUrl = + getConfig().publicRuntimeConfig.EXECUTOR_UI_URL === "" + ? "http://localhost:3008" + : getConfig().publicRuntimeConfig.EXECUTOR_UI_URL; return (