diff --git a/Dockerfile b/Dockerfile index df4614a13..87c4d54c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,42 @@ -FROM node:16.14.0-alpine -RUN apk add --no-cache g++ cmake make python3 -WORKDIR /app -COPY package*.json . -RUN yarn install -COPY . . -RUN yarn build - -FROM node:16.14.0-alpine +FROM node:16.14.2-alpine as install WORKDIR /app -LABEL coolify.managed true - -RUN apk add --no-cache git git-lfs openssh-client curl jq cmake sqlite openssl - +RUN apk add --no-cache curl RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6 RUN pnpm add -g pnpm -RUN curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz" | tar -xzvf - docker/docker -C . --strip-components 1 && mv docker /usr/bin/docker -RUN mkdir -p ~/.docker/cli-plugins/ -RUN curl -SL https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose -RUN chmod +x ~/.docker/cli-plugins/docker-compose +COPY package*.json . +RUN pnpm install + +FROM node:16.14.2-alpine +ARG TARGETPLATFORM + +WORKDIR /app + +ENV PRISMA_QUERY_ENGINE_BINARY=/app/prisma-engines/query-engine \ + PRISMA_MIGRATION_ENGINE_BINARY=/app/prisma-engines/migration-engine \ + PRISMA_INTROSPECTION_ENGINE_BINARY=/app/prisma-engines/introspection-engine \ + PRISMA_FMT_BINARY=/app/prisma-engines/prisma-fmt \ + PRISMA_CLI_QUERY_ENGINE_TYPE=binary \ + PRISMA_CLIENT_ENGINE_TYPE=binary + +COPY --from=coollabsio/prisma-engine:latest /prisma-engines/query-engine /prisma-engines/migration-engine /prisma-engines/introspection-engine /prisma-engines/prisma-fmt /app/prisma-engines/ + +COPY --from=install /app/node_modules ./node_modules +COPY . . + +RUN apk add --no-cache git git-lfs openssh-client curl jq cmake sqlite openssl +RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6 +RUN pnpm add -g pnpm +RUN mkdir -p ~/.docker/cli-plugins/ +RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-20.10.9 -o /usr/bin/docker +RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-compose-linux-2.3.4 -o ~/.docker/cli-plugins/docker-compose +RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker + +RUN pnpm prisma generate +RUN pnpm build + -COPY --from=0 /app/docker-compose.yaml . -COPY --from=0 /app/build . -COPY --from=0 /app/package.json . -COPY --from=0 /app/node_modules ./node_modules -COPY --from=0 /app/prisma ./prisma EXPOSE 3000 CMD ["pnpm", "start"] \ No newline at end of file diff --git a/data/build-prisma-engine.sh b/data/build-prisma-engine.sh new file mode 100644 index 000000000..42c2af608 --- /dev/null +++ b/data/build-prisma-engine.sh @@ -0,0 +1 @@ +nohup docker build -t coollabsio/prisma-engine: --push . & \ No newline at end of file diff --git a/data/haproxy-http.Dockerfile b/data/haproxy-http.Dockerfile new file mode 100644 index 000000000..de5246628 --- /dev/null +++ b/data/haproxy-http.Dockerfile @@ -0,0 +1,6 @@ +FROM haproxytech/haproxy-alpine:2.5 +RUN mkdir -p /usr/local/etc/haproxy/ssl /usr/local/etc/haproxy/maps /usr/local/etc/haproxy/spoe + +COPY haproxy/haproxy.cfg-http.template /usr/local/etc/haproxy/haproxy.cfg +COPY haproxy/dataplaneapi.hcl /usr/local/etc/haproxy/dataplaneapi.hcl +COPY haproxy/ssl/default.pem /usr/local/etc/haproxy/ssl/default.pem \ No newline at end of file diff --git a/data/haproxy-tcp.Dockerfile b/data/haproxy-tcp.Dockerfile new file mode 100644 index 000000000..9b9639777 --- /dev/null +++ b/data/haproxy-tcp.Dockerfile @@ -0,0 +1,6 @@ +FROM haproxytech/haproxy-alpine:2.5 +RUN mkdir -p /usr/local/etc/haproxy/ssl /usr/local/etc/haproxy/maps /usr/local/etc/haproxy/spoe + +COPY haproxy/haproxy.cfg-tcp.template /usr/local/etc/haproxy/haproxy.cfg +COPY haproxy/dataplaneapi.hcl /usr/local/etc/haproxy/dataplaneapi.hcl +COPY haproxy/ssl/default.pem /usr/local/etc/haproxy/ssl/default.pem \ No newline at end of file diff --git a/data/haproxy.Dockerfile b/data/haproxy.Dockerfile new file mode 100644 index 000000000..3ab520a65 --- /dev/null +++ b/data/haproxy.Dockerfile @@ -0,0 +1,6 @@ +FROM haproxytech/haproxy-alpine:2.5 +RUN mkdir -p /usr/local/etc/haproxy/ssl /usr/local/etc/haproxy/maps /usr/local/etc/haproxy/spoe + +COPY haproxy/haproxy.cfg.template /usr/local/etc/haproxy/haproxy.cfg +COPY haproxy/dataplaneapi.hcl /usr/local/etc/haproxy/dataplaneapi.hcl +COPY haproxy/ssl/default.pem /usr/local/etc/haproxy/ssl/default.pem \ No newline at end of file diff --git a/data/haproxy/haproxy.cfg-http.template b/data/haproxy/haproxy.cfg-http.template index 72fdece7a..f819e9be7 100644 --- a/data/haproxy/haproxy.cfg-http.template +++ b/data/haproxy/haproxy.cfg-http.template @@ -4,10 +4,10 @@ global defaults mode http log global - timeout http-request 60s - timeout connect 10s - timeout client 60s - timeout server 60s + timeout http-request 120s + timeout connect 20s + timeout client 120s + timeout server 120s frontend "${APP}" mode http diff --git a/data/haproxy/haproxy.cfg.template b/data/haproxy/haproxy.cfg.template index c39cb7878..35cb8a74d 100644 --- a/data/haproxy/haproxy.cfg.template +++ b/data/haproxy/haproxy.cfg.template @@ -5,10 +5,10 @@ global defaults mode http log global - timeout http-request 60s - timeout connect 10s - timeout client 60s - timeout server 60s + timeout http-request 120s + timeout connect 20s + timeout client 120s + timeout server 120s userlist haproxy-dataplaneapi user admin insecure-password "${HAPROXY_PASSWORD}" diff --git a/data/prisma-engine.Dockerfile b/data/prisma-engine.Dockerfile new file mode 100644 index 000000000..086472e23 --- /dev/null +++ b/data/prisma-engine.Dockerfile @@ -0,0 +1,10 @@ +FROM rust:1.58.1-alpine3.14 as prisma +WORKDIR /prisma +ENV RUSTFLAGS="-C target-feature=-crt-static" +RUN apk --no-cache add openssl direnv git musl-dev openssl-dev build-base perl protoc +RUN git clone --depth=1 --branch=3.11.x https://github.com/prisma/prisma-engines.git /prisma +RUN cargo build --release + +FROM alpine +WORKDIR /prisma-engines +COPY --from=prisma /prisma/target/release/query-engine /prisma/target/release/migration-engine /prisma/target/release/introspection-engine /prisma/target/release/prisma-fmt /prisma-engines/ diff --git a/haproxy-http.Dockerfile b/haproxy-http.Dockerfile deleted file mode 100644 index 089ae0f96..000000000 --- a/haproxy-http.Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM haproxytech/haproxy-alpine:2.5 -RUN mkdir -p /usr/local/etc/haproxy/ssl /usr/local/etc/haproxy/maps /usr/local/etc/haproxy/spoe - -COPY data/haproxy/haproxy.cfg-http.template /usr/local/etc/haproxy/haproxy.cfg -COPY data/haproxy/dataplaneapi.hcl /usr/local/etc/haproxy/dataplaneapi.hcl -COPY data/haproxy/ssl/default.pem /usr/local/etc/haproxy/ssl/default.pem \ No newline at end of file diff --git a/haproxy-tcp.Dockerfile b/haproxy-tcp.Dockerfile deleted file mode 100644 index bddcbe541..000000000 --- a/haproxy-tcp.Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM haproxytech/haproxy-alpine:2.5 -RUN mkdir -p /usr/local/etc/haproxy/ssl /usr/local/etc/haproxy/maps /usr/local/etc/haproxy/spoe - -COPY data/haproxy/haproxy.cfg-tcp.template /usr/local/etc/haproxy/haproxy.cfg -COPY data/haproxy/dataplaneapi.hcl /usr/local/etc/haproxy/dataplaneapi.hcl -COPY data/haproxy/ssl/default.pem /usr/local/etc/haproxy/ssl/default.pem \ No newline at end of file diff --git a/haproxy.Dockerfile b/haproxy.Dockerfile deleted file mode 100644 index 45e2d9d71..000000000 --- a/haproxy.Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM haproxytech/haproxy-alpine:2.5 -RUN mkdir -p /usr/local/etc/haproxy/ssl /usr/local/etc/haproxy/maps /usr/local/etc/haproxy/spoe - -COPY data/haproxy/haproxy.cfg.template /usr/local/etc/haproxy/haproxy.cfg -COPY data/haproxy/dataplaneapi.hcl /usr/local/etc/haproxy/dataplaneapi.hcl -COPY data/haproxy/ssl/default.pem /usr/local/etc/haproxy/ssl/default.pem \ No newline at end of file diff --git a/package.json b/package.json index a272908c7..ceef4b161 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "2.4.2", + "version": "2.4.3", "license": "AGPL-3.0", "scripts": { "dev": "docker-compose -f docker-compose-dev.yaml up -d && cross-env NODE_ENV=development & svelte-kit dev", "dev:stop": "docker-compose -f docker-compose-dev.yaml down", "dev:logs": "docker-compose -f docker-compose-dev.yaml logs -f --tail 10", "studio": "npx prisma studio", - "start": "npx prisma migrate deploy && npx prisma generate && npx prisma db seed && node index.js", + "start": "npx prisma migrate deploy && npx prisma generate && npx prisma db seed && node build/index.js", "build": "svelte-kit build", "preview": "svelte-kit preview", "check": "svelte-check --tsconfig ./tsconfig.json", @@ -17,18 +17,17 @@ "db:push": "prisma db push && prisma generate", "db:seed": "prisma db seed", "db:migrate": "COOLIFY_DATABASE_URL=file:../db/migration.db prisma migrate dev --skip-seed --name", - "release:staging": "cross-var docker build -t coollabsio/coolify:$npm_package_version . && docker push coollabsio/coolify:$npm_package_version", - "release:pre": "cross-var docker build -t coollabsio/coolify:$npm_package_version -t coollabsio/coolify:latest .", - "release:coolify": "cross-var yarn release:pre && docker push coollabsio/coolify:$npm_package_version && docker push coollabsio/coolify:latest", - "release:haproxy": "docker build -f haproxy.Dockerfile -t coollabsio/coolify-haproxy-alpine:1.0.0 -t coollabsio/coolify-haproxy-alpine:latest . && docker image push --all-tags coollabsio/coolify-haproxy-alpine", - "release:haproxy:tcp": "docker build -f haproxy-tcp.Dockerfile -t coollabsio/coolify-haproxy-tcp-alpine:1.0.0 -t coollabsio/coolify-haproxy-tcp-alpine:latest . && docker image push --all-tags coollabsio/coolify-haproxy-tcp-alpine", - "release:haproxy:http": "docker build -f haproxy-http.Dockerfile -t coollabsio/coolify-haproxy-http-alpine:1.0.0 -t coollabsio/coolify-haproxy-http-alpine:latest . && docker image push --all-tags coollabsio/coolify-haproxy-http-alpine", + "release:production:all": "cross-var docker build --platform linux/amd64,linux/arm64 -t coollabsio/coolify:$npm_package_version -t coollabsio/coolify:latest --push .", + "release:staging:all": "cross-var docker build --platform linux/amd64,linux/arm64 -t coollabsio/coolify:$npm_package_version --push .", + "release:staging:amd": "cross-var docker build --platform linux/amd64 -t coollabsio/coolify:$npm_package_version --push .", + "release:haproxy": "docker build --platform linux/amd64,linux/arm64 -t coollabsio/coolify-haproxy-alpine:latest -t coollabsio/coolify-haproxy-alpine:1.1.0 -f haproxy.Dockerfile --push .", + "release:haproxy:tcp": "docker build --platform linux/amd64,linux/arm64 -t coollabsio/coolify-haproxy-tcp-alpine:latest -t coollabsio/coolify-haproxy-tcp-alpine:1.1.0 -f haproxy-tcp.Dockerfile --push .", + "release:haproxy:http": "docker build --platform linux/amd64,linux/arm64 -t coollabsio/coolify-haproxy-http-alpine:latest -t coollabsio/coolify-haproxy-http-alpine:1.1.0 -f haproxy-http.Dockerfile --push .", "prepare": "husky install" }, "devDependencies": { "@sveltejs/adapter-node": "1.0.0-next.73", - "@sveltejs/kit": "1.0.0-next.303", - "@types/bcrypt": "5.0.0", + "@sveltejs/kit": "1.0.0-next.310", "@types/js-cookie": "3.0.1", "@types/js-yaml": "4.0.5", "@types/node": "17.0.23", @@ -45,13 +44,13 @@ "husky": "7.0.4", "lint-staged": "12.3.7", "postcss": "8.4.12", - "prettier": "2.6.1", - "prettier-plugin-svelte": "2.6.0", + "prettier": "2.6.2", + "prettier-plugin-svelte": "2.7.0", "prettier-plugin-tailwindcss": "0.1.8", "prisma": "3.11.1", - "svelte": "3.46.4", - "svelte-check": "2.4.6", - "svelte-preprocess": "4.10.4", + "svelte": "3.47.0", + "svelte-check": "2.6.0", + "svelte-preprocess": "4.10.5", "svelte-select": "4.4.7", "tailwindcss": "3.0.23", "ts-node": "10.7.0", @@ -62,24 +61,23 @@ "dependencies": { "@iarna/toml": "2.2.5", "@prisma/client": "3.11.1", - "@sentry/node": "6.19.2", - "bcrypt": "5.0.1", - "bullmq": "1.78.1", + "@sentry/node": "6.19.6", + "bcryptjs": "^2.4.3", + "bullmq": "1.79.0", "compare-versions": "4.1.3", "cookie": "0.4.2", - "cooltipz-css": "2.1.0", "cuid": "2.1.8", "dayjs": "1.11.0", "dockerode": "3.3.1", "dotenv-extended": "2.9.0", "generate-password": "1.7.0", "get-port": "6.1.2", - "got": "12.0.2", + "got": "12.0.3", "js-cookie": "3.0.1", "js-yaml": "4.1.0", "jsonwebtoken": "8.5.1", "mustache": "4.2.0", - "node-forge": "1.3.0", + "node-forge": "1.3.1", "p-limit": "4.0.0", "svelte-kit-cookie-session": "2.1.2", "tailwindcss-scrollbar": "0.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 175ba2285..5577cc3fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,10 +3,9 @@ lockfileVersion: 5.3 specifiers: '@iarna/toml': 2.2.5 '@prisma/client': 3.11.1 - '@sentry/node': 6.19.2 + '@sentry/node': 6.19.6 '@sveltejs/adapter-node': 1.0.0-next.73 - '@sveltejs/kit': 1.0.0-next.303 - '@types/bcrypt': 5.0.0 + '@sveltejs/kit': 1.0.0-next.310 '@types/js-cookie': 3.0.1 '@types/js-yaml': 4.0.5 '@types/node': 17.0.23 @@ -15,11 +14,10 @@ specifiers: '@typescript-eslint/parser': 4.31.1 '@zerodevx/svelte-toast': 0.7.1 autoprefixer: 10.4.4 - bcrypt: 5.0.1 - bullmq: 1.78.1 + bcryptjs: ^2.4.3 + bullmq: 1.79.0 compare-versions: 4.1.3 cookie: 0.4.2 - cooltipz-css: 2.1.0 cross-env: 7.0.3 cross-var: 1.1.0 cuid: 2.1.8 @@ -31,24 +29,24 @@ specifiers: eslint-plugin-svelte3: 3.4.1 generate-password: 1.7.0 get-port: 6.1.2 - got: 12.0.2 + got: 12.0.3 husky: 7.0.4 js-cookie: 3.0.1 js-yaml: 4.1.0 jsonwebtoken: 8.5.1 lint-staged: 12.3.7 mustache: 4.2.0 - node-forge: 1.3.0 + node-forge: 1.3.1 p-limit: 4.0.0 postcss: 8.4.12 - prettier: 2.6.1 - prettier-plugin-svelte: 2.6.0 + prettier: 2.6.2 + prettier-plugin-svelte: 2.7.0 prettier-plugin-tailwindcss: 0.1.8 prisma: 3.11.1 - svelte: 3.46.4 - svelte-check: 2.4.6 + svelte: 3.47.0 + svelte-check: 2.6.0 svelte-kit-cookie-session: 2.1.2 - svelte-preprocess: 4.10.4 + svelte-preprocess: 4.10.5 svelte-select: 4.4.7 tailwindcss: 3.0.23 tailwindcss-scrollbar: 0.1.0 @@ -60,24 +58,23 @@ specifiers: dependencies: '@iarna/toml': 2.2.5 '@prisma/client': 3.11.1_prisma@3.11.1 - '@sentry/node': 6.19.2 - bcrypt: 5.0.1 - bullmq: 1.78.1 + '@sentry/node': 6.19.6 + bcryptjs: 2.4.3 + bullmq: 1.79.0 compare-versions: 4.1.3 cookie: 0.4.2 - cooltipz-css: 2.1.0 cuid: 2.1.8 dayjs: 1.11.0 dockerode: 3.3.1 dotenv-extended: 2.9.0 generate-password: 1.7.0 get-port: 6.1.2 - got: 12.0.2 + got: 12.0.3 js-cookie: 3.0.1 js-yaml: 4.1.0 jsonwebtoken: 8.5.1 mustache: 4.2.0 - node-forge: 1.3.0 + node-forge: 1.3.1 p-limit: 4.0.0 svelte-kit-cookie-session: 2.1.2 tailwindcss-scrollbar: 0.1.0_tailwindcss@3.0.23 @@ -85,8 +82,7 @@ dependencies: devDependencies: '@sveltejs/adapter-node': 1.0.0-next.73 - '@sveltejs/kit': 1.0.0-next.303_svelte@3.46.4 - '@types/bcrypt': 5.0.0 + '@sveltejs/kit': 1.0.0-next.310_svelte@3.47.0 '@types/js-cookie': 3.0.1 '@types/js-yaml': 4.0.5 '@types/node': 17.0.23 @@ -99,17 +95,17 @@ devDependencies: cross-var: 1.1.0 eslint: 7.32.0 eslint-config-prettier: 8.5.0_eslint@7.32.0 - eslint-plugin-svelte3: 3.4.1_eslint@7.32.0+svelte@3.46.4 + eslint-plugin-svelte3: 3.4.1_eslint@7.32.0+svelte@3.47.0 husky: 7.0.4 lint-staged: 12.3.7 postcss: 8.4.12 - prettier: 2.6.1 - prettier-plugin-svelte: 2.6.0_prettier@2.6.1+svelte@3.46.4 - prettier-plugin-tailwindcss: 0.1.8_prettier@2.6.1 + prettier: 2.6.2 + prettier-plugin-svelte: 2.7.0_prettier@2.6.2+svelte@3.47.0 + prettier-plugin-tailwindcss: 0.1.8_prettier@2.6.2 prisma: 3.11.1 - svelte: 3.46.4 - svelte-check: 2.4.6_postcss@8.4.12+svelte@3.46.4 - svelte-preprocess: 4.10.4_296873641a0ad9f42fe92172d27bcedd + svelte: 3.47.0 + svelte-check: 2.6.0_postcss@8.4.12+svelte@3.47.0 + svelte-preprocess: 4.10.5_41810887ae6c6d59323116f47e33fa38 svelte-select: 4.4.7 tailwindcss: 3.0.23_b89136460714832cdda11d1e9d57d1ff ts-node: 10.7.0_ee885bc7281b682b6adbed6ae09ee090 @@ -212,26 +208,6 @@ packages: } dev: false - /@mapbox/node-pre-gyp/1.0.6: - resolution: - { - integrity: sha512-qK1ECws8UxuPqOA8F5LFD90vyVU33W7N3hGfgsOVfrJaRVc8McC3JClTDHpeSbL9CBrOHly/4GsNPAvIgNZE+g== - } - hasBin: true - dependencies: - detect-libc: 1.0.3 - https-proxy-agent: 5.0.0 - make-dir: 3.1.0 - node-fetch: 2.6.6 - nopt: 5.0.0 - npmlog: 5.0.1 - rimraf: 3.0.2 - semver: 7.3.5 - tar: 6.1.11 - transitivePeerDependencies: - - supports-color - dev: false - /@nodelib/fs.scandir/2.1.5: resolution: { @@ -305,55 +281,55 @@ packages: picomatch: 2.3.0 dev: true - /@sentry/core/6.19.2: + /@sentry/core/6.19.6: resolution: { - integrity: sha512-yu1R3ewBT4udmB4v7sc4biQZ0Z0rfB9+TzB5ZKoCftbe6kqXjFMMaFRYNUF9HicVldKAsBktgkWw3+yfqGkw/A== + integrity: sha512-biEotGRr44/vBCOegkTfC9rwqaqRKIpFljKGyYU6/NtzMRooktqOhjmjmItNCMRknArdeaQwA8lk2jcZDXX3Og== } engines: { node: '>=6' } dependencies: - '@sentry/hub': 6.19.2 - '@sentry/minimal': 6.19.2 - '@sentry/types': 6.19.2 - '@sentry/utils': 6.19.2 + '@sentry/hub': 6.19.6 + '@sentry/minimal': 6.19.6 + '@sentry/types': 6.19.6 + '@sentry/utils': 6.19.6 tslib: 1.14.1 dev: false - /@sentry/hub/6.19.2: + /@sentry/hub/6.19.6: resolution: { - integrity: sha512-W7KCgNBgdBIMagOxy5J5KQPe+maYxSqfE8a5ncQ3R8BcZDQEKnkW/1FplNbfRLZqA/tL/ndKb7pTPqVtzsbARw== + integrity: sha512-PuEOBZxvx3bjxcXmWWZfWXG+orojQiWzv9LQXjIgroVMKM/GG4QtZbnWl1hOckUj7WtKNl4hEGO2g/6PyCV/vA== } engines: { node: '>=6' } dependencies: - '@sentry/types': 6.19.2 - '@sentry/utils': 6.19.2 + '@sentry/types': 6.19.6 + '@sentry/utils': 6.19.6 tslib: 1.14.1 dev: false - /@sentry/minimal/6.19.2: + /@sentry/minimal/6.19.6: resolution: { - integrity: sha512-ClwxKm77iDHET7kpzv1JvzDx1er5DoNu+EUjst0kQzARIrXvu9xuZuE2/CnBWycQWqw8o3HoGoKz65uIhsUCzQ== + integrity: sha512-T1NKcv+HTlmd8EbzUgnGPl4ySQGHWMCyZ8a8kXVMZOPDzphN3fVIzkYzWmSftCWp0rpabXPt9aRF2mfBKU+mAQ== } engines: { node: '>=6' } dependencies: - '@sentry/hub': 6.19.2 - '@sentry/types': 6.19.2 + '@sentry/hub': 6.19.6 + '@sentry/types': 6.19.6 tslib: 1.14.1 dev: false - /@sentry/node/6.19.2: + /@sentry/node/6.19.6: resolution: { - integrity: sha512-Z1qREpTpYHxaeWjc1zMUk8ZTAp1WbxMiI2TVNc+a14DVT19Z2xNXb06MiRfeLgNc9lVGdmzR62dPmMBjVgPJYg== + integrity: sha512-kHQMfsy40ZxxdS9zMPmXCOOLWOJbQj6/aVSHt/L1QthYcgkAi7NJQNXnQIPWQDe8eP3DfNIWM7dc446coqjXrQ== } engines: { node: '>=6' } dependencies: - '@sentry/core': 6.19.2 - '@sentry/hub': 6.19.2 - '@sentry/types': 6.19.2 - '@sentry/utils': 6.19.2 + '@sentry/core': 6.19.6 + '@sentry/hub': 6.19.6 + '@sentry/types': 6.19.6 + '@sentry/utils': 6.19.6 cookie: 0.4.2 https-proxy-agent: 5.0.0 lru_map: 0.3.3 @@ -362,22 +338,22 @@ packages: - supports-color dev: false - /@sentry/types/6.19.2: + /@sentry/types/6.19.6: resolution: { - integrity: sha512-XO5qmVBdTs+7PdCz7fAwn1afWxSnRE2KLBFg5/vOdKosPSSHsSHUURSkxiEZc2QsR+JpRB4AeQ26AkIRX38qTg== + integrity: sha512-QH34LMJidEUPZK78l+Frt3AaVFJhEmIi05Zf8WHd9/iTt+OqvCHBgq49DDr1FWFqyYWm/QgW/3bIoikFpfsXyQ== } engines: { node: '>=6' } dev: false - /@sentry/utils/6.19.2: + /@sentry/utils/6.19.6: resolution: { - integrity: sha512-2DQQ2OJaxjtyxGq5FmMlqb6hptsqMs2xoBiVRMkTS/rvyTrk1oQdKZ8ePwjtgX3nJ728ni3IXIyXV+vfGp4EBw== + integrity: sha512-fAMWcsguL0632eWrROp/vhPgI7sBj/JROWVPzpabwVkm9z3m1rQm6iLFn4qfkZL8Ozy6NVZPXOQ7EXmeU24byg== } engines: { node: '>=6' } dependencies: - '@sentry/types': 6.19.2 + '@sentry/types': 6.19.6 tslib: 1.14.1 dev: false @@ -398,20 +374,20 @@ packages: tiny-glob: 0.2.9 dev: true - /@sveltejs/kit/1.0.0-next.303_svelte@3.46.4: + /@sveltejs/kit/1.0.0-next.310_svelte@3.47.0: resolution: { - integrity: sha512-WdxDc8OiF1WEd/bEza7CBdzA+3qIcCi1GKBj/gieKX9I3N8iDJt/Cg2POrLo9wQoJ47nZcAd1eOhfr7XEX1aIQ== + integrity: sha512-pTyMyaoyHS+V5cQZIQMfQXmLkhw1VaRwT9avOSgwDc0QBpnNw2LdzwoPYsUr96ca5B6cfT3SMUNolxErTNHmPQ== } engines: { node: '>=14.13' } hasBin: true peerDependencies: svelte: ^3.44.0 dependencies: - '@sveltejs/vite-plugin-svelte': 1.0.0-next.33_svelte@3.46.4+vite@2.8.0 + '@sveltejs/vite-plugin-svelte': 1.0.0-next.33_svelte@3.47.0+vite@2.9.1 sade: 1.7.4 - svelte: 3.46.4 - vite: 2.8.0 + svelte: 3.47.0 + vite: 2.9.1 transitivePeerDependencies: - diff-match-patch - less @@ -420,7 +396,7 @@ packages: - supports-color dev: true - /@sveltejs/vite-plugin-svelte/1.0.0-next.33_svelte@3.46.4+vite@2.8.0: + /@sveltejs/vite-plugin-svelte/1.0.0-next.33_svelte@3.47.0+vite@2.9.1: resolution: { integrity: sha512-aj0h2+ZixgT+yoJFIs8dRRw/Cj9tgNu3+hY4CJikpa04mfhR61wXqJFfi2ZEFMUvFda5nCxKYIChFkc6wq5fJA== @@ -439,9 +415,9 @@ packages: kleur: 4.1.4 magic-string: 0.25.7 require-relative: 0.8.7 - svelte: 3.46.4 - svelte-hmr: 0.14.9_svelte@3.46.4 - vite: 2.8.0 + svelte: 3.47.0 + svelte-hmr: 0.14.9_svelte@3.47.0 + vite: 2.9.1 transitivePeerDependencies: - supports-color dev: true @@ -484,15 +460,6 @@ packages: } dev: true - /@types/bcrypt/5.0.0: - resolution: - { - integrity: sha512-agtcFKaruL8TmcvqbndlqHPSJgsolhf/qPWchFlgnW1gECTN/nKbFcoFnvKAQRFfKbh+BO6A3SWdJu9t+xF3Lw== - } - dependencies: - '@types/node': 17.0.23 - dev: true - /@types/cacheable-request/6.0.2: resolution: { @@ -722,13 +689,6 @@ packages: } dev: true - /abbrev/1.1.1: - resolution: - { - integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== - } - dev: false - /acorn-jsx/5.3.2_acorn@7.4.1: resolution: { @@ -855,17 +815,13 @@ packages: engines: { node: '>=0.10.0' } dev: true - /ansi-regex/3.0.0: - resolution: { integrity: sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= } - engines: { node: '>=4' } - dev: false - /ansi-regex/5.0.1: resolution: { integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== } engines: { node: '>=8' } + dev: true /ansi-regex/6.0.1: resolution: @@ -919,24 +875,6 @@ packages: picomatch: 2.3.0 dev: true - /aproba/2.0.0: - resolution: - { - integrity: sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ== - } - dev: false - - /are-we-there-yet/2.0.0: - resolution: - { - integrity: sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw== - } - engines: { node: '>=10' } - dependencies: - delegates: 1.0.0 - readable-stream: 3.6.0 - dev: false - /arg/4.1.3: resolution: { @@ -1656,18 +1594,8 @@ packages: tweetnacl: 0.14.5 dev: false - /bcrypt/5.0.1: - resolution: - { - integrity: sha512-9BTgmrhZM2t1bNuDtrtIMVSmmxZBrJ71n8Wg+YgdjHuIWYF7SjjmCPZFB+/5i/o/PIeRpwVJR3P+NrpIItUjqw== - } - engines: { node: '>= 10.0.0' } - requiresBuild: true - dependencies: - '@mapbox/node-pre-gyp': 1.0.6 - node-addon-api: 3.2.1 - transitivePeerDependencies: - - supports-color + /bcryptjs/2.4.3: + resolution: { integrity: sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms= } dev: false /binary-extensions/2.2.0: @@ -1741,10 +1669,10 @@ packages: ieee754: 1.2.1 dev: false - /bullmq/1.78.1: + /bullmq/1.79.0: resolution: { - integrity: sha512-er45mM8nGhgA83EVCJ4PNxPyDSzakvoxeFGU4vdSgYeB+SbeFQAlJYmAC50Ms7YFPstm1LeinbVZ+oX/BmBzOg== + integrity: sha512-rVtNCDpcWdc+U1MinRtvhJv+GBFNkz0Q3Unf20010qIC6Pj+O2kkIUeepBkCmMNz6G9abrhsee2PheGRJ32+sw== } dependencies: cron-parser: 4.2.1 @@ -1874,14 +1802,6 @@ packages: } dev: false - /chownr/2.0.0: - resolution: - { - integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== - } - engines: { node: '>=10' } - dev: false - /clean-stack/2.2.0: resolution: { @@ -1966,14 +1886,6 @@ packages: } dev: true - /color-support/1.1.3: - resolution: - { - integrity: sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== - } - hasBin: true - dev: false - /colorette/2.0.16: resolution: { @@ -1999,10 +1911,6 @@ packages: /concat-map/0.0.1: resolution: { integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= } - /console-control-strings/1.1.0: - resolution: { integrity: sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= } - dev: false - /convert-source-map/1.8.0: resolution: { @@ -2020,19 +1928,6 @@ packages: engines: { node: '>= 0.6' } dev: false - /cooltipz-css/2.1.0: - resolution: - { - integrity: sha512-howXMSGn4tYvroGUad5jg1QFKUMxxc2GiQSXrv6TQBIMmhrf8t//hz1Fx8eyc5t93SS9ZzUa5rHbPtjBTg5j1w== - } - engines: { node: '>=16', npm: '>=8' } - peerDependencies: - sass: 1.x - peerDependenciesMeta: - sass: - optional: true - dev: false - /core-js/2.6.12: resolution: { @@ -2217,10 +2112,6 @@ packages: resolution: { integrity: sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM= } dev: true - /delegates/1.0.0: - resolution: { integrity: sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= } - dev: false - /denque/1.5.1: resolution: { @@ -2244,12 +2135,6 @@ packages: engines: { node: '>=8' } dev: true - /detect-libc/1.0.3: - resolution: { integrity: sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= } - engines: { node: '>=0.10' } - hasBin: true - dev: false - /detective/5.2.0: resolution: { @@ -2383,6 +2268,7 @@ packages: { integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== } + dev: true /emoji-regex/9.2.2: resolution: @@ -2423,10 +2309,22 @@ packages: resolution: { integrity: sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM= } dev: true - /esbuild-android-arm64/0.14.21: + /esbuild-android-64/0.14.34: resolution: { - integrity: sha512-Bqgld1TY0wZv8TqiQmVxQFgYzz8ZmyzT7clXBDZFkOOdRybzsnj8AZuK1pwcLVA7Ya6XncHgJqIao7NFd3s0RQ== + integrity: sha512-XfxcfJqmMYsT/LXqrptzFxmaR3GWzXHDLdFNIhm6S00zPaQF1TBBWm+9t0RZ6LRR7iwH57DPjaOeW20vMqI4Yw== + } + engines: { node: '>=12' } + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /esbuild-android-arm64/0.14.34: + resolution: + { + integrity: sha512-T02+NXTmSRL1Mc6puz+R9CB54rSPICkXKq6+tw8B6vxZFnCPzbJxgwIX4kcluz9p8nYBjF3+lSilTGWb7+Xgew== } engines: { node: '>=12' } cpu: [arm64] @@ -2435,10 +2333,10 @@ packages: dev: true optional: true - /esbuild-darwin-64/0.14.21: + /esbuild-darwin-64/0.14.34: resolution: { - integrity: sha512-j+Eg+e13djzyYINVvAbOo2/zvZ2DivuJJTaBrJnJHSD7kUNuGHRkHoSfFjbI80KHkn091w350wdmXDNSgRjfYQ== + integrity: sha512-pLRip2Bh4Ng7Bf6AMgCrSp3pPe/qZyf11h5Qo2mOfJqLWzSVjxrXW+CFRJfrOVP7TCnh/gmZSM2AFdCPB72vtw== } engines: { node: '>=12' } cpu: [x64] @@ -2447,10 +2345,10 @@ packages: dev: true optional: true - /esbuild-darwin-arm64/0.14.21: + /esbuild-darwin-arm64/0.14.34: resolution: { - integrity: sha512-nDNTKWDPI0RuoPj5BhcSB2z5EmZJJAyRtZLIjyXSqSpAyoB8eyAKXl4lB8U2P78Fnh4Lh1le/fmpewXE04JhBQ== + integrity: sha512-vpidSJEBxx6lf1NWgXC+DCmGqesJuZ5Y8aQVVsaoO4i8tRXbXb0whChRvop/zd3nfNM4dIl5EXAky0knRX5I6w== } engines: { node: '>=12' } cpu: [arm64] @@ -2459,10 +2357,10 @@ packages: dev: true optional: true - /esbuild-freebsd-64/0.14.21: + /esbuild-freebsd-64/0.14.34: resolution: { - integrity: sha512-zIurkCHXhxELiDZtLGiexi8t8onQc2LtuE+S7457H/pP0g0MLRKMrsn/IN4LDkNe6lvBjuoZZi2OfelOHn831g== + integrity: sha512-m0HBjePhe0hAQJgtMRMNV9kMgIyV4/qSnzPx42kRMQBcPhgjAq1JRu4Il26czC+9FgpMbFkUktb07f/Lwnc6CA== } engines: { node: '>=12' } cpu: [x64] @@ -2471,10 +2369,10 @@ packages: dev: true optional: true - /esbuild-freebsd-arm64/0.14.21: + /esbuild-freebsd-arm64/0.14.34: resolution: { - integrity: sha512-wdxMmkJfbwcN+q85MpeUEamVZ40FNsBa9mPq8tAszDn8TRT2HoJvVRADPIIBa9SWWwlDChIMjkDKAnS3KS/sPA== + integrity: sha512-cpRc2B94L1KvMPPYB4D6G39jLqpKlD3noAMY4/e86iXXXkhUYJJEtTuyNFTa9JRpWM0xCAp4mxjHjoIiLuoCLA== } engines: { node: '>=12' } cpu: [arm64] @@ -2483,10 +2381,10 @@ packages: dev: true optional: true - /esbuild-linux-32/0.14.21: + /esbuild-linux-32/0.14.34: resolution: { - integrity: sha512-fmxvyzOPPh2xiEHojpCeIQP6pXcoKsWbz3ryDDIKLOsk4xp3GbpHIEAWP0xTeuhEbendmvBDVKbAVv3PnODXLg== + integrity: sha512-8nQaEaoW7MH/K/RlozJa+lE1ejHIr8fuPIHhc513UebRav7HtXgQvxHQ6VZRUkWtep23M6dd7UqhwO1tMOfzQQ== } engines: { node: '>=12' } cpu: [ia32] @@ -2495,10 +2393,10 @@ packages: dev: true optional: true - /esbuild-linux-64/0.14.21: + /esbuild-linux-64/0.14.34: resolution: { - integrity: sha512-edZyNOv1ql+kpmlzdqzzDjRQYls+tSyi4QFi+PdBhATJFUqHsnNELWA9vMSzAaInPOEaVUTA5Ml28XFChcy4DA== + integrity: sha512-Y3of4qQoLLlAgf042MlrY1P+7PnN9zWj8nVtw9XQG5hcLOZLz7IKpU35oeu7n4wvyaZHwvQqDJ93gRLqdJekcQ== } engines: { node: '>=12' } cpu: [x64] @@ -2507,10 +2405,10 @@ packages: dev: true optional: true - /esbuild-linux-arm/0.14.21: + /esbuild-linux-arm/0.14.34: resolution: { - integrity: sha512-aSU5pUueK6afqmLQsbU+QcFBT62L+4G9hHMJDHWfxgid6hzhSmfRH9U/f+ymvxsSTr/HFRU4y7ox8ZyhlVl98w== + integrity: sha512-9lpq1NcJqssAF7alCO6zL3gvBVVt/lKw4oetUM7OgNnRX0OWpB+ZIO9FwCrSj/dMdmgDhPLf+119zB8QxSMmAg== } engines: { node: '>=12' } cpu: [arm] @@ -2519,10 +2417,10 @@ packages: dev: true optional: true - /esbuild-linux-arm64/0.14.21: + /esbuild-linux-arm64/0.14.34: resolution: { - integrity: sha512-t5qxRkq4zdQC0zXpzSB2bTtfLgOvR0C6BXYaRE/6/k8/4SrkZcTZBeNu+xGvwCU4b5dU9ST9pwIWkK6T1grS8g== + integrity: sha512-IlWaGtj9ir7+Nrume1DGcyzBDlK8GcnJq0ANKwcI9pVw8tqr+6GD0eqyF9SF1mR8UmAp+odrx1H5NdR2cHdFHA== } engines: { node: '>=12' } cpu: [arm64] @@ -2531,10 +2429,10 @@ packages: dev: true optional: true - /esbuild-linux-mips64le/0.14.21: + /esbuild-linux-mips64le/0.14.34: resolution: { - integrity: sha512-jLZLQGCNlUsmIHtGqNvBs3zN+7a4D9ckf0JZ+jQTwHdZJ1SgV9mAjbB980OFo66LoY+WeM7t3WEnq3FjI1zw4A== + integrity: sha512-k3or+01Rska1AjUyNjA4buEwB51eyN/xPQAoOx1CjzAQC3l8rpjUDw55kXyL63O/1MUi4ISvtNtl8gLwdyEcxw== } engines: { node: '>=12' } cpu: [mips64el] @@ -2543,10 +2441,10 @@ packages: dev: true optional: true - /esbuild-linux-ppc64le/0.14.21: + /esbuild-linux-ppc64le/0.14.34: resolution: { - integrity: sha512-4TWxpK391en2UBUw6GSrukToTDu6lL9vkm3Ll40HrI08WG3qcnJu7bl8e1+GzelDsiw1QmfAY/nNvJ6iaHRpCQ== + integrity: sha512-+qxb8M9FfM2CJaVU7GgYpJOHM1ngQOx+/VrtBjb4C8oVqaPcESCeg2anjl+HRZy8VpYc71q/iBYausPPbJ+Keg== } engines: { node: '>=12' } cpu: [ppc64] @@ -2555,10 +2453,10 @@ packages: dev: true optional: true - /esbuild-linux-riscv64/0.14.21: + /esbuild-linux-riscv64/0.14.34: resolution: { - integrity: sha512-fElngqOaOfTsF+u+oetDLHsPG74vB2ZaGZUqmGefAJn3a5z9Z2pNa4WpVbbKgHpaAAy5tWM1m1sbGohj6Ki6+Q== + integrity: sha512-Y717ltBdQ5j5sZIHdy1DV9kieo0wMip0dCmVSTceowCPYSn1Cg33Kd6981+F/3b9FDMzNWldZFOBRILViENZSA== } engines: { node: '>=12' } cpu: [riscv64] @@ -2567,10 +2465,10 @@ packages: dev: true optional: true - /esbuild-linux-s390x/0.14.21: + /esbuild-linux-s390x/0.14.34: resolution: { - integrity: sha512-brleZ6R5fYv0qQ7ZBwenQmP6i9TdvJCB092c/3D3pTLQHBGHJb5zWgKxOeS7bdHzmLy6a6W7GbFk6QKpjyD6QA== + integrity: sha512-bDDgYO4LhL4+zPs+WcBkXph+AQoPcQRTv18FzZS0WhjfH8TZx2QqlVPGhmhZ6WidrY+jKthUqO6UhGyIb4MpmA== } engines: { node: '>=12' } cpu: [s390x] @@ -2579,10 +2477,10 @@ packages: dev: true optional: true - /esbuild-netbsd-64/0.14.21: + /esbuild-netbsd-64/0.14.34: resolution: { - integrity: sha512-nCEgsLCQ8RoFWVV8pVI+kX66ICwbPP/M9vEa0NJGIEB/Vs5sVGMqkf67oln90XNSkbc0bPBDuo4G6FxlF7PN8g== + integrity: sha512-cfaFGXdRt0+vHsjNPyF0POM4BVSHPSbhLPe8mppDc7GDDxjIl08mV1Zou14oDWMp/XZMjYN1kWYRSfftiD0vvQ== } engines: { node: '>=12' } cpu: [x64] @@ -2591,10 +2489,10 @@ packages: dev: true optional: true - /esbuild-openbsd-64/0.14.21: + /esbuild-openbsd-64/0.14.34: resolution: { - integrity: sha512-h9zLMyVD0T73MDTVYIb/qUTokwI6EJH9O6wESuTNq6+XpMSr6C5aYZ4fvFKdNELW+Xsod+yDS2hV2JTUAbFrLA== + integrity: sha512-vmy9DxXVnRiI14s8GKuYBtess+EVcDALkbpTqd5jw4XITutIzyB7n4x0Tj5utAkKsgZJB22lLWGekr0ABnSLow== } engines: { node: '>=12' } cpu: [x64] @@ -2603,10 +2501,10 @@ packages: dev: true optional: true - /esbuild-sunos-64/0.14.21: + /esbuild-sunos-64/0.14.34: resolution: { - integrity: sha512-Kl+7Cot32qd9oqpLdB1tEGXEkjBlijrIxMJ0+vlDFaqsODutif25on0IZlFxEBtL2Gosd4p5WCV1U7UskNQfXA== + integrity: sha512-eNPVatNET1F7tRMhii7goL/eptfxc0ALRjrj9SPFNqp0zmxrehBFD6BaP3R4LjMn6DbMO0jOAnTLFKr8NqcJAA== } engines: { node: '>=12' } cpu: [x64] @@ -2615,10 +2513,10 @@ packages: dev: true optional: true - /esbuild-windows-32/0.14.21: + /esbuild-windows-32/0.14.34: resolution: { - integrity: sha512-V7vnTq67xPBUCk/9UtlolmQ798Ecjdr1ZoI1vcSgw7M82aSSt0eZdP6bh5KAFZU8pxDcx3qoHyWQfHYr11f22A== + integrity: sha512-EFhpXyHEcnqWYe2rAHFd8dRw8wkrd9U+9oqcyoEL84GbanAYjiiIjBZsnR8kl0sCQ5w6bLpk7vCEIA2VS32Vcg== } engines: { node: '>=12' } cpu: [ia32] @@ -2627,10 +2525,10 @@ packages: dev: true optional: true - /esbuild-windows-64/0.14.21: + /esbuild-windows-64/0.14.34: resolution: { - integrity: sha512-kDgHjKOHwjfJDCyRGELzVxiP/RBJBTA+wyspf78MTTJQkyPuxH2vChReNdWc+dU2S4gIZFHMdP1Qrl/k22ZmaA== + integrity: sha512-a8fbl8Ky7PxNEjf1aJmtxdDZj32/hC7S1OcA2ckEpCJRTjiKslI9vAdPpSjrKIWhws4Galpaawy0nB7fjHYf5Q== } engines: { node: '>=12' } cpu: [x64] @@ -2639,10 +2537,10 @@ packages: dev: true optional: true - /esbuild-windows-arm64/0.14.21: + /esbuild-windows-arm64/0.14.34: resolution: { - integrity: sha512-8Sbo0zpzgwWrwjQYLmHF78f7E2xg5Ve63bjB2ng3V2aManilnnTGaliq2snYg+NOX60+hEvJHRdVnuIAHW0lVw== + integrity: sha512-EYvmKbSa2B3sPnpC28UEu9jBK5atGV4BaVRE7CYGUci2Hlz4AvtV/LML+TcDMT6gBgibnN2gcltWclab3UutMg== } engines: { node: '>=12' } cpu: [arm64] @@ -2651,34 +2549,35 @@ packages: dev: true optional: true - /esbuild/0.14.21: + /esbuild/0.14.34: resolution: { - integrity: sha512-7WEoNMBJdLN993dr9h0CpFHPRc3yFZD+EAVY9lg6syJJ12gc5fHq8d75QRExuhnMkT2DaRiIKFThRvDWP+fO+A== + integrity: sha512-QIWdPT/gFF6hCaf4m7kP0cJ+JIuFkdHibI7vVFvu3eJS1HpVmYHWDulyN5WXwbRA0SX/7ZDaJ/1DH8SdY9xOJg== } engines: { node: '>=12' } hasBin: true requiresBuild: true optionalDependencies: - esbuild-android-arm64: 0.14.21 - esbuild-darwin-64: 0.14.21 - esbuild-darwin-arm64: 0.14.21 - esbuild-freebsd-64: 0.14.21 - esbuild-freebsd-arm64: 0.14.21 - esbuild-linux-32: 0.14.21 - esbuild-linux-64: 0.14.21 - esbuild-linux-arm: 0.14.21 - esbuild-linux-arm64: 0.14.21 - esbuild-linux-mips64le: 0.14.21 - esbuild-linux-ppc64le: 0.14.21 - esbuild-linux-riscv64: 0.14.21 - esbuild-linux-s390x: 0.14.21 - esbuild-netbsd-64: 0.14.21 - esbuild-openbsd-64: 0.14.21 - esbuild-sunos-64: 0.14.21 - esbuild-windows-32: 0.14.21 - esbuild-windows-64: 0.14.21 - esbuild-windows-arm64: 0.14.21 + esbuild-android-64: 0.14.34 + esbuild-android-arm64: 0.14.34 + esbuild-darwin-64: 0.14.34 + esbuild-darwin-arm64: 0.14.34 + esbuild-freebsd-64: 0.14.34 + esbuild-freebsd-arm64: 0.14.34 + esbuild-linux-32: 0.14.34 + esbuild-linux-64: 0.14.34 + esbuild-linux-arm: 0.14.34 + esbuild-linux-arm64: 0.14.34 + esbuild-linux-mips64le: 0.14.34 + esbuild-linux-ppc64le: 0.14.34 + esbuild-linux-riscv64: 0.14.34 + esbuild-linux-s390x: 0.14.34 + esbuild-netbsd-64: 0.14.34 + esbuild-openbsd-64: 0.14.34 + esbuild-sunos-64: 0.14.34 + esbuild-windows-32: 0.14.34 + esbuild-windows-64: 0.14.34 + esbuild-windows-arm64: 0.14.34 dev: true /escalade/3.1.1: @@ -2714,7 +2613,7 @@ packages: eslint: 7.32.0 dev: true - /eslint-plugin-svelte3/3.4.1_eslint@7.32.0+svelte@3.46.4: + /eslint-plugin-svelte3/3.4.1_eslint@7.32.0+svelte@3.47.0: resolution: { integrity: sha512-7p59WG8qV8L6wLdl4d/c3mdjkgVglQCdv5XOTk/iNPBKXuuV+Q0eFP5Wa6iJd/G2M1qR3BkLPEzaANOqKAZczw== @@ -2725,7 +2624,7 @@ packages: svelte: ^3.2.0 dependencies: eslint: 7.32.0 - svelte: 3.46.4 + svelte: 3.47.0 dev: true /eslint-scope/5.1.1: @@ -3025,16 +2924,6 @@ packages: } dev: false - /fs-minipass/2.1.0: - resolution: - { - integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== - } - engines: { node: '>= 8' } - dependencies: - minipass: 3.1.5 - dev: false - /fs.realpath/1.0.0: resolution: { integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8= } @@ -3069,24 +2958,6 @@ packages: resolution: { integrity: sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= } dev: true - /gauge/3.0.1: - resolution: - { - integrity: sha512-6STz6KdQgxO4S/ko+AbjlFGGdGcknluoqU+79GOFCDqqyYj5OanQf9AjxwN0jCidtT+ziPMmPSt9E4hfQ0CwIQ== - } - engines: { node: '>=10' } - dependencies: - aproba: 2.0.0 - color-support: 1.1.3 - console-control-strings: 1.1.0 - has-unicode: 2.0.1 - object-assign: 4.1.1 - signal-exit: 3.0.5 - string-width: 2.1.1 - strip-ansi: 4.0.0 - wide-align: 1.1.5 - dev: false - /generate-password/1.7.0: resolution: { @@ -3207,10 +3078,10 @@ packages: } dev: true - /got/12.0.2: + /got/12.0.3: resolution: { - integrity: sha512-Zi4yHiqCgaorUbknr/RHFBsC3XqjSodaw0F3qxlqAqyj+OGYZl37/uy01R0qz++KANKQYdY5FHJ0okXZpEzwWQ== + integrity: sha512-hmdcXi/S0gcAtDg4P8j/rM7+j3o1Aq6bXhjxkDhRY2ipe7PHpvx/14DgTY2czHOLaGeU8VRvRecidwfu9qdFug== } engines: { node: '>=14.16' } dependencies: @@ -3256,10 +3127,6 @@ packages: engines: { node: '>=8' } dev: true - /has-unicode/2.0.1: - resolution: { integrity: sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= } - dev: false - /has/1.0.3: resolution: { @@ -3472,17 +3339,13 @@ packages: engines: { node: '>=0.10.0' } dev: true - /is-fullwidth-code-point/2.0.0: - resolution: { integrity: sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= } - engines: { node: '>=4' } - dev: false - /is-fullwidth-code-point/3.0.0: resolution: { integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== } engines: { node: '>=8' } + dev: true /is-fullwidth-code-point/4.0.0: resolution: @@ -3854,6 +3717,7 @@ packages: engines: { node: '>=10' } dependencies: yallist: 4.0.0 + dev: true /lru_map/0.3.3: resolution: { integrity: sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0= } @@ -3875,16 +3739,6 @@ packages: sourcemap-codec: 1.4.8 dev: true - /make-dir/3.1.0: - resolution: - { - integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== - } - engines: { node: '>=8' } - dependencies: - semver: 6.3.0 - dev: false - /make-error/1.3.6: resolution: { @@ -3965,27 +3819,6 @@ packages: } dev: true - /minipass/3.1.5: - resolution: - { - integrity: sha512-+8NzxD82XQoNKNrl1d/FSi+X8wAEWR+sbYAfIvub4Nz0d22plFG72CEVVaufV8PNf4qSslFTD8VMOxNVhHCjTw== - } - engines: { node: '>=8' } - dependencies: - yallist: 4.0.0 - dev: false - - /minizlib/2.1.2: - resolution: - { - integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== - } - engines: { node: '>= 8' } - dependencies: - minipass: 3.1.5 - yallist: 4.0.0 - dev: false - /mkdirp-classic/0.5.3: resolution: { @@ -4003,15 +3836,6 @@ packages: minimist: 1.2.5 dev: true - /mkdirp/1.0.4: - resolution: - { - integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - } - engines: { node: '>=10' } - hasBin: true - dev: false - /mri/1.2.0: resolution: { @@ -4080,27 +3904,10 @@ packages: resolution: { integrity: sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= } dev: true - /node-addon-api/3.2.1: + /node-forge/1.3.1: resolution: { - integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== - } - dev: false - - /node-fetch/2.6.6: - resolution: - { - integrity: sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA== - } - engines: { node: 4.x || >=6.0.0 } - dependencies: - whatwg-url: 5.0.0 - dev: false - - /node-forge/1.3.0: - resolution: - { - integrity: sha512-08ARB91bUi6zNKzVmaj3QO7cr397uiDT2nJ63cHjyNtCTWIgvS47j3eT0WfzUwS9+6Z5YshRaoasFkXCKrIYbA== + integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== } engines: { node: '>= 6.13.0' } dev: false @@ -4128,17 +3935,6 @@ packages: } dev: false - /nopt/5.0.0: - resolution: - { - integrity: sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ== - } - engines: { node: '>=6' } - hasBin: true - dependencies: - abbrev: 1.1.1 - dev: false - /normalize-path/3.0.0: resolution: { @@ -4170,23 +3966,6 @@ packages: path-key: 3.1.1 dev: true - /npmlog/5.0.1: - resolution: - { - integrity: sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw== - } - dependencies: - are-we-there-yet: 2.0.0 - console-control-strings: 1.1.0 - gauge: 3.0.1 - set-blocking: 2.0.0 - dev: false - - /object-assign/4.1.1: - resolution: { integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= } - engines: { node: '>=0.10.0' } - dev: false - /object-hash/2.2.0: resolution: { @@ -4433,20 +4212,20 @@ packages: engines: { node: '>= 0.8.0' } dev: true - /prettier-plugin-svelte/2.6.0_prettier@2.6.1+svelte@3.46.4: + /prettier-plugin-svelte/2.7.0_prettier@2.6.2+svelte@3.47.0: resolution: { - integrity: sha512-NPSRf6Y5rufRlBleok/pqg4+1FyGsL0zYhkYP6hnueeL1J/uCm3OfOZPsLX4zqD9VAdcXfyEL2PYqGv8ZoOSfA== + integrity: sha512-fQhhZICprZot2IqEyoiUYLTRdumULGRvw0o4dzl5jt0jfzVWdGqeYW27QTWAeXhoupEZJULmNoH3ueJwUWFLIA== } peerDependencies: prettier: ^1.16.4 || ^2.0.0 svelte: ^3.2.0 dependencies: - prettier: 2.6.1 - svelte: 3.46.4 + prettier: 2.6.2 + svelte: 3.47.0 dev: true - /prettier-plugin-tailwindcss/0.1.8_prettier@2.6.1: + /prettier-plugin-tailwindcss/0.1.8_prettier@2.6.2: resolution: { integrity: sha512-hwarSBCswAXa+kqYtaAkFr3Vop9o04WOyZs0qo3NyvW8L7f1rif61wRyq0+ArmVThOuRBcJF5hjGXYk86cwemg== @@ -4455,13 +4234,13 @@ packages: peerDependencies: prettier: '>=2.2.0' dependencies: - prettier: 2.6.1 + prettier: 2.6.2 dev: true - /prettier/2.6.1: + /prettier/2.6.2: resolution: { - integrity: sha512-8UVbTBYGwN37Bs9LERmxCPjdvPxlEowx2urIL6urHzdb3SDq4B/Z6xLFCblrSnE4iKWcS6ziJ3aOYrc1kz/E2A== + integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew== } engines: { node: '>=10.13.0' } hasBin: true @@ -4731,6 +4510,7 @@ packages: hasBin: true dependencies: glob: 7.2.0 + dev: true /rollup/2.61.1: resolution: @@ -4826,10 +4606,7 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 - - /set-blocking/2.0.0: - resolution: { integrity: sha1-BF+XgtARrppoA93TgrJDkrPYkPc= } - dev: false + dev: true /shebang-command/1.2.0: resolution: { integrity: sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= } @@ -4864,6 +4641,7 @@ packages: { integrity: sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ== } + dev: true /slash/1.0.0: resolution: { integrity: sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU= } @@ -4998,17 +4776,6 @@ packages: engines: { node: '>=0.6.19' } dev: true - /string-width/2.1.1: - resolution: - { - integrity: sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== - } - engines: { node: '>=4' } - dependencies: - is-fullwidth-code-point: 2.0.0 - strip-ansi: 4.0.0 - dev: false - /string-width/4.2.3: resolution: { @@ -5019,6 +4786,7 @@ packages: emoji-regex: 8.0.0 is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 + dev: true /string-width/5.1.0: resolution: @@ -5048,13 +4816,6 @@ packages: ansi-regex: 2.1.1 dev: true - /strip-ansi/4.0.0: - resolution: { integrity: sha1-qEeQIusaw2iocTibY1JixQXuNo8= } - engines: { node: '>=4' } - dependencies: - ansi-regex: 3.0.0 - dev: false - /strip-ansi/6.0.1: resolution: { @@ -5063,6 +4824,7 @@ packages: engines: { node: '>=8' } dependencies: ansi-regex: 5.0.1 + dev: true /strip-ansi/7.0.1: resolution: @@ -5141,10 +4903,10 @@ packages: engines: { node: '>= 0.4' } dev: true - /svelte-check/2.4.6_postcss@8.4.12+svelte@3.46.4: + /svelte-check/2.6.0_postcss@8.4.12+svelte@3.47.0: resolution: { - integrity: sha512-luzdly7RJhyXucQe8ID/7CqDgXdMrPYXmyZBjCbp+cixzTopZotuWevrB5hWDOnOU19m2cyetigIIa7WDHnCmQ== + integrity: sha512-POL3IqLUuGqb9DdvuXQaSTNXYnw/odK4hqW86+2LwGcZTdbUPKBBln7pq74wXmcnRE+12bXMY1CvbcUNa2d5nw== } hasBin: true peerDependencies: @@ -5153,12 +4915,11 @@ packages: chokidar: 3.5.3 fast-glob: 3.2.11 import-fresh: 3.3.0 - minimist: 1.2.5 picocolors: 1.0.0 sade: 1.7.4 source-map: 0.7.3 - svelte: 3.46.4 - svelte-preprocess: 4.10.4_296873641a0ad9f42fe92172d27bcedd + svelte: 3.47.0 + svelte-preprocess: 4.10.5_41810887ae6c6d59323116f47e33fa38 typescript: 4.6.3 transitivePeerDependencies: - '@babel/core' @@ -5173,7 +4934,7 @@ packages: - sugarss dev: true - /svelte-hmr/0.14.9_svelte@3.46.4: + /svelte-hmr/0.14.9_svelte@3.47.0: resolution: { integrity: sha512-bKE9+4qb4sAnA+TKHiYurUl970rjA0XmlP9TEP7K/ncyWz3m81kA4HOgmlZK/7irGK7gzZlaPDI3cmf8fp/+tg== @@ -5181,7 +4942,7 @@ packages: peerDependencies: svelte: '>=3.19.0' dependencies: - svelte: 3.46.4 + svelte: 3.47.0 dev: true /svelte-kit-cookie-session/2.1.2: @@ -5191,10 +4952,10 @@ packages: } dev: false - /svelte-preprocess/4.10.4_296873641a0ad9f42fe92172d27bcedd: + /svelte-preprocess/4.10.5_41810887ae6c6d59323116f47e33fa38: resolution: { - integrity: sha512-fuwol0N4UoHsNQolLFbMqWivqcJ9N0vfWO9IuPAiX/5okfoGXURyJ6nECbuEIv0nU3M8Xe2I1ONNje2buk7l6A== + integrity: sha512-VKXPRScCzAZqeBZOGq4LLwtNrAu++mVn7XvQox3eFDV7Ciq0Lg70Q8QWjH9iXF7J+pMlXhPsSFwpCb2E+hoeyA== } engines: { node: '>= 9.11.2' } requiresBuild: true @@ -5242,7 +5003,7 @@ packages: postcss: 8.4.12 sorcery: 0.10.0 strip-indent: 3.0.0 - svelte: 3.46.4 + svelte: 3.47.0 typescript: 4.6.3 dev: true @@ -5253,10 +5014,10 @@ packages: } dev: true - /svelte/3.46.4: + /svelte/3.47.0: resolution: { - integrity: sha512-qKJzw6DpA33CIa+C/rGp4AUdSfii0DOTCzj/2YpSKKayw5WGSS624Et9L1nU1k2OVRS9vaENQXp2CVZNU+xvIg== + integrity: sha512-4JaJp3HEoTCGARRWZQIZDUanhYv0iyoHikklVHVLH9xFE9db22g4TDv7CPeNA8HD1JgjXI1vlhR1JZvvhaTu2Q== } engines: { node: '>= 8' } dev: true @@ -5349,21 +5110,6 @@ packages: readable-stream: 3.6.0 dev: false - /tar/6.1.11: - resolution: - { - integrity: sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== - } - engines: { node: '>= 10' } - dependencies: - chownr: 2.0.0 - fs-minipass: 2.1.0 - minipass: 3.1.5 - minizlib: 2.1.2 - mkdirp: 1.0.4 - yallist: 4.0.0 - dev: false - /text-table/0.2.0: resolution: { integrity: sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= } dev: true @@ -5397,10 +5143,6 @@ packages: is-number: 7.0.0 dev: true - /tr46/0.0.3: - resolution: { integrity: sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= } - dev: false - /trim-right/1.0.1: resolution: { integrity: sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= } engines: { node: '>=0.10.0' } @@ -5556,10 +5298,10 @@ packages: } dev: true - /vite/2.8.0: + /vite/2.9.1: resolution: { - integrity: sha512-ed5rjyeysttuPJX/aKSA0gTB/8ZKLM5xF6FtEuKy1B9DiQbDNFMVMQxnb9JesgBPUMMIJxC8w5KZ/KNWLKFXoA== + integrity: sha512-vSlsSdOYGcYEJfkQ/NeLXgnRv5zZfpAsdztkIrs7AZHV8RCMZQkwjo4DS5BnrYTqoWqLoUe1Cah4aVO4oNNqCQ== } engines: { node: '>=12.2.0' } hasBin: true @@ -5575,7 +5317,7 @@ packages: stylus: optional: true dependencies: - esbuild: 0.14.21 + esbuild: 0.14.34 postcss: 8.4.12 resolve: 1.22.0 rollup: 2.61.1 @@ -5583,17 +5325,6 @@ packages: fsevents: 2.3.2 dev: true - /webidl-conversions/3.0.1: - resolution: { integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= } - dev: false - - /whatwg-url/5.0.0: - resolution: { integrity: sha1-lmRU6HZUYuN2RNNib2dCzotwll0= } - dependencies: - tr46: 0.0.3 - webidl-conversions: 3.0.1 - dev: false - /which/1.3.1: resolution: { @@ -5614,15 +5345,6 @@ packages: dependencies: isexe: 2.0.0 - /wide-align/1.1.5: - resolution: - { - integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg== - } - dependencies: - string-width: 4.2.3 - dev: false - /word-wrap/1.2.3: resolution: { @@ -5675,6 +5397,7 @@ packages: { integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== } + dev: true /yaml/1.10.2: resolution: diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2c97a9e8b..928562abd 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { provider = "prisma-client-js" + binaryTargets = ["linux-musl"] } datasource db { diff --git a/src/lib/api.ts b/src/lib/api.ts index 42fe10a1e..867ed338e 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,9 +1,17 @@ -async function send({ method, path, data = {}, headers, timeout = 30000 }) { +// TODO: Make this functions generic + +async function send({ + method, + path, + data = {}, + headers, + timeout = 30000 +}): Promise> { const controller = new AbortController(); const id = setTimeout(() => controller.abort(), timeout); const opts = { method, headers: {}, body: null, signal: controller.signal }; if (Object.keys(data).length > 0) { - let parsedData = data; + const parsedData = data; for (const [key, value] of Object.entries(data)) { if (value === '') { parsedData[key] = null; @@ -43,18 +51,33 @@ async function send({ method, path, data = {}, headers, timeout = 30000 }) { return responseData; } -export function get(path, headers = {}): Promise { +export function get( + path: string, + headers: Record +): Promise> { return send({ method: 'GET', path, headers }); } -export function del(path, data = {}, headers = {}): Promise { +export function del( + path: string, + data: Record, + headers: Record +): Promise> { return send({ method: 'DELETE', path, data, headers }); } -export function post(path, data, headers = {}): Promise { +export function post( + path: string, + data: Record, + headers: Record +): Promise> { return send({ method: 'POST', path, data, headers }); } -export function put(path, data, headers = {}): Promise { +export function put( + path: string, + data: Record, + headers: Record +): Promise> { return send({ method: 'PUT', path, data, headers }); } diff --git a/src/lib/buildPacks/docker.ts b/src/lib/buildPacks/docker.ts index 371ffed82..2db5d567c 100644 --- a/src/lib/buildPacks/docker.ts +++ b/src/lib/buildPacks/docker.ts @@ -26,14 +26,17 @@ export default async function ({ if (secrets.length > 0) { secrets.forEach((secret) => { if (secret.isBuildSecret) { - if (pullmergeRequestId) { - if (secret.isPRMRSecret) { - Dockerfile.push(`ARG ${secret.name}=${secret.value}`); - } - } else { - if (!secret.isPRMRSecret) { - Dockerfile.push(`ARG ${secret.name}=${secret.value}`); - } + if ( + (pullmergeRequestId && secret.isPRMRSecret) || + (!pullmergeRequestId && !secret.isPRMRSecret) + ) { + Dockerfile.unshift(`ARG ${secret.name}=${secret.value}`); + + Dockerfile.forEach((line, index) => { + if (line.startsWith('FROM')) { + Dockerfile.splice(index + 1, 0, `ARG ${secret.name}`); + } + }); } } }); diff --git a/src/lib/common.ts b/src/lib/common.ts index 57cdabba2..a9157d1dc 100644 --- a/src/lib/common.ts +++ b/src/lib/common.ts @@ -12,7 +12,8 @@ import { version as currentVersion } from '../../package.json'; import dayjs from 'dayjs'; import Cookie from 'cookie'; import os from 'os'; -import cuid from 'cuid'; +import type { RequestEvent } from '@sveltejs/kit/types/internal'; +import type { Job } from 'bullmq'; try { if (!dev) { @@ -45,13 +46,21 @@ const customConfig: Config = { export const version = currentVersion; export const asyncExecShell = util.promisify(child.exec); -export const asyncSleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay)); - +export const asyncSleep = (delay: number): Promise => + new Promise((resolve) => setTimeout(resolve, delay)); export const sentry = Sentry; -export const uniqueName = () => uniqueNamesGenerator(customConfig); +export const uniqueName = (): string => uniqueNamesGenerator(customConfig); -export const saveBuildLog = async ({ line, buildId, applicationId }) => { +export const saveBuildLog = async ({ + line, + buildId, + applicationId +}: { + line: string; + buildId: string; + applicationId: string; +}): Promise => { if (line) { if (line.includes('ghs_')) { const regex = /ghs_.*@/g; @@ -62,20 +71,7 @@ export const saveBuildLog = async ({ line, buildId, applicationId }) => { } }; -export const isTeamIdTokenAvailable = (request) => { - const cookie = request.headers.cookie - ?.split(';') - .map((s) => s.trim()) - .find((s) => s.startsWith('teamId=')) - ?.split('=')[1]; - if (!cookie) { - return getTeam(request); - } else { - return cookie; - } -}; - -export const getTeam = (event) => { +export const getTeam = (event: RequestEvent): string | null => { const cookies = Cookie.parse(event.request.headers.get('cookie')); if (cookies?.teamId) { return cookies.teamId; @@ -85,7 +81,16 @@ export const getTeam = (event) => { return null; }; -export const getUserDetails = async (event, isAdminRequired = true) => { +export const getUserDetails = async ( + event: RequestEvent, + isAdminRequired = true +): Promise<{ + teamId: string; + userId: string; + permission: string; + status: number; + body: { message: string }; +}> => { const teamId = getTeam(event); const userId = event?.locals?.session?.data?.userId || null; const { permission = 'read' } = await db.prisma.permission.findFirst({ @@ -112,11 +117,11 @@ export const getUserDetails = async (event, isAdminRequired = true) => { return payload; }; -export function getEngine(engine) { +export function getEngine(engine: string): string { return engine === '/var/run/docker.sock' ? 'unix:///var/run/docker.sock' : engine; } -export async function removeContainer(id, engine) { +export async function removeContainer(id: string, engine: string): Promise { const host = getEngine(engine); try { const { stdout } = await asyncExecShell( @@ -132,11 +137,23 @@ export async function removeContainer(id, engine) { } } -export const removeDestinationDocker = async ({ id, engine }) => { +export const removeDestinationDocker = async ({ + id, + engine +}: { + id: string; + engine: string; +}): Promise => { return await removeContainer(id, engine); }; -export const createDirectories = async ({ repository, buildId }) => { +export const createDirectories = async ({ + repository, + buildId +}: { + repository: string; + buildId: string; +}): Promise<{ workdir: string; repodir: string }> => { const repodir = `/tmp/build-sources/${repository}/`; const workdir = `/tmp/build-sources/${repository}/${buildId}`; @@ -148,20 +165,10 @@ export const createDirectories = async ({ repository, buildId }) => { }; }; -export function generateTimestamp() { +export function generateTimestamp(): string { return `${dayjs().format('HH:mm:ss.SSS')} `; } -export function getDomain(domain) { +export function getDomain(domain: string): string { return domain?.replace('https://', '').replace('http://', ''); } - -export function dashify(str: string, options?: any): string { - if (typeof str !== 'string') return str; - return str - .trim() - .replace(/\W/g, (m) => (/[À-ž]/.test(m) ? m : '-')) - .replace(/^-+|-+$/g, '') - .replace(/-{2,}/g, (m) => (options && options.condense ? '-' : m)) - .toLowerCase(); -} diff --git a/src/lib/crypto.ts b/src/lib/crypto.ts index 861a25510..dfb38991f 100644 --- a/src/lib/crypto.ts +++ b/src/lib/crypto.ts @@ -1,13 +1,13 @@ import crypto from 'crypto'; const algorithm = 'aes-256-ctr'; -export const base64Encode = (text: string) => { +export const base64Encode = (text: string): string => { return Buffer.from(text).toString('base64'); }; -export const base64Decode = (text: string) => { +export const base64Decode = (text: string): string => { return Buffer.from(text, 'base64').toString('ascii'); }; -export const encrypt = (text: string) => { +export const encrypt = (text: string): string => { if (text) { const iv = crypto.randomBytes(16); const cipher = crypto.createCipheriv(algorithm, process.env['COOLIFY_SECRET_KEY'], iv); @@ -19,7 +19,7 @@ export const encrypt = (text: string) => { } }; -export const decrypt = (hashString: string) => { +export const decrypt = (hashString: string): string => { if (hashString) { const hash: Hash = JSON.parse(hashString); const decipher = crypto.createDecipheriv( diff --git a/src/lib/database/applications.ts b/src/lib/database/applications.ts index ce53fe709..3ce6286d7 100644 --- a/src/lib/database/applications.ts +++ b/src/lib/database/applications.ts @@ -1,10 +1,19 @@ import { decrypt, encrypt } from '$lib/crypto'; import { asyncExecShell, getEngine } from '$lib/common'; -import { getDomain, removeDestinationDocker } from '$lib/common'; +import { removeDestinationDocker } from '$lib/common'; import { prisma } from './common'; -export async function listApplications(teamId) { +import type { + DestinationDocker, + GitSource, + Secret, + ApplicationSettings, + Application, + ApplicationPersistentStorage +} from '@prisma/client'; + +export async function listApplications(teamId: string): Promise { if (teamId === '0') { return await prisma.application.findMany({ include: { teams: true } }); } @@ -14,7 +23,13 @@ export async function listApplications(teamId) { }); } -export async function newApplication({ name, teamId }) { +export async function newApplication({ + name, + teamId +}: { + name: string; + teamId: string; +}): Promise { return await prisma.application.create({ data: { name, @@ -24,34 +39,17 @@ export async function newApplication({ name, teamId }) { }); } -export async function importApplication({ - name, - teamId, - fqdn, - port, - buildCommand, - startCommand, - installCommand -}) { - return await prisma.application.create({ - data: { - name, - fqdn, - port, - buildCommand, - startCommand, - installCommand, - teams: { connect: { id: teamId } } - } - }); -} - -export async function removeApplication({ id, teamId }) { - const { fqdn, destinationDockerId, destinationDocker } = await prisma.application.findUnique({ +export async function removeApplication({ + id, + teamId +}: { + id: string; + teamId: string; +}): Promise { + const { destinationDockerId, destinationDocker } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } }); - const domain = getDomain(fqdn); if (destinationDockerId) { const host = getEngine(destinationDocker.engine); const { stdout: containers } = await asyncExecShell( @@ -62,7 +60,6 @@ export async function removeApplication({ id, teamId }) { for (const container of containersArray) { const containerObj = JSON.parse(container); const id = containerObj.ID; - const preview = containerObj.Image.split('-')[1]; await removeDestinationDocker({ id, engine: destinationDocker.engine }); } } @@ -80,9 +77,23 @@ export async function removeApplication({ id, teamId }) { } } -export async function getApplicationWebhook({ projectId, branch }) { +export async function getApplicationWebhook({ + projectId, + branch +}: { + projectId: number; + branch: string; +}): Promise< + Application & { + destinationDocker: DestinationDocker; + settings: ApplicationSettings; + gitSource: GitSource; + secrets: Secret[]; + persistentStorage: ApplicationPersistentStorage[]; + } +> { try { - let application = await prisma.application.findFirst({ + const application = await prisma.application.findFirst({ where: { projectId, branch, settings: { autodeploy: true } }, include: { destinationDocker: true, @@ -131,16 +142,17 @@ export async function getApplicationWebhook({ projectId, branch }) { throw { status: 404, body: { message: e.message } }; } } -export async function getApplicationById({ id }) { - const body = await prisma.application.findFirst({ - where: { id }, - include: { destinationDocker: true } - }); - return { ...body }; -} -export async function getApplication({ id, teamId }) { - let body = {}; +export async function getApplication({ id, teamId }: { id: string; teamId: string }): Promise< + Application & { + destinationDocker: DestinationDocker; + settings: ApplicationSettings; + gitSource: GitSource; + secrets: Secret[]; + persistentStorage: ApplicationPersistentStorage[]; + } +> { + let body; if (teamId === '0') { body = await prisma.application.findFirst({ where: { id }, @@ -194,7 +206,14 @@ export async function configureGitRepository({ projectId, webhookToken, autodeploy -}) { +}: { + id: string; + repository: string; + branch: string; + projectId: number; + webhookToken: string; + autodeploy: boolean; +}): Promise { if (webhookToken) { const encryptedWebhookToken = encrypt(webhookToken); await prisma.application.update({ @@ -224,7 +243,10 @@ export async function configureGitRepository({ } } -export async function configureBuildPack({ id, buildPack }) { +export async function configureBuildPack({ + id, + buildPack +}: Pick): Promise { return await prisma.application.update({ where: { id }, data: { buildPack } }); } @@ -242,7 +264,21 @@ export async function configureApplication({ pythonWSGI, pythonModule, pythonVariable -}) { +}: { + id: string; + buildPack: string; + name: string; + fqdn: string; + port: number; + installCommand: string; + buildCommand: string; + startCommand: string; + baseDirectory: string; + publishDirectory: string; + pythonWSGI: string; + pythonModule: string; + pythonVariable: string; +}): Promise { return await prisma.application.update({ where: { id }, data: { @@ -262,11 +298,24 @@ export async function configureApplication({ }); } -export async function checkDoubleBranch(branch, projectId) { +export async function checkDoubleBranch(branch: string, projectId: number): Promise { const applications = await prisma.application.findMany({ where: { branch, projectId } }); return applications.length > 1; } -export async function setApplicationSettings({ id, debug, previews, dualCerts, autodeploy }) { + +export async function setApplicationSettings({ + id, + debug, + previews, + dualCerts, + autodeploy +}: { + id: string; + debug: boolean; + previews: boolean; + dualCerts: boolean; + autodeploy: boolean; +}): Promise { return await prisma.application.update({ where: { id }, data: { settings: { update: { debug, previews, dualCerts, autodeploy } } }, @@ -274,29 +323,6 @@ export async function setApplicationSettings({ id, debug, previews, dualCerts, a }); } -export async function createBuild({ - id, - applicationId, - destinationDockerId, - gitSourceId, - githubAppId, - gitlabAppId, - type -}) { - return await prisma.build.create({ - data: { - id, - applicationId, - destinationDockerId, - gitSourceId, - githubAppId, - gitlabAppId, - status: 'running', - type - } - }); -} - -export async function getPersistentStorage(id) { +export async function getPersistentStorage(id: string): Promise { return await prisma.applicationPersistentStorage.findMany({ where: { applicationId: id } }); } diff --git a/src/lib/database/checks.ts b/src/lib/database/checks.ts index 534d81966..bbe773ae5 100644 --- a/src/lib/database/checks.ts +++ b/src/lib/database/checks.ts @@ -1,7 +1,16 @@ import { getDomain } from '$lib/common'; import { prisma } from './common'; +import type { Application, ServiceSecret, DestinationDocker, Secret } from '@prisma/client'; -export async function isBranchAlreadyUsed({ repository, branch, id }) { +export async function isBranchAlreadyUsed({ + repository, + branch, + id +}: { + id: string; + repository: string; + branch: string; +}): Promise { const application = await prisma.application.findUnique({ where: { id }, include: { gitSource: true } @@ -11,18 +20,42 @@ export async function isBranchAlreadyUsed({ repository, branch, id }) { }); } -export async function isDockerNetworkExists({ network }) { +export async function isDockerNetworkExists({ + network +}: { + network: string; +}): Promise { return await prisma.destinationDocker.findFirst({ where: { network } }); } -export async function isServiceSecretExists({ id, name }) { +export async function isServiceSecretExists({ + id, + name +}: { + id: string; + name: string; +}): Promise { return await prisma.serviceSecret.findFirst({ where: { name, serviceId: id } }); } -export async function isSecretExists({ id, name, isPRMRSecret }) { +export async function isSecretExists({ + id, + name, + isPRMRSecret +}: { + id: string; + name: string; + isPRMRSecret: boolean; +}): Promise { return await prisma.secret.findFirst({ where: { name, applicationId: id, isPRMRSecret } }); } -export async function isDomainConfigured({ id, fqdn }) { +export async function isDomainConfigured({ + id, + fqdn +}: { + id: string; + fqdn: string; +}): Promise { const domain = getDomain(fqdn); const nakedDomain = domain.replace('www.', ''); const foundApp = await prisma.application.findFirst({ @@ -55,6 +88,5 @@ export async function isDomainConfigured({ id, fqdn }) { }, select: { fqdn: true } }); - if (foundApp || foundService || coolifyFqdn) return true; - return false; + return !!(foundApp || foundService || coolifyFqdn); } diff --git a/src/lib/database/common.ts b/src/lib/database/common.ts index 9d588fcc4..cdc1d5b92 100644 --- a/src/lib/database/common.ts +++ b/src/lib/database/common.ts @@ -6,11 +6,11 @@ import { } from '$lib/components/common'; import * as Prisma from '@prisma/client'; import { default as ProdPrisma } from '@prisma/client'; -import type { PrismaClientOptions } from '@prisma/client/runtime'; +import type { Database, DatabaseSettings } from '@prisma/client'; import generator from 'generate-password'; import forge from 'node-forge'; -export function generatePassword(length = 24) { +export function generatePassword(length = 24): string { return generator.generate({ length, numbers: true, @@ -30,8 +30,14 @@ export const prisma = new PrismaClient({ rejectOnNotFound: false }); -export function ErrorHandler(e) { - if (e! instanceof Error) { +export function ErrorHandler(e: { + stdout?; + message?: string; + status?: number; + name?: string; + error?: string; +}): { status: number; body: { message: string; error: string } } { + if (e && e instanceof Error) { e = new Error(e.toString()); } let truncatedError = e; @@ -39,8 +45,7 @@ export function ErrorHandler(e) { truncatedError = e.stdout; } if (e.message?.includes('docker run')) { - let truncatedArray = []; - truncatedArray = truncatedError.message.split('-').filter((line) => { + const truncatedArray: string[] = truncatedError.message.split('-').filter((line) => { if (!line.startsWith('e ')) { return line; } @@ -68,11 +73,11 @@ export function ErrorHandler(e) { payload.body.message = 'Already exists. Choose another name.'; } } - // console.error(e) return payload; } + export async function generateSshKeyPair(): Promise<{ publicKey: string; privateKey: string }> { - return await new Promise(async (resolve, reject) => { + return await new Promise((resolve, reject) => { forge.pki.rsa.generateKeyPair({ bits: 4096, workers: -1 }, function (err, keys) { if (keys) { resolve({ @@ -86,35 +91,93 @@ export async function generateSshKeyPair(): Promise<{ publicKey: string; private }); } -export function getVersions(type) { +export function getVersions(type: string): string[] { const found = supportedDatabaseTypesAndVersions.find((t) => t.name === type); if (found) { return found.versions; } return []; } -export function getDatabaseImage(type) { + +export function getDatabaseImage(type: string): string { const found = supportedDatabaseTypesAndVersions.find((t) => t.name === type); if (found) { return found.baseImage; } return ''; } -export function getServiceImage(type) { + +export function getServiceImage(type: string): string { const found = supportedServiceTypesAndVersions.find((t) => t.name === type); if (found) { return found.baseImage; } return ''; } -export function getServiceImages(type) { + +export function getServiceImages(type: string): string[] { const found = supportedServiceTypesAndVersions.find((t) => t.name === type); if (found) { return found.images; } return []; } -export function generateDatabaseConfiguration(database) { + +export function generateDatabaseConfiguration(database: Database & { settings: DatabaseSettings }): + | { + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + MYSQL_DATABASE: string; + MYSQL_PASSWORD: string; + MYSQL_ROOT_USER: string; + MYSQL_USER: string; + MYSQL_ROOT_PASSWORD: string; + }; + } + | { + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + MONGODB_ROOT_USER: string; + MONGODB_ROOT_PASSWORD: string; + }; + } + | { + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + POSTGRESQL_USERNAME: string; + POSTGRESQL_PASSWORD: string; + POSTGRESQL_DATABASE: string; + }; + } + | { + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + REDIS_AOF_ENABLED: string; + REDIS_PASSWORD: string; + }; + } + | { + volume: string; + image: string; + ulimits: Record; + privatePort: number; + environmentVariables: { + COUCHDB_PASSWORD: string; + COUCHDB_USER: string; + }; + } { const { id, dbUser, @@ -129,7 +192,6 @@ export function generateDatabaseConfiguration(database) { const baseImage = getDatabaseImage(type); if (type === 'mysql') { return { - // url: `mysql://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 3306}/${defaultDatabase}`, privatePort: 3306, environmentVariables: { MYSQL_USER: dbUser, @@ -144,7 +206,6 @@ export function generateDatabaseConfiguration(database) { }; } else if (type === 'mongodb') { return { - // url: `mongodb://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 27017}/${defaultDatabase}`, privatePort: 27017, environmentVariables: { MONGODB_ROOT_USER: rootUser, @@ -156,7 +217,6 @@ export function generateDatabaseConfiguration(database) { }; } else if (type === 'postgresql') { return { - // url: `psql://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 5432}/${defaultDatabase}`, privatePort: 5432, environmentVariables: { POSTGRESQL_POSTGRES_PASSWORD: rootUserPassword, @@ -170,7 +230,6 @@ export function generateDatabaseConfiguration(database) { }; } else if (type === 'redis') { return { - // url: `redis://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 6379}/${defaultDatabase}`, privatePort: 6379, environmentVariables: { REDIS_PASSWORD: dbUserPassword, @@ -182,7 +241,6 @@ export function generateDatabaseConfiguration(database) { }; } else if (type === 'couchdb') { return { - // url: `couchdb://${dbUser}:${dbUserPassword}@${id}:${isPublic ? port : 5984}/${defaultDatabase}`, privatePort: 5984, environmentVariables: { COUCHDB_PASSWORD: dbUserPassword, @@ -193,18 +251,4 @@ export function generateDatabaseConfiguration(database) { ulimits: {} }; } - // } else if (type === 'clickhouse') { - // return { - // url: `clickhouse://${dbUser}:${dbUserPassword}@${id}:${port}/${defaultDatabase}`, - // privatePort: 9000, - // image: `bitnami/clickhouse-server:${version}`, - // volume: `${id}-${type}-data:/var/lib/clickhouse`, - // ulimits: { - // nofile: { - // soft: 262144, - // hard: 262144 - // } - // } - // } - // } } diff --git a/src/lib/database/databases.ts b/src/lib/database/databases.ts index 9132fc2b2..388047ac3 100644 --- a/src/lib/database/databases.ts +++ b/src/lib/database/databases.ts @@ -1,12 +1,11 @@ import { decrypt, encrypt } from '$lib/crypto'; -import * as db from '$lib/database'; import cuid from 'cuid'; import { generatePassword } from '.'; -import { prisma, ErrorHandler } from './common'; -import getPort, { portNumbers } from 'get-port'; +import { prisma } from './common'; import { asyncExecShell, getEngine, removeContainer } from '$lib/common'; +import type { Database, DatabaseSettings, DestinationDocker } from '@prisma/client'; -export async function listDatabases(teamId) { +export async function listDatabases(teamId: string): Promise { if (teamId === '0') { return await prisma.database.findMany({ include: { teams: true } }); } else { @@ -16,7 +15,14 @@ export async function listDatabases(teamId) { }); } } -export async function newDatabase({ name, teamId }) { + +export async function newDatabase({ + name, + teamId +}: { + name: string; + teamId: string; +}): Promise { const dbUser = cuid(); const dbUserPassword = encrypt(generatePassword()); const rootUser = cuid(); @@ -37,8 +43,14 @@ export async function newDatabase({ name, teamId }) { }); } -export async function getDatabase({ id, teamId }) { - let body = {}; +export async function getDatabase({ + id, + teamId +}: { + id: string; + teamId: string; +}): Promise { + let body; if (teamId === '0') { body = await prisma.database.findFirst({ where: { id }, @@ -50,20 +62,25 @@ export async function getDatabase({ id, teamId }) { include: { destinationDocker: true, settings: true } }); } - if (body.dbUserPassword) body.dbUserPassword = decrypt(body.dbUserPassword); if (body.rootUserPassword) body.rootUserPassword = decrypt(body.rootUserPassword); - return { ...body }; + return body; } -export async function removeDatabase({ id }) { +export async function removeDatabase({ id }: { id: string }): Promise { await prisma.databaseSettings.deleteMany({ where: { databaseId: id } }); await prisma.database.delete({ where: { id } }); return; } -export async function configureDatabaseType({ id, type }) { +export async function configureDatabaseType({ + id, + type +}: { + id: string; + type: string; +}): Promise { return await prisma.database.update({ where: { id }, data: { type } @@ -79,7 +96,7 @@ export async function setDatabase({ version?: string; isPublic?: boolean; appendOnly?: boolean; -}) { +}): Promise { return await prisma.database.update({ where: { id }, data: { @@ -97,7 +114,16 @@ export async function updateDatabase({ rootUser, rootUserPassword, version -}) { +}: { + id: string; + name: string; + defaultDatabase: string; + dbUser: string; + dbUserPassword: string; + rootUser: string; + rootUserPassword: string; + version: string; +}): Promise { const encryptedDbUserPassword = dbUserPassword && encrypt(dbUserPassword); const encryptedRootUserPassword = rootUserPassword && encrypt(rootUserPassword); return await prisma.database.update({ @@ -114,7 +140,9 @@ export async function updateDatabase({ }); } -export async function stopDatabase(database) { +export async function stopDatabase( + database: Database & { destinationDocker: DestinationDocker } +): Promise { let everStarted = false; const { id, diff --git a/src/lib/database/destinations.ts b/src/lib/database/destinations.ts index 7b2570d93..2f6cdb488 100644 --- a/src/lib/database/destinations.ts +++ b/src/lib/database/destinations.ts @@ -1,11 +1,22 @@ import { asyncExecShell, getEngine } from '$lib/common'; -import { decrypt, encrypt } from '$lib/crypto'; import { dockerInstance } from '$lib/docker'; import { startCoolifyProxy } from '$lib/haproxy'; import { getDatabaseImage } from '.'; import { prisma } from './common'; +import type { DestinationDocker, Service, Application, Prisma } from '@prisma/client'; +import type { CreateDockerDestination } from '$lib/types/destinations'; -export async function listDestinations(teamId) { +type DestinationConfigurationObject = { + id: string; + destinationId: string; +}; + +type FindDestinationFromTeam = { + id: string; + teamId: string; +}; + +export async function listDestinations(teamId: string): Promise { if (teamId === '0') { return await prisma.destinationDocker.findMany({ include: { teams: true } }); } @@ -15,19 +26,28 @@ export async function listDestinations(teamId) { }); } -export async function configureDestinationForService({ id, destinationId }) { +export async function configureDestinationForService({ + id, + destinationId +}: DestinationConfigurationObject): Promise { return await prisma.service.update({ where: { id }, data: { destinationDocker: { connect: { id: destinationId } } } }); } -export async function configureDestinationForApplication({ id, destinationId }) { +export async function configureDestinationForApplication({ + id, + destinationId +}: DestinationConfigurationObject): Promise { return await prisma.application.update({ where: { id }, data: { destinationDocker: { connect: { id: destinationId } } } }); } -export async function configureDestinationForDatabase({ id, destinationId }) { +export async function configureDestinationForDatabase({ + id, + destinationId +}: DestinationConfigurationObject): Promise { await prisma.database.update({ where: { id }, data: { destinationDocker: { connect: { id: destinationId } } } @@ -48,7 +68,12 @@ export async function configureDestinationForDatabase({ id, destinationId }) { } } } -export async function updateDestination({ id, name, engine, network }) { +export async function updateDestination({ + id, + name, + engine, + network +}: Pick): Promise { return await prisma.destinationDocker.update({ where: { id }, data: { name, engine, network } }); } @@ -58,13 +83,8 @@ export async function newRemoteDestination({ engine, network, isCoolifyProxyUsed, - remoteEngine, - ipAddress, - user, - port, - sshPrivateKey -}) { - const encryptedPrivateKey = encrypt(sshPrivateKey); + remoteEngine +}: CreateDockerDestination): Promise { const destination = await prisma.destinationDocker.create({ data: { name, @@ -72,16 +92,18 @@ export async function newRemoteDestination({ engine, network, isCoolifyProxyUsed, - remoteEngine, - ipAddress, - user, - port, - sshPrivateKey: encryptedPrivateKey + remoteEngine } }); return destination.id; } -export async function newLocalDestination({ name, teamId, engine, network, isCoolifyProxyUsed }) { +export async function newLocalDestination({ + name, + teamId, + engine, + network, + isCoolifyProxyUsed +}: CreateDockerDestination): Promise { const host = getEngine(engine); const docker = dockerInstance({ destinationDocker: { engine, network } }); const found = await docker.engine.listNetworks({ filters: { name: [`^${network}$`] } }); @@ -99,18 +121,14 @@ export async function newLocalDestination({ name, teamId, engine, network, isCoo (destination) => destination.network !== network && destination.isCoolifyProxyUsed === true ); if (proxyConfigured) { - if (proxyConfigured.isCoolifyProxyUsed) { - isCoolifyProxyUsed = true; - } else { - isCoolifyProxyUsed = false; - } + isCoolifyProxyUsed = !!proxyConfigured.isCoolifyProxyUsed; } await prisma.destinationDocker.updateMany({ where: { engine }, data: { isCoolifyProxyUsed } }); } if (isCoolifyProxyUsed) await startCoolifyProxy(engine); return destination.id; } -export async function removeDestination({ id }) { +export async function removeDestination({ id }: Pick): Promise { const destination = await prisma.destinationDocker.delete({ where: { id } }); if (destination.isCoolifyProxyUsed) { const host = getEngine(destination.engine); @@ -127,8 +145,11 @@ export async function removeDestination({ id }) { } } -export async function getDestination({ id, teamId }) { - let destination = {}; +export async function getDestination({ + id, + teamId +}: FindDestinationFromTeam): Promise { + let destination; if (teamId === '0') { destination = await prisma.destinationDocker.findFirst({ where: { id } @@ -141,13 +162,22 @@ export async function getDestination({ id, teamId }) { return destination; } -export async function getDestinationByApplicationId({ id, teamId }) { +export async function getDestinationByApplicationId({ + id, + teamId +}: FindDestinationFromTeam): Promise { return await prisma.destinationDocker.findFirst({ where: { application: { some: { id } }, teams: { some: { id: teamId } } } }); } -export async function setDestinationSettings({ engine, isCoolifyProxyUsed }) { +export async function setDestinationSettings({ + engine, + isCoolifyProxyUsed +}: { + engine: string; + isCoolifyProxyUsed: boolean; +}): Promise { return await prisma.destinationDocker.updateMany({ where: { engine }, data: { isCoolifyProxyUsed } diff --git a/src/lib/database/gitSources.ts b/src/lib/database/gitSources.ts index b8279c268..01d36a7da 100644 --- a/src/lib/database/gitSources.ts +++ b/src/lib/database/gitSources.ts @@ -1,7 +1,10 @@ import { decrypt, encrypt } from '$lib/crypto'; import { prisma } from './common'; +import type { GithubApp, GitlabApp, GitSource, Prisma, Application } from '@prisma/client'; -export async function listSources(teamId) { +export async function listSources( + teamId: string | Prisma.StringFilter +): Promise<(GitSource & { githubApp?: GithubApp; gitlabApp?: GitlabApp })[]> { if (teamId === '0') { return await prisma.gitSource.findMany({ include: { githubApp: true, gitlabApp: true, teams: true } @@ -13,7 +16,21 @@ export async function listSources(teamId) { }); } -export async function newSource({ teamId, name }) { +export async function newSource({ + name, + teamId, + type, + htmlUrl, + apiUrl, + organization +}: { + name: string; + teamId: string; + type: string; + htmlUrl: string; + apiUrl: string; + organization: string; +}): Promise { return await prisma.gitSource.create({ data: { name, @@ -21,7 +38,7 @@ export async function newSource({ teamId, name }) { } }); } -export async function removeSource({ id }) { +export async function removeSource({ id }: { id: string }): Promise { const source = await prisma.gitSource.delete({ where: { id }, include: { githubApp: true, gitlabApp: true } @@ -30,8 +47,14 @@ export async function removeSource({ id }) { if (source.gitlabAppId) await prisma.gitlabApp.delete({ where: { id: source.gitlabAppId } }); } -export async function getSource({ id, teamId }) { - let body = {}; +export async function getSource({ + id, + teamId +}: { + id: string; + teamId: string; +}): Promise { + let body; if (teamId === '0') { body = await prisma.gitSource.findFirst({ where: { id }, @@ -80,19 +103,31 @@ export async function addGitLabSource({ appId, oauthId, groupName, - appSecret: encrptedAppSecret, + appSecret: encryptedAppSecret, gitSource: { connect: { id } } } }); } -export async function configureGitsource({ id, gitSourceId }) { +export async function configureGitsource({ + id, + gitSourceId +}: { + id: string; + gitSourceId: string; +}): Promise { return await prisma.application.update({ where: { id }, data: { gitSource: { connect: { id: gitSourceId } } } }); } -export async function updateGitsource({ id, name, htmlUrl, apiUrl }) { +export async function updateGitsource({ + id, + name +}: { + id: string; + name: string; +}): Promise { return await prisma.gitSource.update({ where: { id }, data: { name, htmlUrl, apiUrl } diff --git a/src/lib/database/github.ts b/src/lib/database/github.ts index 339b8e008..182ad4529 100644 --- a/src/lib/database/github.ts +++ b/src/lib/database/github.ts @@ -1,7 +1,15 @@ import { decrypt, encrypt } from '$lib/crypto'; import { prisma } from './common'; +import type { GithubApp } from '@prisma/client'; -export async function addInstallation({ gitSourceId, installation_id }) { +// TODO: We should change installation_id to be camelCase +export async function addInstallation({ + gitSourceId, + installation_id +}: { + gitSourceId: string; + installation_id: string; +}): Promise { const source = await prisma.gitSource.findUnique({ where: { id: gitSourceId }, include: { githubApp: true } @@ -12,8 +20,12 @@ export async function addInstallation({ gitSourceId, installation_id }) { }); } -export async function getUniqueGithubApp({ githubAppId }) { - let body = await prisma.githubApp.findUnique({ where: { id: githubAppId } }); +export async function getUniqueGithubApp({ + githubAppId +}: { + githubAppId: string; +}): Promise { + const body = await prisma.githubApp.findUnique({ where: { id: githubAppId } }); if (body.privateKey) body.privateKey = decrypt(body.privateKey); return body; } @@ -26,7 +38,15 @@ export async function createGithubApp({ pem, webhook_secret, state -}) { +}: { + id: number; + client_id: string; + slug: string; + client_secret: string; + pem: string; + webhook_secret: string; + state: string; +}): Promise { const encryptedClientSecret = encrypt(client_secret); const encryptedWebhookSecret = encrypt(webhook_secret); const encryptedPem = encrypt(pem); diff --git a/src/lib/database/gitlab.ts b/src/lib/database/gitlab.ts index eb9bdfb1b..8bb6a9c9b 100644 --- a/src/lib/database/gitlab.ts +++ b/src/lib/database/gitlab.ts @@ -1,7 +1,14 @@ import { encrypt } from '$lib/crypto'; import { generateSshKeyPair, prisma } from './common'; +import type { GitlabApp } from '@prisma/client'; -export async function updateDeployKey({ id, deployKeyId }) { +export async function updateDeployKey({ + id, + deployKeyId +}: { + id: string; + deployKeyId: number; +}): Promise { const application = await prisma.application.findUnique({ where: { id }, include: { gitSource: { include: { gitlabApp: true } } } @@ -11,14 +18,24 @@ export async function updateDeployKey({ id, deployKeyId }) { data: { deployKeyId } }); } -export async function getSshKey({ id }) { +export async function getSshKey({ + id +}: { + id: string; +}): Promise<{ status: number; body: { publicKey: string } }> { const application = await prisma.application.findUnique({ where: { id }, include: { gitSource: { include: { gitlabApp: true } } } }); return { status: 200, body: { publicKey: application.gitSource.gitlabApp.publicSshKey } }; } -export async function generateSshKey({ id }) { +export async function generateSshKey({ + id +}: { + id: string; +}): Promise< + { status: number; body: { publicKey: string } } | { status: number; body?: undefined } +> { const application = await prisma.application.findUnique({ where: { id }, include: { gitSource: { include: { gitlabApp: true } } } diff --git a/src/lib/database/logs.ts b/src/lib/database/logs.ts index 9a71f51e4..74f50b50b 100644 --- a/src/lib/database/logs.ts +++ b/src/lib/database/logs.ts @@ -1,6 +1,13 @@ +import type { BuildLog } from '@prisma/client'; import { prisma, ErrorHandler } from './common'; -export async function listLogs({ buildId, last = 0 }) { +export async function listLogs({ + buildId, + last = 0 +}: { + buildId: string; + last: number; +}): Promise { try { const body = await prisma.buildLog.findMany({ where: { buildId, time: { gt: last } }, diff --git a/src/lib/database/secrets.ts b/src/lib/database/secrets.ts index 835eb4def..2aade4a2f 100644 --- a/src/lib/database/secrets.ts +++ b/src/lib/database/secrets.ts @@ -1,7 +1,8 @@ import { encrypt, decrypt } from '$lib/crypto'; import { prisma } from './common'; +import type { ServiceSecret, Secret, Prisma } from '@prisma/client'; -export async function listServiceSecrets(serviceId: string) { +export async function listServiceSecrets(serviceId: string): Promise { let secrets = await prisma.serviceSecret.findMany({ where: { serviceId }, orderBy: { createdAt: 'desc' } @@ -14,7 +15,7 @@ export async function listServiceSecrets(serviceId: string) { return secrets; } -export async function listSecrets(applicationId: string) { +export async function listSecrets(applicationId: string): Promise { let secrets = await prisma.secret.findMany({ where: { applicationId }, orderBy: { createdAt: 'desc' } @@ -27,20 +28,48 @@ export async function listSecrets(applicationId: string) { return secrets; } -export async function createServiceSecret({ id, name, value }) { +export async function createServiceSecret({ + id, + name, + value +}: { + id: string; + name: string; + value: string; +}): Promise { value = encrypt(value); return await prisma.serviceSecret.create({ data: { name, value, service: { connect: { id } } } }); } -export async function createSecret({ id, name, value, isBuildSecret, isPRMRSecret }) { +export async function createSecret({ + id, + name, + value, + isBuildSecret, + isPRMRSecret +}: { + id: string; + name: string; + value: string; + isBuildSecret: boolean; + isPRMRSecret: boolean; +}): Promise { value = encrypt(value); return await prisma.secret.create({ data: { name, value, isBuildSecret, isPRMRSecret, application: { connect: { id } } } }); } -export async function updateServiceSecret({ id, name, value }) { +export async function updateServiceSecret({ + id, + name, + value +}: { + id: string; + name: string; + value: string; +}): Promise { value = encrypt(value); const found = await prisma.serviceSecret.findFirst({ where: { serviceId: id, name } }); @@ -55,7 +84,19 @@ export async function updateServiceSecret({ id, name, value }) { }); } } -export async function updateSecret({ id, name, value, isBuildSecret, isPRMRSecret }) { +export async function updateSecret({ + id, + name, + value, + isBuildSecret, + isPRMRSecret +}: { + id: string; + name: string; + value: string; + isBuildSecret: boolean; + isPRMRSecret: boolean; +}): Promise { value = encrypt(value); const found = await prisma.secret.findFirst({ where: { applicationId: id, name, isPRMRSecret } }); @@ -71,10 +112,22 @@ export async function updateSecret({ id, name, value, isBuildSecret, isPRMRSecre } } -export async function removeServiceSecret({ id, name }) { +export async function removeServiceSecret({ + id, + name +}: { + id: string; + name: string; +}): Promise { return await prisma.serviceSecret.deleteMany({ where: { serviceId: id, name } }); } -export async function removeSecret({ id, name }) { +export async function removeSecret({ + id, + name +}: { + id: string; + name: string; +}): Promise { return await prisma.secret.deleteMany({ where: { applicationId: id, name } }); } diff --git a/src/lib/database/services.ts b/src/lib/database/services.ts index 0aec569b6..7beaaf76a 100644 --- a/src/lib/database/services.ts +++ b/src/lib/database/services.ts @@ -1,10 +1,10 @@ -import { asyncExecShell, getEngine } from '$lib/common'; import { decrypt, encrypt } from '$lib/crypto'; +import type { Minio, Service } from '@prisma/client'; import cuid from 'cuid'; import { generatePassword } from '.'; import { prisma } from './common'; -export async function listServices(teamId) { +export async function listServices(teamId: string): Promise { if (teamId === '0') { return await prisma.service.findMany({ include: { teams: true } }); } else { @@ -15,12 +15,18 @@ export async function listServices(teamId) { } } -export async function newService({ name, teamId }) { +export async function newService({ + name, + teamId +}: { + name: string; + teamId: string; +}): Promise { return await prisma.service.create({ data: { name, teams: { connect: { id: teamId } } } }); } -export async function getService({ id, teamId }) { - let body = {}; +export async function getService({ id, teamId }: { id: string; teamId: string }): Promise { + let body; const include = { destinationDocker: true, plausibleAnalytics: true, @@ -83,7 +89,13 @@ export async function getService({ id, teamId }) { return { ...body, settings }; } -export async function configureServiceType({ id, type }) { +export async function configureServiceType({ + id, + type +}: { + id: string; + type: string; +}): Promise { if (type === 'plausibleanalytics') { const password = encrypt(generatePassword()); const postgresqlUser = cuid(); @@ -199,44 +211,157 @@ export async function configureServiceType({ id, type }) { }); } } -export async function setServiceVersion({ id, version }) { + +export async function setServiceVersion({ + id, + version +}: { + id: string; + version: string; +}): Promise { return await prisma.service.update({ where: { id }, data: { version } }); } -export async function setServiceSettings({ id, dualCerts }) { +export async function setServiceSettings({ + id, + dualCerts +}: { + id: string; + dualCerts: boolean; +}): Promise { return await prisma.service.update({ where: { id }, data: { dualCerts } }); } -export async function updatePlausibleAnalyticsService({ id, fqdn, email, username, name }) { +export async function updatePlausibleAnalyticsService({ + id, + fqdn, + email, + username, + name +}: { + id: string; + fqdn: string; + name: string; + email: string; + username: string; +}): Promise { await prisma.plausibleAnalytics.update({ where: { serviceId: id }, data: { email, username } }); await prisma.service.update({ where: { id }, data: { name, fqdn } }); } -export async function updateService({ id, fqdn, name }) { + +export async function updateService({ + id, + fqdn, + name +}: { + id: string; + fqdn: string; + name: string; +}): Promise { return await prisma.service.update({ where: { id }, data: { fqdn, name } }); } -export async function updateWordpress({ id, fqdn, name, mysqlDatabase, extraConfig }) { + +export async function updateLanguageToolService({ + id, + fqdn, + name +}: { + id: string; + fqdn: string; + name: string; +}): Promise { + return await prisma.service.update({ where: { id }, data: { fqdn, name } }); +} + +export async function updateMeiliSearchService({ + id, + fqdn, + name +}: { + id: string; + fqdn: string; + name: string; +}): Promise { + return await prisma.service.update({ where: { id }, data: { fqdn, name } }); +} + +export async function updateVaultWardenService({ + id, + fqdn, + name +}: { + id: string; + fqdn: string; + name: string; +}): Promise { + return await prisma.service.update({ where: { id }, data: { fqdn, name } }); +} + +export async function updateVsCodeServer({ + id, + fqdn, + name +}: { + id: string; + fqdn: string; + name: string; +}): Promise { + return await prisma.service.update({ where: { id }, data: { fqdn, name } }); +} + +export async function updateWordpress({ + id, + fqdn, + name, + mysqlDatabase, + extraConfig +}: { + id: string; + fqdn: string; + name: string; + mysqlDatabase: string; + extraConfig: string; +}): Promise { return await prisma.service.update({ where: { id }, data: { fqdn, name, wordpress: { update: { mysqlDatabase, extraConfig } } } }); } -export async function updateMinioService({ id, publicPort }) { + +export async function updateMinioService({ + id, + publicPort +}: { + id: string; + publicPort: number; +}): Promise { return await prisma.minio.update({ where: { serviceId: id }, data: { publicPort } }); } -export async function updateGhostService({ id, fqdn, name, mariadbDatabase }) { + +export async function updateGhostService({ + id, + fqdn, + name, + mariadbDatabase +}: { + id: string; + fqdn: string; + name: string; + mariadbDatabase: string; +}): Promise { return await prisma.service.update({ where: { id }, data: { fqdn, name, ghost: { update: { mariadbDatabase } } } }); } -export async function removeService({ id }) { +export async function removeService({ id }: { id: string }): Promise { await prisma.meiliSearch.deleteMany({ where: { serviceId: id } }); await prisma.ghost.deleteMany({ where: { serviceId: id } }); await prisma.plausibleAnalytics.deleteMany({ where: { serviceId: id } }); diff --git a/src/lib/database/settings.ts b/src/lib/database/settings.ts index 31d6b3c04..2d0395d88 100644 --- a/src/lib/database/settings.ts +++ b/src/lib/database/settings.ts @@ -1,8 +1,9 @@ import { decrypt } from '$lib/crypto'; import { prisma } from './common'; +import type { Setting } from '@prisma/client'; -export async function listSettings() { - let settings = await prisma.setting.findFirst({}); +export async function listSettings(): Promise { + const settings = await prisma.setting.findFirst({}); if (settings.proxyPassword) settings.proxyPassword = decrypt(settings.proxyPassword); return settings; } diff --git a/src/lib/database/teams.ts b/src/lib/database/teams.ts index dd9a14cff..45d8fb5db 100644 --- a/src/lib/database/teams.ts +++ b/src/lib/database/teams.ts @@ -1,9 +1,10 @@ +import type { Team, Permission } from '@prisma/client'; import { prisma } from './common'; -export async function listTeams() { +export async function listTeams(): Promise { return await prisma.team.findMany(); } -export async function newTeam({ name, userId }) { +export async function newTeam({ name, userId }: { name: string; userId: string }): Promise { return await prisma.team.create({ data: { name, @@ -12,7 +13,11 @@ export async function newTeam({ name, userId }) { } }); } -export async function getMyTeams({ userId }) { +export async function getMyTeams({ + userId +}: { + userId: string; +}): Promise<(Permission & { team: Team & { _count: { users: number } } })[]> { return await prisma.permission.findMany({ where: { userId }, include: { team: { include: { _count: { select: { users: true } } } } } diff --git a/src/lib/database/users.ts b/src/lib/database/users.ts index 36b130b35..cdabf3588 100644 --- a/src/lib/database/users.ts +++ b/src/lib/database/users.ts @@ -1,16 +1,30 @@ import cuid from 'cuid'; -import bcrypt from 'bcrypt'; +import bcrypt from 'bcryptjs'; import { prisma } from './common'; import { asyncExecShell, uniqueName } from '$lib/common'; - import * as db from '$lib/database'; import { startCoolifyProxy } from '$lib/haproxy'; -export async function hashPassword(password: string) { +import type { User } from '@prisma/client'; + +export async function hashPassword(password: string): Promise { const saltRounds = 15; return bcrypt.hash(password, saltRounds); } -export async function login({ email, password, isLogin }) { + +export async function login({ + email, + password, + isLogin +}: { + email: string; + password: string; + isLogin: boolean; +}): Promise<{ + status: number; + headers: { 'Set-Cookie': string }; + body: { userId: string; teamId: string; permission: string; isAdmin: boolean }; +}> { const users = await prisma.user.count(); const userFound = await prisma.user.findUnique({ where: { email }, @@ -140,6 +154,6 @@ export async function login({ email, password, isLogin }) { }; } -export async function getUser({ userId }) { +export async function getUser({ userId }: { userId: string }): Promise { return await prisma.user.findUnique({ where: { id: userId } }); } diff --git a/src/lib/form.ts b/src/lib/form.ts index 08099576d..5a7d65e23 100644 --- a/src/lib/form.ts +++ b/src/lib/form.ts @@ -1,5 +1,6 @@ import { toast } from '@zerodevx/svelte-toast'; -export function errorNotification(message: string) { + +export function errorNotification(message: string): void { console.error(message); if (typeof message !== 'string') { toast.push('Ooops, something is not okay, are you okay?'); @@ -30,7 +31,7 @@ export function enhance( e.preventDefault(); let body = new FormData(form); - let parsedData = body; + const parsedData = body; body.forEach((data, key) => { if (data === '' || data === null) parsedData.delete(key); diff --git a/src/lib/haproxy/configuration.ts b/src/lib/haproxy/configuration.ts index 831d9490b..f93a34838 100644 --- a/src/lib/haproxy/configuration.ts +++ b/src/lib/haproxy/configuration.ts @@ -1,8 +1,5 @@ import { dev } from '$app/env'; -import got from 'got'; -import mustache from 'mustache'; -import crypto from 'crypto'; - +import got, { type Got } from 'got'; import * as db from '$lib/database'; import { checkContainer, checkHAProxy } from '.'; import { asyncExecShell, getDomain, getEngine } from '$lib/common'; @@ -10,7 +7,7 @@ import { supportedServiceTypesAndVersions } from '$lib/components/common'; const url = dev ? 'http://localhost:5555' : 'http://coolify-haproxy:5555'; -let template = `program api +const template = `program api command /usr/bin/dataplaneapi -f /usr/local/etc/haproxy/dataplaneapi.hcl --userlist haproxy-dataplaneapi no option start-on-reload @@ -128,7 +125,8 @@ backend {{domain}} server {{id}} {{id}}:{{port}} check fall 10 {{/coolify}} `; -export async function haproxyInstance() { + +export async function haproxyInstance(): Promise { const { proxyPassword } = await db.listSettings(); return got.extend({ prefixUrl: url, @@ -137,31 +135,96 @@ export async function haproxyInstance() { }); } -export async function configureHAProxy() { +export async function configureHAProxy(): Promise { const haproxy = await haproxyInstance(); await checkHAProxy(haproxy); - try { - const data = { - applications: [], - services: [], - coolify: [] - }; - const applications = await db.prisma.application.findMany({ - include: { destinationDocker: true, settings: true } - }); - for (const application of applications) { - const { - fqdn, - id, - port, - destinationDocker, - destinationDockerId, - settings: { previews }, - updatedAt - } = application; - if (destinationDockerId) { - const { engine, network } = destinationDocker; + const data = { + applications: [], + services: [], + coolify: [] + }; + const applications = await db.prisma.application.findMany({ + include: { destinationDocker: true, settings: true } + }); + for (const application of applications) { + const { + fqdn, + id, + port, + destinationDocker, + destinationDockerId, + settings: { previews }, + updatedAt + } = application; + if (destinationDockerId) { + const { engine, network } = destinationDocker; + const isRunning = await checkContainer(engine, id); + if (fqdn) { + const domain = getDomain(fqdn); + const isHttps = fqdn.startsWith('https://'); + const isWWW = fqdn.includes('www.'); + const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`; + if (isRunning) { + data.applications.push({ + id, + port: port || 3000, + domain, + isRunning, + isHttps, + redirectValue, + redirectTo: isWWW ? domain.replace('www.', '') : 'www.' + domain, + updatedAt: updatedAt.getTime() + }); + } + if (previews) { + const host = getEngine(engine); + const { stdout } = await asyncExecShell( + `DOCKER_HOST=${host} docker container ls --filter="status=running" --filter="network=${network}" --filter="name=${id}-" --format="{{json .Names}}"` + ); + const containers = stdout + .trim() + .split('\n') + .filter((a) => a) + .map((c) => c.replace(/"/g, '')); + if (containers.length > 0) { + for (const container of containers) { + const previewDomain = `${container.split('-')[1]}.${domain}`; + data.applications.push({ + id: container, + port: port || 3000, + domain: previewDomain, + isRunning, + isHttps, + redirectValue, + redirectTo: isWWW ? previewDomain.replace('www.', '') : 'www.' + previewDomain, + updatedAt: updatedAt.getTime() + }); + } + } + } + } + } + } + const services = await db.prisma.service.findMany({ + include: { + destinationDocker: true, + minio: true, + plausibleAnalytics: true, + vscodeserver: true, + wordpress: true, + ghost: true + } + }); + + for (const service of services) { + const { fqdn, id, type, destinationDocker, destinationDockerId, updatedAt } = service; + if (destinationDockerId) { + const { engine } = destinationDocker; + const found = supportedServiceTypesAndVersions.find((a) => a.name === type); + if (found) { + const port = found.ports.main; + const publicPort = service[type]?.publicPort; const isRunning = await checkContainer(engine, id); if (fqdn) { const domain = getDomain(fqdn); @@ -169,9 +232,10 @@ export async function configureHAProxy() { const isWWW = fqdn.includes('www.'); const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`; if (isRunning) { - data.applications.push({ + data.services.push({ id, - port: port || 3000, + port, + publicPort, domain, isRunning, isHttps, @@ -180,46 +244,24 @@ export async function configureHAProxy() { updatedAt: updatedAt.getTime() }); } - if (previews) { - const host = getEngine(engine); - const { stdout } = await asyncExecShell( - `DOCKER_HOST=${host} docker container ls --filter="status=running" --filter="network=${network}" --filter="name=${id}-" --format="{{json .Names}}"` - ); - const containers = stdout - .trim() - .split('\n') - .filter((a) => a) - .map((c) => c.replace(/"/g, '')); - if (containers.length > 0) { - for (const container of containers) { - let previewDomain = `${container.split('-')[1]}.${domain}`; - data.applications.push({ - id: container, - port: port || 3000, - domain: previewDomain, - isRunning, - isHttps, - redirectValue, - redirectTo: isWWW ? previewDomain.replace('www.', '') : 'www.' + previewDomain, - updatedAt: updatedAt.getTime() - }); - } - } - } } } } - const services = await db.prisma.service.findMany({ - include: { - destinationDocker: true, - minio: true, - plausibleAnalytics: true, - vscodeserver: true, - wordpress: true, - ghost: true - } + } + const { fqdn } = await db.prisma.setting.findFirst(); + if (fqdn) { + const domain = getDomain(fqdn); + const isHttps = fqdn.startsWith('https://'); + const isWWW = fqdn.includes('www.'); + const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`; + data.coolify.push({ + id: dev ? 'host.docker.internal' : 'coolify', + port: 3000, + domain, + isHttps, + redirectValue, + redirectTo: isWWW ? domain.replace('www.', '') : 'www.' + domain }); - for (const service of services) { const { fqdn, id, type, destinationDocker, destinationDockerId, updatedAt } = service; if (destinationDockerId) { @@ -251,37 +293,5 @@ export async function configureHAProxy() { } } } - const { fqdn } = await db.prisma.setting.findFirst(); - if (fqdn) { - const domain = getDomain(fqdn); - const isHttps = fqdn.startsWith('https://'); - const isWWW = fqdn.includes('www.'); - const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`; - data.coolify.push({ - id: dev ? 'host.docker.internal' : 'coolify', - port: 3000, - domain, - isHttps, - redirectValue, - redirectTo: isWWW ? domain.replace('www.', '') : 'www.' + domain - }); - } - const output = mustache.render(template, data); - const newHash = crypto.createHash('md5').update(output).digest('hex'); - const { proxyHash, id } = await db.listSettings(); - if (proxyHash !== newHash) { - await db.prisma.setting.update({ where: { id }, data: { proxyHash: newHash } }); - await haproxy.post(`v2/services/haproxy/configuration/raw`, { - searchParams: { - skip_version: true - }, - body: output, - headers: { - 'Content-Type': 'text/plain' - } - }); - } - } catch (error) { - throw error; } } diff --git a/src/lib/haproxy/index.ts b/src/lib/haproxy/index.ts index 98a1453f3..473660fa1 100644 --- a/src/lib/haproxy/index.ts +++ b/src/lib/haproxy/index.ts @@ -1,7 +1,8 @@ import { dev } from '$app/env'; import { asyncExecShell, getEngine } from '$lib/common'; -import got from 'got'; +import got, { type Got, type Response } from 'got'; import * as db from '$lib/database'; +import type { DestinationDocker } from '@prisma/client'; const url = dev ? 'http://localhost:5555' : 'http://coolify-haproxy:5555'; @@ -9,7 +10,7 @@ export const defaultProxyImage = `coolify-haproxy-alpine:latest`; export const defaultProxyImageTcp = `coolify-haproxy-tcp-alpine:latest`; export const defaultProxyImageHttp = `coolify-haproxy-http-alpine:latest`; -export async function haproxyInstance() { +export async function haproxyInstance(): Promise { const { proxyPassword } = await db.listSettings(); return got.extend({ prefixUrl: url, @@ -17,6 +18,7 @@ export async function haproxyInstance() { password: proxyPassword }); } + export async function getRawConfiguration(): Promise { return await (await haproxyInstance()).get(`v2/services/haproxy/configuration/raw`).json(); } @@ -43,11 +45,12 @@ export async function getNextTransactionId(): Promise { return newTransaction.id; } -export async function completeTransaction(transactionId) { +export async function completeTransaction(transactionId: string): Promise> { const haproxy = await haproxyInstance(); return await haproxy.put(`v2/services/haproxy/transactions/${transactionId}`); } -export async function deleteProxy({ id }) { + +export async function deleteProxy({ id }: { id: string }): Promise { const haproxy = await haproxyInstance(); await checkHAProxy(haproxy); @@ -77,11 +80,12 @@ export async function deleteProxy({ id }) { } } -export async function reloadHaproxy(engine) { +export async function reloadHaproxy(engine: string): Promise<{ stdout: string; stderr: string }> { const host = getEngine(engine); return await asyncExecShell(`DOCKER_HOST=${host} docker exec coolify-haproxy kill -HUP 1`); } -export async function checkHAProxy(haproxy?: any) { + +export async function checkHAProxy(haproxy?: Got): Promise { if (!haproxy) haproxy = await haproxyInstance(); try { await haproxy.get('v2/info'); @@ -93,7 +97,10 @@ export async function checkHAProxy(haproxy?: any) { } } -export async function stopTcpHttpProxy(destinationDocker, publicPort) { +export async function stopTcpHttpProxy( + destinationDocker: DestinationDocker, + publicPort: number +): Promise<{ stdout: string; stderr: string } | Error> { const { engine } = destinationDocker; const host = getEngine(engine); const containerName = `haproxy-for-${publicPort}`; @@ -108,7 +115,13 @@ export async function stopTcpHttpProxy(destinationDocker, publicPort) { return error; } } -export async function startTcpProxy(destinationDocker, id, publicPort, privatePort, volume = null) { +export async function startTcpProxy( + destinationDocker: DestinationDocker, + id: string, + publicPort: number, + privatePort: number, + volume?: string +): Promise<{ stdout: string; stderr: string } | Error> { const { network, engine } = destinationDocker; const host = getEngine(engine); @@ -132,7 +145,13 @@ export async function startTcpProxy(destinationDocker, id, publicPort, privatePo return error; } } -export async function startHttpProxy(destinationDocker, id, publicPort, privatePort) { + +export async function startHttpProxy( + destinationDocker: DestinationDocker, + id: string, + publicPort: number, + privatePort: number +): Promise<{ stdout: string; stderr: string } | Error> { const { network, engine } = destinationDocker; const host = getEngine(engine); @@ -154,7 +173,8 @@ export async function startHttpProxy(destinationDocker, id, publicPort, privateP return error; } } -export async function startCoolifyProxy(engine) { + +export async function startCoolifyProxy(engine: string): Promise { const host = getEngine(engine); const found = await checkContainer(engine, 'coolify-haproxy'); const { proxyPassword, proxyUser, id } = await db.listSettings(); @@ -170,7 +190,8 @@ export async function startCoolifyProxy(engine) { } await configureNetworkCoolifyProxy(engine); } -export async function checkContainer(engine, container) { + +export async function checkContainer(engine: string, container: string): Promise { const host = getEngine(engine); let containerFound = false; @@ -180,7 +201,7 @@ export async function checkContainer(engine, container) { ); const parsedStdout = JSON.parse(stdout); const status = parsedStdout.Status; - const isRunning = status === 'running' ? true : false; + const isRunning = status === 'running'; if (status === 'exited' || status === 'created') { await asyncExecShell(`DOCKER_HOST="${host}" docker rm ${container}`); } @@ -193,7 +214,9 @@ export async function checkContainer(engine, container) { return containerFound; } -export async function stopCoolifyProxy(engine) { +export async function stopCoolifyProxy( + engine: string +): Promise<{ stdout: string; stderr: string } | Error> { const host = getEngine(engine); const found = await checkContainer(engine, 'coolify-haproxy'); await db.setDestinationSettings({ engine, isCoolifyProxyUsed: false }); @@ -210,16 +233,12 @@ export async function stopCoolifyProxy(engine) { } } -export async function configureNetworkCoolifyProxy(engine) { +export async function configureNetworkCoolifyProxy(engine: string): Promise { const host = getEngine(engine); const destinations = await db.prisma.destinationDocker.findMany({ where: { engine } }); - destinations.forEach(async (destination) => { - try { - await asyncExecShell( - `DOCKER_HOST="${host}" docker network connect ${destination.network} coolify-haproxy` - ); - } catch (err) { - // TODO: handle error - } - }); + for (const destination of destinations) { + await asyncExecShell( + `DOCKER_HOST="${host}" docker network connect ${destination.network} coolify-haproxy` + ); + } } diff --git a/src/lib/importers/github.ts b/src/lib/importers/github.ts index 53754205e..a08fb87b4 100644 --- a/src/lib/importers/github.ts +++ b/src/lib/importers/github.ts @@ -2,11 +2,9 @@ import { asyncExecShell, saveBuildLog } from '$lib/common'; import got from 'got'; import jsonwebtoken from 'jsonwebtoken'; import * as db from '$lib/database'; -import { ErrorHandler } from '$lib/database'; export default async function ({ applicationId, - debug, workdir, githubAppId, repository, @@ -14,7 +12,16 @@ export default async function ({ htmlUrl, branch, buildId -}): Promise { +}: { + applicationId: string; + workdir: string; + githubAppId: string; + repository: string; + apiUrl: string; + htmlUrl: string; + branch: string; + buildId: string; +}): Promise { const url = htmlUrl.replace('https://', '').replace('http://', ''); await saveBuildLog({ line: 'GitHub importer started.', buildId, applicationId }); const { privateKey, appId, installationId } = await db.getUniqueGithubApp({ githubAppId }); diff --git a/src/lib/importers/gitlab.ts b/src/lib/importers/gitlab.ts index 0cf57d98a..966b22c96 100644 --- a/src/lib/importers/gitlab.ts +++ b/src/lib/importers/gitlab.ts @@ -9,7 +9,16 @@ export default async function ({ branch, buildId, privateSshKey -}): Promise { +}: { + applicationId: string; + workdir: string; + repository: string; + htmlUrl: string; + branch: string; + buildId: string; + repodir: string; + privateSshKey: string; +}): Promise { const url = htmlUrl.replace('https://', '').replace('http://', '').replace(/\/$/, ''); await saveBuildLog({ line: 'GitLab importer started.', buildId, applicationId }); await asyncExecShell(`echo '${privateSshKey}' > ${repodir}/id.rsa`); diff --git a/src/lib/letsencrypt/index.ts b/src/lib/letsencrypt/index.ts index fb1fa46ac..b90cac5bd 100644 --- a/src/lib/letsencrypt/index.ts +++ b/src/lib/letsencrypt/index.ts @@ -7,7 +7,7 @@ import fs from 'fs/promises'; import getPort, { portNumbers } from 'get-port'; import { supportedServiceTypesAndVersions } from '$lib/components/common'; -export async function letsEncrypt(domain, id = null, isCoolify = false) { +export async function letsEncrypt(domain: string, id?: string, isCoolify = false): Promise { try { const data = await db.prisma.setting.findFirst(); const { minPort, maxPort } = data; @@ -98,7 +98,7 @@ export async function letsEncrypt(domain, id = null, isCoolify = false) { } } -export async function generateSSLCerts() { +export async function generateSSLCerts(): Promise { const ssls = []; const applications = await db.prisma.application.findMany({ include: { destinationDocker: true, settings: true }, @@ -131,7 +131,7 @@ export async function generateSSLCerts() { .map((c) => c.replace(/"/g, '')); if (containers.length > 0) { for (const container of containers) { - let previewDomain = `${container.split('-')[1]}.${domain}`; + const previewDomain = `${container.split('-')[1]}.${domain}`; if (isHttps) ssls.push({ domain: previewDomain, id, isCoolify: false }); } } diff --git a/src/lib/queues/builder.ts b/src/lib/queues/builder.ts index a09e2c3bf..7419fa5dc 100644 --- a/src/lib/queues/builder.ts +++ b/src/lib/queues/builder.ts @@ -20,27 +20,22 @@ import { setDefaultConfiguration } from '$lib/buildPacks/common'; import yaml from 'js-yaml'; +import type { Job } from 'bullmq'; +import type { BuilderJob } from '$lib/types/builderJob'; + import type { ComposeFile } from '$lib/types/composeFile'; -export default async function (job) { - let { +export default async function (job: Job): Promise { + const { id: applicationId, repository, - branch, - buildPack, name, destinationDocker, destinationDockerId, gitSource, build_id: buildId, configHash, - port, - installCommand, - buildCommand, - startCommand, fqdn, - baseDirectory, - publishDirectory, projectId, secrets, phpModules, @@ -53,6 +48,16 @@ export default async function (job) { pythonModule, pythonVariable } = job.data; + let { + branch, + buildPack, + port, + installCommand, + buildCommand, + startCommand, + baseDirectory, + publishDirectory + } = job.data; const { debug } = settings; await asyncSleep(500); @@ -67,7 +72,7 @@ export default async function (job) { }); let imageId = applicationId; let domain = getDomain(fqdn); - let volumes = + const volumes = persistentStorage?.map((storage) => { return `${applicationId}${storage.path.replace(/\//gi, '-')}:${ buildPack !== 'docker' ? '/app' : '' @@ -103,7 +108,7 @@ export default async function (job) { publishDirectory = configuration.publishDirectory; baseDirectory = configuration.baseDirectory; - let commit = await importers[gitSource.type]({ + const commit = await importers[gitSource.type]({ applicationId, debug, workdir, @@ -210,9 +215,7 @@ export default async function (job) { await saveBuildLog({ line: `Build pack ${buildPack} not found`, buildId, applicationId }); throw new Error(`Build pack ${buildPack} not found.`); } - deployNeeded = true; } else { - deployNeeded = false; await saveBuildLog({ line: 'Nothing changed.', buildId, applicationId }); } diff --git a/src/lib/queues/cleanup.ts b/src/lib/queues/cleanup.ts index f89353531..3802e3317 100644 --- a/src/lib/queues/cleanup.ts +++ b/src/lib/queues/cleanup.ts @@ -1,8 +1,6 @@ -import { dev } from '$app/env'; import { asyncExecShell, getEngine, version } from '$lib/common'; import { prisma } from '$lib/database'; -import { defaultProxyImageHttp, defaultProxyImageTcp } from '$lib/haproxy'; -export default async function () { +export default async function (): Promise { const destinationDockers = await prisma.destinationDocker.findMany(); for (const destinationDocker of destinationDockers) { const host = getEngine(destinationDocker.engine); diff --git a/src/lib/queues/index.ts b/src/lib/queues/index.ts index 736d76789..21a5b0330 100644 --- a/src/lib/queues/index.ts +++ b/src/lib/queues/index.ts @@ -1,11 +1,8 @@ import * as Bullmq from 'bullmq'; -import { default as ProdBullmq, Job, QueueEvents, QueueScheduler } from 'bullmq'; -import cuid from 'cuid'; +import { default as ProdBullmq, QueueScheduler } from 'bullmq'; import { dev } from '$app/env'; import { prisma } from '$lib/database'; - import builder from './builder'; -import logger from './logger'; import cleanup from './cleanup'; import proxy from './proxy'; import ssl from './ssl'; @@ -28,7 +25,7 @@ const connectionOptions = { } }; -const cron = async () => { +const cron = async (): Promise => { new QueueScheduler('proxy', connectionOptions); new QueueScheduler('cleanup', connectionOptions); new QueueScheduler('ssl', connectionOptions); @@ -89,18 +86,6 @@ const cron = async () => { await queue.ssl.add('ssl', {}, { repeat: { every: dev ? 10000 : 60000 } }); if (!dev) await queue.cleanup.add('cleanup', {}, { repeat: { every: 300000 } }); await queue.sslRenew.add('sslRenew', {}, { repeat: { every: 1800000 } }); - - const events = { - proxy: new QueueEvents('proxy', { ...connectionOptions }), - ssl: new QueueEvents('ssl', { ...connectionOptions }) - }; - - events.proxy.on('completed', (data) => { - // console.log(data) - }); - events.ssl.on('completed', (data) => { - // console.log(data) - }); }; cron().catch((error) => { console.log('cron failed to start'); @@ -157,9 +142,5 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => { const buildLogQueueName = 'log_queue'; const buildLogQueue = new Queue(buildLogQueueName, connectionOptions); -const buildLogWorker = new Worker(buildLogQueueName, async (job) => await logger(job), { - concurrency: 1, - ...connectionOptions -}); export { buildQueue, buildLogQueue }; diff --git a/src/lib/queues/logger.ts b/src/lib/queues/logger.ts index 14665b9ad..f751f8d6f 100644 --- a/src/lib/queues/logger.ts +++ b/src/lib/queues/logger.ts @@ -1,7 +1,8 @@ import { prisma } from '$lib/database'; import { dev } from '$app/env'; +import type { Job } from 'bullmq'; -export default async function (job) { +export default async function (job: Job): Promise { const { line, applicationId, buildId } = job.data; if (dev) console.debug(`[${applicationId}] ${line}`); await prisma.buildLog.create({ data: { line, buildId, time: Number(job.id), applicationId } }); diff --git a/src/lib/queues/proxy.ts b/src/lib/queues/proxy.ts index 339e60d60..db8742e74 100644 --- a/src/lib/queues/proxy.ts +++ b/src/lib/queues/proxy.ts @@ -1,7 +1,10 @@ import { ErrorHandler } from '$lib/database'; import { configureHAProxy } from '$lib/haproxy/configuration'; -export default async function () { +export default async function (): Promise { try { return await configureHAProxy(); } catch (error) { diff --git a/src/lib/queues/ssl.ts b/src/lib/queues/ssl.ts index f041153d6..84b608fae 100644 --- a/src/lib/queues/ssl.ts +++ b/src/lib/queues/ssl.ts @@ -1,6 +1,6 @@ import { generateSSLCerts } from '$lib/letsencrypt'; -export default async function () { +export default async function (): Promise { try { return await generateSSLCerts(); } catch (error) { diff --git a/src/lib/queues/sslrenewal.ts b/src/lib/queues/sslrenewal.ts index 807aa34c5..4af5bae64 100644 --- a/src/lib/queues/sslrenewal.ts +++ b/src/lib/queues/sslrenewal.ts @@ -1,13 +1,9 @@ import { asyncExecShell } from '$lib/common'; import { reloadHaproxy } from '$lib/haproxy'; -export default async function () { - try { - await asyncExecShell( - `docker run --rm --name certbot-renewal -v "coolify-letsencrypt:/etc/letsencrypt" certbot/certbot --logs-dir /etc/letsencrypt/logs renew` - ); - await reloadHaproxy('unix:///var/run/docker.sock'); - } catch (error) { - throw error; - } +export default async function (): Promise { + await asyncExecShell( + `docker run --rm --name certbot-renewal -v "coolify-letsencrypt:/etc/letsencrypt" certbot/certbot --logs-dir /etc/letsencrypt/logs renew` + ); + await reloadHaproxy('unix:///var/run/docker.sock'); } diff --git a/src/lib/store.ts b/src/lib/store.ts index d8d1be6ce..42cb12455 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -1,6 +1,7 @@ -import { writable } from 'svelte/store'; +import { writable, type Writable } from 'svelte/store'; -export const gitTokens = writable({ - githubToken: null, - gitlabToken: null -}); +export const gitTokens: Writable<{ githubToken: string | null; gitlabToken: string | null }> = + writable({ + githubToken: null, + gitlabToken: null + }); diff --git a/src/lib/types/builderJob.ts b/src/lib/types/builderJob.ts new file mode 100644 index 000000000..1a1652f8a --- /dev/null +++ b/src/lib/types/builderJob.ts @@ -0,0 +1,51 @@ +import type { DestinationDocker, GithubApp, GitlabApp, GitSource, Secret } from '@prisma/client'; + +export type BuilderJob = { + build_id: string; + type: BuildType; + id: string; + name: string; + fqdn: string; + repository: string; + configHash: unknown; + branch: string; + buildPack: BuildPackName; + projectId: number; + port: number; + installCommand: string; + buildCommand?: string; + startCommand?: string; + baseDirectory: string; + publishDirectory: string; + phpModules: string; + pythonWSGI: string; + pythonModule: string; + pythonVariable: string; + createdAt: string; + updatedAt: string; + destinationDockerId: string; + destinationDocker: DestinationDocker; + gitSource: GitSource & { githubApp?: GithubApp; gitlabApp?: GitlabApp }; + settings: BuilderJobSettings; + secrets: Secret[]; + persistentStorage: { path: string }[]; + pullmergeRequestId?: unknown; + sourceBranch?: string; +}; + +// TODO: Add the other build types +export type BuildType = 'manual'; + +// TODO: Add the other buildpack names +export type BuildPackName = 'node' | 'docker'; + +export type BuilderJobSettings = { + id: string; + applicationId: string; + dualCerts: boolean; + debug: boolean; + previews: boolean; + autodeploy: boolean; + createdAt: string; + updatedAt: string; +}; diff --git a/src/lib/types/destinations.ts b/src/lib/types/destinations.ts new file mode 100644 index 000000000..c5a56d772 --- /dev/null +++ b/src/lib/types/destinations.ts @@ -0,0 +1,8 @@ +export type CreateDockerDestination = { + name: string; + engine: string; + remoteEngine: boolean; + network: string; + isCoolifyProxyUsed: boolean; + teamId: string; +}; diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index 09b030328..ca6857c70 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -176,7 +176,7 @@ {:else if updateStatus.success} - {:else} - diff --git a/src/routes/applications/[id]/secrets/index.svelte b/src/routes/applications/[id]/secrets/index.svelte index 5ca2bbfcb..980e88177 100644 --- a/src/routes/applications/[id]/secrets/index.svelte +++ b/src/routes/applications/[id]/secrets/index.svelte @@ -61,9 +61,6 @@ await refreshSecrets(); toast.push('Secrets saved'); } - function asd() { - console.log(secrets); - }
@@ -164,7 +161,6 @@ -

Paste .env file