diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000000..92bd33894e
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,9 @@
+packages/server/node_modules
+packages/builder
+packages/frontend-core
+packages/backend-core
+packages/worker/node_modules
+packages/cli
+packages/client
+packages/bbui
+packages/string-templates
diff --git a/.eslintrc.json b/.eslintrc.json
index 4dc11c0d65..87f8269c50 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -24,9 +24,28 @@
{
"files": ["*.svelte"],
"processor": "svelte3/svelte3"
+ },
+ {
+ "files": ["**/*.ts"],
+ "parser": "@typescript-eslint/parser",
+ "plugins": [],
+ "extends": [
+ "eslint:recommended"
+ ],
+ "rules": {
+ "no-unused-vars": "off",
+ "no-inner-declarations": "off",
+ "no-case-declarations": "off",
+ "no-useless-escape": "off",
+ "no-undef": "off",
+ "no-prototype-builtins": "off"
+ }
}
],
"rules": {
"no-self-assign": "off"
+ },
+ "globals": {
+ "GeolocationPositionError": true
}
}
diff --git a/.github/workflows/smoke_test.yaml b/.github/workflows/smoke_test.yaml
index 745fed1306..04c0c7b5e3 100644
--- a/.github/workflows/smoke_test.yaml
+++ b/.github/workflows/smoke_test.yaml
@@ -2,6 +2,8 @@ name: Budibase Smoke Test
on:
workflow_dispatch:
+ schedule:
+ - cron: "0 5 * * *" # every day at 5AM
jobs:
release:
@@ -23,10 +25,13 @@ jobs:
-o packages/builder/cypress.env.json \
-L https://api.github.com/repos/budibase/budibase-infra/contents/test/cypress.env.json
wc -l packages/builder/cypress.env.json
- - run: yarn test:e2e:ci
- env:
- CI: true
- name: Budibase CI
+
+ - name: Cypress run
+ id: cypress
+ uses: cypress-io/github-action@v2
+ with:
+ install: false
+ command: yarn test:e2e:ci
# TODO: upload recordings to s3
# - name: Configure AWS Credentials
@@ -36,11 +41,11 @@ jobs:
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: eu-west-1
- # TODO look at cypress reporters
- # - name: Discord Webhook Action
- # uses: tsickert/discord-webhook@v4.0.0
- # with:
- # webhook-url: ${{ secrets.PROD_DEPLOY_WEBHOOK_URL }}
- # content: "Production Deployment Complete: ${{ env.RELEASE_VERSION }} deployed to Budibase Cloud."
- # embed-title: ${{ env.RELEASE_VERSION }}
+ - name: Discord Webhook Action
+ uses: tsickert/discord-webhook@v4.0.0
+ with:
+ webhook-url: ${{ secrets.BUDI_QA_WEBHOOK }}
+ content: "Smoke test run completed with ${{ steps.cypress.outcome }}. See results at ${{ steps.cypress.dashboardUrl }}"
+ embed-title: ${{ steps.cypress.outcome }}
+ embed-color: ${{ steps.cypress.outcome == 'success' && '3066993' || '15548997' }}
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 34951b6310..8cb49d5825 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -22,9 +22,16 @@
"name": "Budibase Worker",
"type": "node",
"request": "launch",
- "program": "${workspaceFolder}/packages/worker/src/index.js",
+ "runtimeArgs": [
+ "--nolazy",
+ "-r",
+ "ts-node/register/transpile-only"
+ ],
+ "args": [
+ "${workspaceFolder}/packages/worker/src/index.ts"
+ ],
"cwd": "${workspaceFolder}/packages/worker"
- }
+ },
],
"compounds": [
{
diff --git a/README.md b/README.md
index 6296862a4c..17a3ab1ef2 100644
--- a/README.md
+++ b/README.md
@@ -102,15 +102,19 @@ Budibase is made to scale. With Budibase, you can self-host on your own infrastr
- Checkout the promo video: https://youtu.be/xoljVpty_Kw
-
+
-### Extend Budibase with its Public API
+---
+
+
+
+
+## Budibase Public API
As with anything that we build in Budibase, our new public API is simple to use, flexible, and introduces new extensibility. To summarize, the Budibase API enables:
- Budibase as a backend
-- Inter-operability
+- Interoperability
-Guide: [Build an app with Budibase and Next.js](https://budibase.com/blog/building-a-crud-app-with-budibase-and-next.js/)
#### Docs
You can learn more about the Budibase API at the following places:
@@ -118,6 +122,10 @@ You can learn more about the Budibase API at the following places:
- [General documentation](https://docs.budibase.com/docs/public-api) : Learn how to get your API key, how to use spec, and how to use with Postman
- [Interactive API documentation](https://docs.budibase.com/reference/post_applications) : Learn how to interact with the API
+#### Guides
+
+- [Build an app with Budibase and Next.js](https://budibase.com/blog/building-a-crud-app-with-budibase-and-next.js/)
+
diff --git a/charts/budibase/Chart.yaml b/charts/budibase/Chart.yaml index daf8dad635..134d29441f 100644 --- a/charts/budibase/Chart.yaml +++ b/charts/budibase/Chart.yaml @@ -15,7 +15,7 @@ version: 0.2.8 appVersion: 1.0.48 dependencies: - name: couchdb - version: 3.3.4 + version: 3.6.1 repository: https://apache.github.io/couchdb-helm condition: services.couchdb.enabled - name: ingress-nginx diff --git a/charts/budibase/templates/app-service-deployment.yaml b/charts/budibase/templates/app-service-deployment.yaml index d9def8c641..86e255d331 100644 --- a/charts/budibase/templates/app-service-deployment.yaml +++ b/charts/budibase/templates/app-service-deployment.yaml @@ -110,6 +110,10 @@ spec: value: {{ .Values.globals.cookieDomain | quote }} - name: HTTP_MIGRATIONS value: {{ .Values.globals.httpMigrations | quote }} + - name: GOOGLE_CLIENT_ID + value: {{ .Values.globals.google.clientId | quote }} + - name: GOOGLE_CLIENT_SECRET + value: {{ .Values.globals.google.secret | quote }} image: budibase/apps:{{ .Values.globals.appVersion }} imagePullPolicy: Always name: bbapps diff --git a/examples/nextjs-api-sales/yarn.lock b/examples/nextjs-api-sales/yarn.lock index 3f32417ba8..52c89967b2 100644 --- a/examples/nextjs-api-sales/yarn.lock +++ b/examples/nextjs-api-sales/yarn.lock @@ -1894,9 +1894,9 @@ minimist-options@4.1.0: kind-of "^6.0.3" minimist@^1.2.0: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== minipass-collect@^1.0.2: version "1.0.2" diff --git a/hosting/digitalocean/files/etc/update-motd.d/99-one-click b/hosting/digitalocean/files/etc/update-motd.d/99-one-click index 0f087a26ee..3fbdbe0146 100644 --- a/hosting/digitalocean/files/etc/update-motd.d/99-one-click +++ b/hosting/digitalocean/files/etc/update-motd.d/99-one-click @@ -12,7 +12,7 @@ All ports are BLOCKED except 22 (SSH), 80 (HTTP), 443 (HTTPS), and 10000 * Budibase website: http://budibase.com -For help and more information, visit https://docs.budibase.com/self-hosting/hosting-methods/digitalocean +For help and more information, visit https://docs.budibase.com/docs/digitalocean ******************************************************************************** To delete this message of the day: rm -rf $(readlink -f ${0}) diff --git a/hosting/docker-compose.dev.yaml b/hosting/docker-compose.dev.yaml index df403c0a22..43b8526e9e 100644 --- a/hosting/docker-compose.dev.yaml +++ b/hosting/docker-compose.dev.yaml @@ -5,7 +5,7 @@ version: "3" services: minio-service: container_name: budi-minio-dev - restart: always + restart: on-failure image: minio/minio volumes: - minio_data:/data @@ -23,7 +23,7 @@ services: proxy-service: container_name: budi-nginx-dev - restart: always + restart: on-failure image: nginx:latest volumes: - ./.generated-nginx.dev.conf:/etc/nginx/nginx.conf @@ -38,7 +38,7 @@ services: couchdb-service: # platform: linux/amd64 container_name: budi-couchdb-dev - restart: always + restart: on-failure image: ibmcom/couchdb3 environment: - COUCHDB_PASSWORD=${COUCH_DB_PASSWORD} @@ -59,7 +59,7 @@ services: redis-service: container_name: budi-redis-dev - restart: always + restart: on-failure image: redis command: redis-server --requirepass ${REDIS_PASSWORD} ports: diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml index 8143be54b7..f9d9eaf1c5 100644 --- a/hosting/docker-compose.yaml +++ b/hosting/docker-compose.yaml @@ -4,7 +4,7 @@ version: "3" services: app-service: - restart: always + restart: unless-stopped image: budibase.docker.scarf.sh/budibase/apps container_name: bbapps environment: @@ -28,7 +28,7 @@ services: - redis-service worker-service: - restart: always + restart: unless-stopped image: budibase.docker.scarf.sh/budibase/worker container_name: bbworker environment: @@ -53,7 +53,7 @@ services: - couch-init minio-service: - restart: always + restart: unless-stopped image: minio/minio volumes: - minio_data:/data @@ -69,7 +69,7 @@ services: retries: 3 proxy-service: - restart: always + restart: unless-stopped ports: - "${MAIN_PORT}:10000" container_name: bbproxy @@ -81,7 +81,7 @@ services: - couchdb-service couchdb-service: - restart: always + restart: unless-stopped image: ibmcom/couchdb3 environment: - COUCHDB_PASSWORD=${COUCH_DB_PASSWORD} @@ -98,13 +98,14 @@ services: command: ["sh","-c","sleep 10 && $${PUT_CALL}/_users && $${PUT_CALL}/_replicator; fg;"] redis-service: - restart: always + restart: unless-stopped image: redis command: redis-server --requirepass ${REDIS_PASSWORD} volumes: - redis_data:/data watchtower-service: + restart: always image: containrrr/watchtower volumes: - /var/run/docker.sock:/var/run/docker.sock @@ -116,7 +117,6 @@ services: labels: - "com.centurylinklabs.watchtower.enable=false" - volumes: couchdb3_data: driver: local diff --git a/hosting/nginx.dev.conf.hbs b/hosting/nginx.dev.conf.hbs index 441fffa9f7..9fc2345fb2 100644 --- a/hosting/nginx.dev.conf.hbs +++ b/hosting/nginx.dev.conf.hbs @@ -52,9 +52,8 @@ http { proxy_pass http://{{ address }}:4001; } - location /app/ { + location /app { proxy_pass http://{{ address }}:4001; - rewrite ^/app/(.*)$ /$1 break; } location /builder { diff --git a/hosting/nginx.prod.conf.hbs b/hosting/nginx.prod.conf.hbs index f3009baf40..88570a4a2d 100644 --- a/hosting/nginx.prod.conf.hbs +++ b/hosting/nginx.prod.conf.hbs @@ -22,9 +22,8 @@ http { resolver {{ resolver }} valid=10s ipv6=off; # buffering - client_body_buffer_size 1K; client_header_buffer_size 1k; - client_max_body_size 10M; + client_max_body_size 20M; ignore_invalid_headers off; proxy_buffering off; @@ -43,13 +42,25 @@ http { client_max_body_size 1000m; ignore_invalid_headers off; proxy_buffering off; - # port_in_redirect off; + + set $csp_default "default-src 'self'"; + set $csp_script "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.budi.live https://js.intercomcdn.com https://widget.intercom.io"; + set $csp_style "style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me https://maxcdn.bootstrapcdn.com"; + set $csp_object "object-src 'none'"; + set $csp_base_uri "base-uri 'self'"; + set $csp_connect "connect-src 'self' https://api-iam.intercom.io https://api-iam.intercom.io https://api-ping.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io wss://nexus-websocket-b.intercom.io https://nexus-websocket-a.intercom.io https://nexus-websocket-b.intercom.io https://uploads.intercomcdn.com https://uploads.intercomusercontent.com"; + set $csp_font "font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me https://maxcdn.bootstrapcdn.com https://js.intercomcdn.com https://fonts.intercomcdn.com"; + set $csp_frame "frame-src 'self' https:"; + set $csp_img "img-src http: https: data: blob:"; + set $csp_manifest "manifest-src 'self'"; + set $csp_media "media-src 'self' https://js.intercomcdn.com"; + set $csp_worker "worker-src 'none'"; # Security Headers add_header X-Frame-Options SAMEORIGIN always; add_header X-Content-Type-Options nosniff always; add_header X-XSS-Protection "1; mode=block" always; - add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.budi.live https://js.intercomcdn.com https://widget.intercom.io; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me https://maxcdn.bootstrapcdn.com; object-src 'none'; base-uri 'self'; connect-src 'self' https://api-iam.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io ; font-src 'self' data https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me https://maxcdn.bootstrapcdn.com; frame-src 'self' https:; img-src http: https: data; manifest-src 'self'; media-src 'self'; worker-src 'none';" always; + add_header Content-Security-Policy "${csp_default}; ${csp_script}; ${csp_style}; ${csp_object}; ${csp_base_uri}; ${csp_connect}; ${csp_font}; ${csp_frame}; ${csp_img}; ${csp_manifest}; ${csp_media}; ${csp_worker};" always; # upstreams set $apps {{ apps }}; @@ -62,7 +73,6 @@ http { location /app { proxy_pass http://$apps:4002; - rewrite ^/app/(.*)$ /$1 break; } location = / { diff --git a/hosting/portainer/template.json b/hosting/portainer/template.json new file mode 100644 index 0000000000..29107b674e --- /dev/null +++ b/hosting/portainer/template.json @@ -0,0 +1,94 @@ +{ + "version": "2", + "templates": [ + { + "type": 3, + "title": "Budibase", + "categories": ["Tools"], + "description": "Build modern business apps in minutes", + "logo": "https://budibase.com/favicon.ico", + "platform": "linux", + "repository": { + "url": "https://github.com/Budibase/budibase", + "stackfile": "hosting/docker-compose.yaml" + }, + "env": [ + { + "name": "MAIN_PORT", + "label": "Main port", + "default": "10000" + }, + { + "name": "JWT_SECRET", + "label": "JWT secret", + "default": "change-me" + }, + { + "name": "MINIO_ACCESS_KEY", + "label": "MinIO access key", + "default": "change-me" + }, + { + "name": "MINIO_SECRET_KEY", + "label": "MinIO secret key", + "default": "change-me" + }, + { + "name": "COUCH_DB_USER", + "default": "budibase", + "preset": true + }, + { + "name": "COUCH_DB_PASSWORD", + "label": "Couch DB password", + "default": "change-me" + }, + { + "name": "REDIS_PASSWORD", + "label": "Redis password", + "default": "change-me" + }, + { + "name": "INTERNAL_API_KEY", + "label": "Internal API key", + "default": "change-me" + }, + { + "name": "APP_PORT", + "default": "4002", + "preset": true + }, + { + "name": "WORKER_PORT", + "default": "4003", + "preset": true + }, + { + "name": "MINIO_PORT", + "default": "4004", + "preset": true + }, + { + "name": "COUCH_DB_PORT", + "default": "4005", + "preset": true + }, + { + "name": "REDIS_PORT", + "default": "6379", + "preset": true + }, + { + "name": "WATCHTOWER_PORT", + "default": "6161", + "preset": true + }, + { + "name": "BUDIBASE_ENVIRONMENT", + "default": "PRODUCTION", + "preset": true + } + ] + } + ] +} diff --git a/hosting/single/Dockerfile b/hosting/single/Dockerfile new file mode 100644 index 0000000000..2123d237b5 --- /dev/null +++ b/hosting/single/Dockerfile @@ -0,0 +1,97 @@ +FROM couchdb + +ENV COUCHDB_PASSWORD=budibase +ENV COUCHDB_USER=budibase +ENV COUCH_DB_URL=http://budibase:budibase@localhost:5984 +ENV BUDIBASE_ENVIRONMENT=PRODUCTION +ENV MINIO_URL=http://localhost:9000 +ENV REDIS_URL=localhost:6379 +ENV WORKER_URL=http://localhost:4002 +ENV INTERNAL_API_KEY=budibase +ENV JWT_SECRET=testsecret +ENV MINIO_ACCESS_KEY=budibase +ENV MINIO_SECRET_KEY=budibase +ENV SELF_HOSTED=1 +ENV CLUSTER_PORT=10000 +ENV REDIS_PASSWORD=budibase +ENV ARCHITECTURE=amd +ENV APP_PORT=4001 +ENV WORKER_PORT=4002 + +RUN apt-get update +RUN apt-get install software-properties-common wget nginx -y +RUN apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main' +RUN apt-get update + +# setup nginx +ADD hosting/single/nginx.conf /etc/nginx +RUN mkdir /etc/nginx/logs +RUN useradd www +RUN touch /etc/nginx/logs/error.log +RUN touch /etc/nginx/logs/nginx.pid + +# install java +RUN apt-get install openjdk-8-jdk -y + +# setup nodejs +WORKDIR /nodejs +RUN curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh +RUN bash /tmp/nodesource_setup.sh +RUN apt-get install nodejs +RUN npm install --global yarn +RUN npm install --global pm2 + +# setup redis +RUN apt install redis-server -y + +# setup server +WORKDIR /app +ADD packages/server . +RUN ls -al +RUN yarn +RUN yarn build +# Install client for oracle datasource +RUN apt-get install unzip libaio1 +RUN /bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh + +# setup worker +WORKDIR /worker +ADD packages/worker . +RUN yarn +RUN yarn build + +# setup clouseau +WORKDIR / +RUN wget https://github.com/cloudant-labs/clouseau/releases/download/2.21.0/clouseau-2.21.0-dist.zip +RUN unzip clouseau-2.21.0-dist.zip +RUN mv clouseau-2.21.0 /opt/clouseau +RUN rm clouseau-2.21.0-dist.zip + +WORKDIR /opt/clouseau +RUN mkdir ./bin +ADD hosting/single/clouseau ./bin/ +ADD hosting/single/log4j.properties . +ADD hosting/single/clouseau.ini . +RUN chmod +x ./bin/clouseau + +# setup CouchDB +WORKDIR /opt/couchdb +ADD hosting/single/vm.args ./etc/ + +# setup minio +WORKDIR /minio +RUN wget https://dl.min.io/server/minio/release/linux-${ARCHITECTURE}64/minio +RUN chmod +x minio + +# setup runner file +WORKDIR / +ADD hosting/single/runner.sh . +RUN chmod +x ./runner.sh + +EXPOSE 10000 +VOLUME /opt/couchdb/data +VOLUME /minio + +# must set this just before running +ENV NODE_ENV=production +CMD ["./runner.sh"] diff --git a/hosting/single/clouseau b/hosting/single/clouseau new file mode 100644 index 0000000000..1095ea24cb --- /dev/null +++ b/hosting/single/clouseau @@ -0,0 +1,12 @@ +#!/bin/sh +/usr/bin/java -server \ + -Xmx2G \ + -Dsun.net.inetaddr.ttl=30 \ + -Dsun.net.inetaddr.negative.ttl=30 \ + -Dlog4j.configuration=file:/opt/clouseau/log4j.properties \ + -XX:OnOutOfMemoryError="kill -9 %p" \ + -XX:+UseConcMarkSweepGC \ + -XX:+CMSParallelRemarkEnabled \ + -classpath '/opt/clouseau/*' \ + com.cloudant.clouseau.Main \ + /opt/clouseau/clouseau.ini \ No newline at end of file diff --git a/hosting/single/clouseau.ini b/hosting/single/clouseau.ini new file mode 100644 index 0000000000..f086cf0398 --- /dev/null +++ b/hosting/single/clouseau.ini @@ -0,0 +1,13 @@ +[clouseau] + +; the name of the Erlang node created by the service, leave this unchanged +name=clouseau@127.0.0.1 + +; set this to the same distributed Erlang cookie used by the CouchDB nodes +cookie=monster + +; the path where you would like to store the search index files +dir=/opt/couchdb/data/search + +; the number of search indexes that can be open simultaneously +max_indexes_open=500 diff --git a/hosting/single/log4j.properties b/hosting/single/log4j.properties new file mode 100644 index 0000000000..9d4d9311bc --- /dev/null +++ b/hosting/single/log4j.properties @@ -0,0 +1,4 @@ +log4j.rootLogger=debug, CONSOLE +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %c [%p] %m%n \ No newline at end of file diff --git a/hosting/single/nginx.conf b/hosting/single/nginx.conf new file mode 100644 index 0000000000..86938ced4e --- /dev/null +++ b/hosting/single/nginx.conf @@ -0,0 +1,116 @@ +user www www; +error_log /etc/nginx/logs/error.log; +pid /etc/nginx/logs/nginx.pid; +worker_processes auto; +worker_rlimit_nofile 8192; + +events { + worker_connections 1024; +} + +http { + limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=20r/s; + proxy_set_header Host $host; + charset utf-8; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + server_tokens off; + types_hash_max_size 2048; + + # buffering + client_header_buffer_size 1k; + client_max_body_size 20M; + ignore_invalid_headers off; + proxy_buffering off; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + map $http_upgrade $connection_upgrade { + default "upgrade"; + } + + server { + listen 10000 default_server; + listen [::]:10000 default_server; + server_name _; + client_max_body_size 1000m; + ignore_invalid_headers off; + proxy_buffering off; + # port_in_redirect off; + + location /app { + proxy_pass http://127.0.0.1:4001; + } + + location = / { + proxy_pass http://127.0.0.1:4001; + } + + location ~ ^/(builder|app_) { + proxy_http_version 1.1; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:4001; + } + + location ~ ^/api/(system|admin|global)/ { + proxy_pass http://127.0.0.1:4002; + } + + location /worker/ { + proxy_pass http://127.0.0.1:4002; + rewrite ^/worker/(.*)$ /$1 break; + } + + location /api/ { + # calls to the API are rate limited with bursting + limit_req zone=ratelimit burst=20 nodelay; + + # 120s timeout on API requests + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; + + proxy_http_version 1.1; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_pass http://127.0.0.1:4001; + } + + location /db/ { + proxy_pass http://127.0.0.1:5984; + rewrite ^/db/(.*)$ /$1 break; + } + + location / { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_connect_timeout 300; + proxy_http_version 1.1; + proxy_set_header Connection ""; + chunked_transfer_encoding off; + proxy_pass http://127.0.0.1:9000; + } + + client_header_timeout 60; + client_body_timeout 60; + keepalive_timeout 60; + + # gzip + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; + } +} diff --git a/hosting/single/runner.sh b/hosting/single/runner.sh new file mode 100644 index 0000000000..fab8431796 --- /dev/null +++ b/hosting/single/runner.sh @@ -0,0 +1,16 @@ +redis-server --requirepass $REDIS_PASSWORD & +/opt/clouseau/bin/clouseau & +/minio/minio server /minio & +/docker-entrypoint.sh /opt/couchdb/bin/couchdb & +/etc/init.d/nginx restart +pushd app +pm2 start --name app "yarn run:docker" +popd +pushd worker +pm2 start --name worker "yarn run:docker" +popd +sleep 10 +URL=http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984 +curl -X PUT ${URL}/_users +curl -X PUT ${URL}/_replicator +sleep infinity \ No newline at end of file diff --git a/hosting/single/vm.args b/hosting/single/vm.args new file mode 100644 index 0000000000..e9e4416863 --- /dev/null +++ b/hosting/single/vm.args @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# erlang cookie for clouseau security +-name couchdb@127.0.0.1 +-setcookie monster + +# Ensure that the Erlang VM listens on a known port +-kernel inet_dist_listen_min 9100 +-kernel inet_dist_listen_max 9100 + +# Tell kernel and SASL not to log anything +-kernel error_logger silent +-sasl sasl_error_logger false + +# Use kernel poll functionality if supported by emulator ++K true + +# Start a pool of asynchronous IO threads ++A 16 + +# Comment this line out to enable the interactive Erlang shell on startup ++Bd -noinput diff --git a/i18n/README.de.md b/i18n/README.de.md index 34a9164c3f..a2f4c3afb9 100644 --- a/i18n/README.de.md +++ b/i18n/README.de.md @@ -39,7 +39,7 @@