diff --git a/docs/budibase-0.2.0.tgz b/docs/budibase-0.2.0.tgz new file mode 100644 index 0000000000..379b92cbb7 Binary files /dev/null and b/docs/budibase-0.2.0.tgz differ diff --git a/docs/index.yaml b/docs/index.yaml index 4e064f3dd0..b050330477 100644 --- a/docs/index.yaml +++ b/docs/index.yaml @@ -1,9 +1,35 @@ apiVersion: v1 entries: budibase: + - apiVersion: v2 + appVersion: 0.9.163 + created: "2021-10-12T21:58:00.515555+01:00" + dependencies: + - condition: services.couchdb.enabled + name: couchdb + repository: https://apache.github.io/couchdb-helm + version: 3.3.4 + - condition: ingress.nginx + name: ingress-nginx + repository: https://github.com/kubernetes/ingress-nginx + version: 3.35.0 + description: Budibase is an open source low-code platform, helping thousands of teams build apps for their workplace in minutes. + digest: f369536c0eac1f6959d51e8ce6d74a87a7a9df29ae84fb9cbed0a273ab77429b + keywords: + - low-code + - database + - cluster + name: budibase + sources: + - https://github.com/Budibase/budibase + - https://budibase.com + type: application + urls: + - https://budibase.github.io/budibase/budibase-0.2.0.tgz + version: 0.2.0 - apiVersion: v2 appVersion: 0.9.56 - created: "2021-08-18T18:41:52.640176+01:00" + created: "2021-10-12T21:58:00.512062+01:00" dependencies: - condition: services.couchdb.enabled name: couchdb @@ -28,7 +54,7 @@ entries: version: 0.1.1 - apiVersion: v2 appVersion: 0.9.56 - created: "2021-08-18T18:41:52.635603+01:00" + created: "2021-10-12T21:58:00.507257+01:00" dependencies: - condition: services.couchdb.enabled name: couchdb @@ -51,4 +77,4 @@ entries: urls: - https://budibase.github.io/budibase/budibase-0.1.0.tgz version: 0.1.0 -generated: "2021-08-18T18:41:52.629415+01:00" +generated: "2021-10-12T21:58:00.503447+01:00" diff --git a/hosting/kubernetes/budibase/templates/.helmignore b/hosting/kubernetes/budibase/.helmignore similarity index 100% rename from hosting/kubernetes/budibase/templates/.helmignore rename to hosting/kubernetes/budibase/.helmignore diff --git a/hosting/kubernetes/budibase/Chart.yaml b/hosting/kubernetes/budibase/Chart.yaml index d00b228b0e..fa652ed28f 100644 --- a/hosting/kubernetes/budibase/Chart.yaml +++ b/hosting/kubernetes/budibase/Chart.yaml @@ -22,13 +22,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.1 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.9.56" +appVersion: "0.9.163" dependencies: - name: couchdb @@ -37,5 +37,5 @@ dependencies: condition: services.couchdb.enabled - name: ingress-nginx version: 3.35.0 - repository: https://kubernetes.github.io/ingress-nginx - condition: services.ingress.nginx + repository: https://github.com/kubernetes/ingress-nginx + condition: ingress.nginx diff --git a/hosting/kubernetes/budibase/templates/alb-ingress.yaml b/hosting/kubernetes/budibase/templates/alb-ingress.yaml index ea3bd674d5..388bcf1d3e 100644 --- a/hosting/kubernetes/budibase/templates/alb-ingress.yaml +++ b/hosting/kubernetes/budibase/templates/alb-ingress.yaml @@ -7,6 +7,8 @@ metadata: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip + alb.ingress.kubernetes.io/success-codes: 200,301 + alb.ingress.kubernetes.io/healthcheck-path: / {{- if .Values.ingress.certificateArn }} alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}' alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' diff --git a/hosting/kubernetes/budibase/templates/app-service-deployment.yaml b/hosting/kubernetes/budibase/templates/app-service-deployment.yaml index 98fdc8dfd0..bce532016a 100644 --- a/hosting/kubernetes/budibase/templates/app-service-deployment.yaml +++ b/hosting/kubernetes/budibase/templates/app-service-deployment.yaml @@ -14,7 +14,7 @@ spec: matchLabels: io.kompose.service: app-service strategy: - type: Recreate + type: RollingUpdate template: metadata: annotations: @@ -73,13 +73,11 @@ spec: name: {{ template "budibase.fullname" . }} key: objectStoreSecret - name: MINIO_URL - {{ if .Values.services.objectStore.url }} value: {{ .Values.services.objectStore.url }} - {{ else }} - value: http://minio-service:{{ .Values.services.objectStore.port }} - {{ end }} - name: PORT value: {{ .Values.services.apps.port | quote }} + - name: MULTI_TENANCY + value: "1" - name: REDIS_PASSWORD value: {{ .Values.services.redis.password }} - name: REDIS_URL @@ -92,14 +90,20 @@ spec: value: {{ .Values.globals.selfHosted | quote }} - name: SENTRY_DSN value: {{ .Values.globals.sentryDSN }} + - name: POSTHOG_TOKEN + value: {{ .Values.globals.posthogToken }} - name: WORKER_URL - value: worker-service:{{ .Values.services.worker.port }} - - name: COOKIE_DOMAIN - value: {{ .Values.globals.cookieDomain | quote }} + value: http://worker-service:{{ .Values.services.worker.port }} + - name: PLATFORM_URL + value: {{ .Values.globals.platformUrl | quote }} + - name: USE_QUOTAS + value: "1" - name: ACCOUNT_PORTAL_URL value: {{ .Values.globals.accountPortalUrl | quote }} - name: ACCOUNT_PORTAL_API_KEY value: {{ .Values.globals.accountPortalApiKey | quote }} + - name: COOKIE_DOMAIN + value: {{ .Values.globals.cookieDomain | quote }} image: budibase/apps imagePullPolicy: Always name: bbapps diff --git a/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml b/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml index 0f802da843..2e453d1c5b 100644 --- a/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml +++ b/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml @@ -14,7 +14,7 @@ spec: matchLabels: app.kubernetes.io/name: budibase-proxy strategy: - type: Recreate + type: RollingUpdate template: metadata: annotations: @@ -26,7 +26,7 @@ spec: spec: containers: - image: budibase/proxy - imagePullPolicy: "" + imagePullPolicy: Always name: proxy-service ports: - containerPort: {{ .Values.services.proxy.port }} diff --git a/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml b/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml index 08b40d3b6b..563b1b4193 100644 --- a/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml +++ b/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml @@ -15,7 +15,7 @@ spec: matchLabels: io.kompose.service: worker-service strategy: - type: Recreate + type: RollingUpdate template: metadata: annotations: @@ -70,13 +70,11 @@ spec: name: {{ template "budibase.fullname" . }} key: objectStoreSecret - name: MINIO_URL - {{ if .Values.services.objectStore.url }} value: {{ .Values.services.objectStore.url }} - {{ else }} - value: http://minio-service:{{ .Values.services.objectStore.port }} - {{ end }} - name: PORT value: {{ .Values.services.worker.port | quote }} + - name: MULTI_TENANCY + value: "1" - name: REDIS_PASSWORD value: {{ .Values.services.redis.password | quote }} - name: REDIS_URL @@ -91,8 +89,22 @@ spec: value: {{ .Values.globals.accountPortalUrl | quote }} - name: ACCOUNT_PORTAL_API_KEY value: {{ .Values.globals.accountPortalApiKey | quote }} + - name: PLATFORM_URL + value: {{ .Values.globals.platformUrl | quote }} - name: COOKIE_DOMAIN value: {{ .Values.globals.cookieDomain | quote }} + - name: SMTP_FALLBACK_ENABLED + value: {{ .Values.globals.smtp.enabled | quote }} + - name: SMTP_USER + value: {{ .Values.globals.smtp.user | quote }} + - name: SMTP_PASSWORD + value: {{ .Values.globals.smtp.password | quote }} + - name: SMTP_HOST + value: {{ .Values.globals.smtp.host | quote }} + - name: SMTP_PORT + value: {{ .Values.globals.smtp.port | quote }} + - name: SMTP_FROM_ADDRESS + value: {{ .Values.globals.smtp.from | quote }} image: budibase/worker imagePullPolicy: Always name: bbworker diff --git a/hosting/kubernetes/budibase/values.yaml b/hosting/kubernetes/budibase/values.yaml index 5999f9c4bc..774f7ea102 100644 --- a/hosting/kubernetes/budibase/values.yaml +++ b/hosting/kubernetes/budibase/values.yaml @@ -40,11 +40,12 @@ service: port: 10000 ingress: - enabled: true - nginx: true - certificateArn: "" + enabled: false + aws: false + nginx: true + certificateArn: "" className: "" - annotations: + annotations: kubernetes.io/ingress.class: nginx hosts: - host: # change if using custom domain @@ -55,7 +56,7 @@ ingress: service: name: proxy-service port: - number: 10000 + number: 10000 resources: {} # We usually recommend not to specify default resources and to leave this as a conscious @@ -84,20 +85,24 @@ affinity: {} globals: budibaseEnv: PRODUCTION - enableAnalytics: false - posthogToken: "" + enableAnalytics: true sentryDSN: "" + posthogToken: "" logLevel: info - selfHosted: 1 - accountPortalUrL: "" + selfHosted: "" + accountPortalUrl: "" accountPortalApiKey: "" - cookieDomain: "" + cookieDomain: "" + platformUrl: "" + createSecrets: true # creates an internal API key, JWT secrets and redis password for you # if createSecrets is set to false, you can hard-code your secrets here internalApiKey: "" jwtSecret: "" + smtp: + enabled: false services: dns: cluster.local @@ -118,12 +123,12 @@ services: couchdb: enabled: true replicaCount: 3 - url: "" # only change if pointing to existing couch server - user: "" # only change if pointing to existing couch server - password: "" # only change if pointing to existing couch server + # url: "" # only change if pointing to existing couch server + # user: "" # only change if pointing to existing couch server + # password: "" # only change if pointing to existing couch server port: 5984 storage: 100Mi - + redis: enabled: true # disable if using external redis port: 6379 @@ -131,7 +136,7 @@ services: url: "" # only change if pointing to existing redis cluster and enabled: false password: "budibase" # recommended to override if using built-in redis storage: 100Mi - + objectStore: minio: true browser: true diff --git a/lerna.json b/lerna.json index bf0512e6bd..0f097b4bda 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.160-alpha.5", + "version": "0.9.164", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 9617e6c1c1..170e09547e 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 165035c425..76b904d0dd 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index b5c75d6c22..25e5e10be3 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.160-alpha.5", - "@budibase/client": "^0.9.160-alpha.5", + "@budibase/bbui": "^0.9.164", + "@budibase/client": "^0.9.164", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.160-alpha.5", + "@budibase/string-templates": "^0.9.164", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/builder/src/pages/builder/admin/_components/ImportAppsModal.svelte b/packages/builder/src/pages/builder/admin/_components/ImportAppsModal.svelte index 633147e910..de29e11301 100644 --- a/packages/builder/src/pages/builder/admin/_components/ImportAppsModal.svelte +++ b/packages/builder/src/pages/builder/admin/_components/ImportAppsModal.svelte @@ -1,6 +1,7 @@ @@ -73,7 +81,7 @@ > Change organisation - {:else if !cloud} + {:else if !cloud && !imported} { diff --git a/packages/builder/src/stores/portal/admin.js b/packages/builder/src/stores/portal/admin.js index ebe8294060..b9ed0f04b8 100644 --- a/packages/builder/src/stores/portal/admin.js +++ b/packages/builder/src/stores/portal/admin.js @@ -9,6 +9,7 @@ export function createAdminStore() { cloud: false, disableAccountPortal: false, accountPortalUrl: "", + importComplete: false, onboardingProgress: 0, checklist: { apps: { checked: false }, @@ -45,6 +46,17 @@ export function createAdminStore() { } } + async function checkImportComplete() { + const response = await api.get(`/api/cloud/import/complete`) + if (response.status === 200) { + const json = await response.json() + admin.update(store => { + store.importComplete = json ? json.imported : false + return store + }) + } + } + async function getEnvironment() { let multiTenancyEnabled = false let cloud = false @@ -79,6 +91,7 @@ export function createAdminStore() { return { subscribe: admin.subscribe, init, + checkImportComplete, unload, } } diff --git a/packages/cli/package.json b/packages/cli/package.json index 48830d595a..6659a58b81 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 278058221b..edcdba9a7d 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.160-alpha.5", + "@budibase/bbui": "^0.9.164", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^0.9.160-alpha.5", + "@budibase/string-templates": "^0.9.164", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index f4ac1b0c5d..7962f1b0fb 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -68,9 +68,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.160-alpha.5", - "@budibase/client": "^0.9.160-alpha.5", - "@budibase/string-templates": "^0.9.160-alpha.5", + "@budibase/auth": "^0.9.164", + "@budibase/client": "^0.9.164", + "@budibase/string-templates": "^0.9.164", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 6608ba0cac..e3aac8bd63 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -86,6 +86,7 @@ async function getAppUrlIfNotInUse(ctx) { if ( url && deployedApps[url] != null && + ctx.params != null && deployedApps[url].appId !== ctx.params.appId ) { ctx.throw(400, "App name/URL is already in use.") diff --git a/packages/server/src/api/controllers/cloud.js b/packages/server/src/api/controllers/cloud.js index aac79bb9dd..a0057d68e4 100644 --- a/packages/server/src/api/controllers/cloud.js +++ b/packages/server/src/api/controllers/cloud.js @@ -28,15 +28,18 @@ exports.exportApps = async ctx => { ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.") } const apps = await getAllApps(CouchDB, { all: true }) - const globalDBString = await exportDB(getGlobalDBName()) + const globalDBString = await exportDB(getGlobalDBName(), { + filter: doc => !doc._id.startsWith(DocumentTypes.USER), + }) let allDBs = { global: globalDBString, } for (let app of apps) { + const appId = app.appId || app._id // only export the dev apps as they will be the latest, the user can republish the apps // in their self hosted environment - if (isDevAppID(app._id)) { - allDBs[app.name] = await exportDB(app._id) + if (isDevAppID(appId)) { + allDBs[app.name] = await exportDB(appId) } } const filename = `cloud-export-${new Date().getTime()}.txt` @@ -53,16 +56,26 @@ async function getAllDocType(db, docType) { return response.rows.map(row => row.doc) } +async function hasBeenImported() { + if (!env.SELF_HOSTED || env.MULTI_TENANCY) { + return true + } + const apps = await getAllApps(CouchDB, { all: true }) + return apps.length !== 0 +} + +exports.hasBeenImported = async ctx => { + ctx.body = { + imported: await hasBeenImported(), + } +} + exports.importApps = async ctx => { if (!env.SELF_HOSTED || env.MULTI_TENANCY) { ctx.throw(400, "Importing only allowed in self hosted environments.") } - const apps = await getAllApps(CouchDB, { all: true }) - if ( - apps.length !== 0 || - !ctx.request.files || - !ctx.request.files.importFile - ) { + const beenImported = await hasBeenImported() + if (beenImported || !ctx.request.files || !ctx.request.files.importFile) { ctx.throw( 400, "Import file is required and environment must be fresh to import apps." @@ -80,11 +93,17 @@ exports.importApps = async ctx => { for (let [appName, appImport] of Object.entries(dbs)) { await createApp(appName, appImport) } - // once apps are created clean up the global db + + // if there are any users make sure to remove them let users = await getAllDocType(globalDb, DocumentTypes.USER) + let userDeletionPromises = [] for (let user of users) { - delete user.tenantId + userDeletionPromises.push(globalDb.remove(user._id, user._rev)) } + if (userDeletionPromises.length > 0) { + await Promise.all(userDeletionPromises) + } + await globalDb.bulkDocs(users) ctx.body = { message: "Apps successfully imported.", diff --git a/packages/server/src/api/routes/cloud.js b/packages/server/src/api/routes/cloud.js index 214473f43f..02b501c399 100644 --- a/packages/server/src/api/routes/cloud.js +++ b/packages/server/src/api/routes/cloud.js @@ -9,5 +9,6 @@ router .get("/api/cloud/export", authorized(BUILDER), controller.exportApps) // has to be public, only run if apps don't exist .post("/api/cloud/import", controller.importApps) + .get("/api/cloud/import/complete", controller.hasBeenImported) module.exports = router diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index e7bc35b04b..4044bb3787 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -74,9 +74,10 @@ module.exports = { }, } -// convert any strings to numbers if required, like "0" would be true otherwise +// clean up any environment variable edge cases for (let [key, value] of Object.entries(module.exports)) { - if (typeof value === "string" && !isNaN(parseInt(value))) { - module.exports[key] = parseInt(value) + // handle the edge case of "0" to disable an environment variable + if (value === "0") { + module.exports[key] = 0 } } diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 6eb93ad5ca..c56f35f42d 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 1f6f298a84..89f9f4095f 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.160-alpha.5", + "version": "0.9.164", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.160-alpha.5", - "@budibase/string-templates": "^0.9.160-alpha.5", + "@budibase/auth": "^0.9.164", + "@budibase/string-templates": "^0.9.164", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", diff --git a/packages/worker/src/environment.js b/packages/worker/src/environment.js index 74bd40314c..a1fab84112 100644 --- a/packages/worker/src/environment.js +++ b/packages/worker/src/environment.js @@ -52,3 +52,11 @@ module.exports = { return !isDev() }, } + +// clean up any environment variable edge cases +for (let [key, value] of Object.entries(module.exports)) { + // handle the edge case of "0" to disable an environment variable + if (value === "0") { + module.exports[key] = 0 + } +} diff --git a/packages/worker/src/middleware/cloudRestricted.js b/packages/worker/src/middleware/cloudRestricted.js index 10cdeaebd4..b29093f77e 100644 --- a/packages/worker/src/middleware/cloudRestricted.js +++ b/packages/worker/src/middleware/cloudRestricted.js @@ -6,7 +6,7 @@ const { Headers } = require("@budibase/auth").constants * Ensure that the correct API key has been supplied. */ module.exports = async (ctx, next) => { - if (!env.SELF_HOSTED) { + if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) { const apiKey = ctx.request.headers[Headers.API_KEY] if (apiKey !== env.INTERNAL_API_KEY) { ctx.throw(403, "Unauthorized")