From 306d29d870e1c0592b75c51c001c9fe2410645b9 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 22 Mar 2021 16:18:29 +0000 Subject: [PATCH] redis, tidy ups --- hosting/docker-compose.dev.yaml | 58 +++++++++---------------- hosting/envoy.dev.yaml | 66 ++++++++--------------------- hosting/hosting.properties | 1 + packages/cli/src/hosting/makeEnv.js | 1 + packages/server/dev.env | 1 + packages/worker/package.json | 3 +- packages/worker/src/db/index.js | 5 +-- 7 files changed, 42 insertions(+), 93 deletions(-) diff --git a/hosting/docker-compose.dev.yaml b/hosting/docker-compose.dev.yaml index 8794b9fdd5..8f6c5b504d 100644 --- a/hosting/docker-compose.dev.yaml +++ b/hosting/docker-compose.dev.yaml @@ -3,45 +3,8 @@ version: "3" # optional ports are specified throughout for more advanced use cases. services: - # app-service: - # restart: always - # #build: ./build/server - # image: budibase/budibase-apps - # ports: - # - "${APP_PORT}:4002" - # environment: - # SELF_HOSTED: 1 - # CLOUD: 1 - # COUCH_DB_URL: http://${COUCH_DB_USER}:${COUCH_DB_PASSWORD}@couchdb-service:5984 - # WORKER_URL: http://worker-service:4003 - # HOSTING_KEY: ${HOSTING_KEY} - # BUDIBASE_ENVIRONMENT: ${BUDIBASE_ENVIRONMENT} - # PORT: 4002 - # JWT_SECRET: ${JWT_SECRET} - # depends_on: - # - worker-service - - # worker-service: - # restart: always - # #build: ./build/worker - # image: budibase/budibase-worker - # ports: - # - "${WORKER_PORT}:4003" - # environment: - # SELF_HOSTED: 1, - # PORT: 4003 - # MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY} - # MINIO_SECRET_KEY: ${MINIO_SECRET_KEY} - # RAW_MINIO_URL: http://minio-service:9000 - # COUCH_DB_USERNAME: ${COUCH_DB_USER} - # COUCH_DB_PASSWORD: ${COUCH_DB_PASSWORD} - # COUCH_DB_URL: http://${COUCH_DB_USER}:${COUCH_DB_PASSWORD}@couchdb-service:5984 - # SELF_HOST_KEY: ${HOSTING_KEY} - # depends_on: - # - minio-service - # - couch-init - minio-service: + container_name: budi-minio-dev restart: always image: minio/minio volumes: @@ -60,6 +23,7 @@ services: retries: 3 proxy-service: + container_name: budi-envoy-dev restart: always image: envoyproxy/envoy:v1.16-latest volumes: @@ -72,6 +36,7 @@ services: - couchdb-service couchdb-service: + container_name: budi-couchdb-dev restart: always image: apache/couchdb:3.0 environment: @@ -83,7 +48,7 @@ services: #- "9100:9100" volumes: - couchdb_data:/opt/couchdb/data - + couch-init: image: curlimages/curl environment: @@ -92,8 +57,23 @@ services: - couchdb-service command: ["sh","-c","sleep 10 && $${PUT_CALL}/_users && $${PUT_CALL}/_replicator; fg;"] + redis-service: + container_name: budi-redis-dev + restart: always + image: redis + environment: + - COUCHDB_PASSWORD=${COUCH_DB_PASSWORD} + - COUCHDB_USER=${COUCH_DB_USER} + ports: + - "${REDIS_PORT}:6379" + volumes: + - redis_data:/data + + volumes: couchdb_data: driver: local minio_data: driver: local + redis_data: + driver: local diff --git a/hosting/envoy.dev.yaml b/hosting/envoy.dev.yaml index ef658c6c3a..e12bc2c0e0 100644 --- a/hosting/envoy.dev.yaml +++ b/hosting/envoy.dev.yaml @@ -16,31 +16,16 @@ static_resources: - name: local_services domains: ["*"] routes: - # - match: { prefix: "/app/" } - # route: - # cluster: app-service - # prefix_rewrite: "/" - - # # special case for presenting our static self hosting page - # - match: { path: "/" } - # route: - # cluster: app-service - - # special case for when API requests are made, can just forward, not to minio - # - match: { prefix: "/api/" } - # route: - # cluster: app-service - - # - match: { prefix: "/worker/" } - # route: - # cluster: worker-service - # prefix_rewrite: "/" - - match: { prefix: "/db/" } route: cluster: couchdb-service prefix_rewrite: "/" + - match: { prefix: "/cache/" } + route: + cluster: redis-service + prefix_rewrite: "/" + # minio is on the default route because this works # best, minio + AWS SDK doesn't handle path proxy - match: { prefix: "/" } @@ -51,20 +36,6 @@ static_resources: - name: envoy.filters.http.router clusters: - # - name: app-service - # connect_timeout: 0.25s - # type: strict_dns - # lb_policy: round_robin - # load_assignment: - # cluster_name: app-service - # endpoints: - # - lb_endpoints: - # - endpoint: - # address: - # socket_address: - # address: app-service - # port_value: 4002 - - name: minio-service connect_timeout: 0.25s type: strict_dns @@ -79,20 +50,6 @@ static_resources: address: minio-service port_value: 9000 - # - name: worker-service - # connect_timeout: 0.25s - # type: strict_dns - # lb_policy: round_robin - # load_assignment: - # cluster_name: worker-service - # endpoints: - # - lb_endpoints: - # - endpoint: - # address: - # socket_address: - # address: worker-service - # port_value: 4003 - - name: couchdb-service connect_timeout: 0.25s type: strict_dns @@ -107,3 +64,16 @@ static_resources: address: couchdb-service port_value: 5984 + - name: redis-service + connect_timeout: 0.25s + type: strict_dns + lb_policy: round_robin + load_assignment: + cluster_name: redis-service + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: redis-service + port_value: 6379 diff --git a/hosting/hosting.properties b/hosting/hosting.properties index ad047a3826..138e66d629 100644 --- a/hosting/hosting.properties +++ b/hosting/hosting.properties @@ -18,4 +18,5 @@ APP_PORT=4002 WORKER_PORT=4003 MINIO_PORT=4004 COUCH_DB_PORT=4005 +REDIS_PORT=6379 BUDIBASE_ENVIRONMENT=PRODUCTION diff --git a/packages/cli/src/hosting/makeEnv.js b/packages/cli/src/hosting/makeEnv.js index c8359dd5e4..318a72def1 100644 --- a/packages/cli/src/hosting/makeEnv.js +++ b/packages/cli/src/hosting/makeEnv.js @@ -26,6 +26,7 @@ APP_PORT=4002 WORKER_PORT=4003 MINIO_PORT=4004 COUCH_DB_PORT=4005 +REDIS_PORT=6379 BUDIBASE_ENVIRONMENT=PRODUCTION` } diff --git a/packages/server/dev.env b/packages/server/dev.env index 3050b3933f..d0a835e0b4 100644 --- a/packages/server/dev.env +++ b/packages/server/dev.env @@ -19,4 +19,5 @@ COUCH_DB_URL=http://budibase:budibase@localhost:10000/db/ # MINIO_PORT=4004 # COUCH_DB_PORT=4005 # BUDIBASE_ENVIRONMENT=PRODUCTION +# REDIS_PORT=6379 diff --git a/packages/worker/package.json b/packages/worker/package.json index 1670fd729e..7d88654a88 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -33,6 +33,5 @@ "pouchdb": "^7.2.2", "pouchdb-all-dbs": "^1.0.2", "server-destroy": "^1.0.1" - }, - "gitHead": "1b95326b20d1352d36305910259228b96a683dc7" + } } diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index 24bbb55092..83f030c846 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -1,12 +1,9 @@ const PouchDB = require("pouchdb") const allDbs = require("pouchdb-all-dbs") const env = require("../environment") -const { join } = require("path") -const { homedir } = require("os") // level option is purely for testing (development) -const COUCH_DB_URL = - env.COUCH_DB_URL || `leveldb://${join(homedir(), ".budibase")}/.data/` +const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/" const Pouch = PouchDB.defaults({ prefix: COUCH_DB_URL,