From 1f73b83a79eeae890fcfaec5a12b4eef27a402a4 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 09:30:13 +0200 Subject: [PATCH 01/49] testing traefik stuff --- apps/api/src/index.ts | 6 ++++++ apps/api/src/lib/common.ts | 2 +- apps/api/src/routes/webhooks/traefik/index.ts | 3 ++- package.json | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 4b3b3998f..7eb745ae1 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -96,6 +96,12 @@ fastify.register(autoLoad, { fastify.register(cookie) fastify.register(cors); +fastify.addHook('onRequest', async (request, reply) => { + console.log({ host: request.headers.host, origin: request.headers.origin }) + if (!request.headers.origin && !request.headers.host.startsWith('host.docker.internal')) { + throw new Error('Invalid origin'); + } +}) fastify.listen({ port, host }, async (err: any, address: any) => { if (err) { console.error(err); diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index 90b35cd12..45f513550 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -21,7 +21,7 @@ import { scheduler } from './scheduler'; import { supportedServiceTypesAndVersions } from './services/supportedVersions'; import { includeServices } from './services/common'; -export const version = '3.9.0'; +export const version = '3.9.1'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/apps/api/src/routes/webhooks/traefik/index.ts b/apps/api/src/routes/webhooks/traefik/index.ts index f9c7ff4b8..3769c8eb3 100644 --- a/apps/api/src/routes/webhooks/traefik/index.ts +++ b/apps/api/src/routes/webhooks/traefik/index.ts @@ -1,4 +1,5 @@ import { FastifyPluginAsync } from 'fastify'; +import { OnlyId } from '../../../types'; import { remoteTraefikConfiguration, traefikConfiguration, traefikOtherConfiguration } from './handlers'; import { TraefikOtherConfiguration } from './types'; @@ -6,7 +7,7 @@ const root: FastifyPluginAsync = async (fastify): Promise => { fastify.get('/main.json', async (request, reply) => traefikConfiguration(request, reply)); fastify.get('/other.json', async (request, reply) => traefikOtherConfiguration(request)); - fastify.get('/remote/:id', async (request) => remoteTraefikConfiguration(request)); + fastify.get('/remote/:id', async (request) => remoteTraefikConfiguration(request)); }; export default root; diff --git a/package.json b/package.json index 2e6c23ed4..fc5b41203 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "3.9.0", + "version": "3.9.1", "license": "Apache-2.0", "repository": "github:coollabsio/coolify", "scripts": { From bdf9a73d194b5e85fede6a6f9c340fdf9380627a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 09:42:13 +0200 Subject: [PATCH 02/49] fix --- apps/api/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 7eb745ae1..e53665a2c 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -99,7 +99,7 @@ fastify.register(cors); fastify.addHook('onRequest', async (request, reply) => { console.log({ host: request.headers.host, origin: request.headers.origin }) if (!request.headers.origin && !request.headers.host.startsWith('host.docker.internal')) { - throw new Error('Invalid origin'); + } }) fastify.listen({ port, host }, async (err: any, address: any) => { From 1126dcacf57477b8bc7b8a8126fb7e07c589f786 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 10:08:31 +0200 Subject: [PATCH 03/49] update --- apps/api/src/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index e53665a2c..289b2fddf 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -97,9 +97,23 @@ fastify.register(autoLoad, { fastify.register(cookie) fastify.register(cors); fastify.addHook('onRequest', async (request, reply) => { + let allowedList = ['coolify:3000']; + const { ipv4, ipv6, fqdn } = await prisma.setting.findFirst({}) + + ipv4 && allowedList.push(ipv4); + ipv6 && allowedList.push(ipv6); + fqdn && allowedList.push(fqdn); + + const remotes = await prisma.destinationDocker.findMany({ where: { remoteEngine: true, remoteVerified: true } }) + if (remotes.length > 0) { + remotes.forEach(remote => { + allowedList.push(`${remote.remoteIpAddress}:3000`); + }) + } + console.log({ allowedList }) console.log({ host: request.headers.host, origin: request.headers.origin }) if (!request.headers.origin && !request.headers.host.startsWith('host.docker.internal')) { - + } }) fastify.listen({ port, host }, async (err: any, address: any) => { From 5a80bb1d2a10e7ff401fd0dbba913f23fd13b96b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 10:14:34 +0200 Subject: [PATCH 04/49] fix: dockerfile --- Dockerfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 938346439..59ec0df06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ FROM node:18-slim as build WORKDIR /app +ARG PNPM_VERSION=7.11.0 + RUN apt update && apt -y install curl -RUN curl -sL https://unpkg.com/@pnpm/self-installer | node +RUN npm --no-update-notifier --no-fund --global install pnpm@${PNPM_VERSION} COPY . . RUN pnpm install @@ -12,10 +14,14 @@ RUN pnpm build FROM node:18-slim WORKDIR /app ENV NODE_ENV production +ARG NPM_VERSION=8.19.1 +ARG PNPM_VERSION=7.11.0 ARG TARGETPLATFORM -RUN apt update && apt -y install git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3 && apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/ -RUN curl -sL https://unpkg.com/@pnpm/self-installer | node +RUN apt update && apt -y install --no-install-recommends ca-certificates git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3 +RUN apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/ +RUN npm --no-update-notifier --no-fund --global install pnpm@${PNPM_VERSION} +RUN npm install -g npm@${PNPM_VERSION} RUN mkdir -p ~/.docker/cli-plugins/ # https://download.docker.com/linux/static/stable/ From f4cd93bd362cccbd4ef38199e504dc6202975eb7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 10:14:39 +0200 Subject: [PATCH 05/49] test allowedlist --- apps/api/src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 289b2fddf..bd2fe73b3 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -5,7 +5,7 @@ import env from '@fastify/env'; import cookie from '@fastify/cookie'; import path, { join } from 'path'; import autoLoad from '@fastify/autoload'; -import { asyncExecShell, createRemoteEngineConfiguration, isDev, listSettings, prisma, version } from './lib/common'; +import { asyncExecShell, createRemoteEngineConfiguration, getDomain, isDev, listSettings, prisma, version } from './lib/common'; import { scheduler } from './lib/scheduler'; import { compareVersions } from 'compare-versions'; import Graceful from '@ladjs/graceful' @@ -100,9 +100,9 @@ fastify.addHook('onRequest', async (request, reply) => { let allowedList = ['coolify:3000']; const { ipv4, ipv6, fqdn } = await prisma.setting.findFirst({}) - ipv4 && allowedList.push(ipv4); + ipv4 && allowedList.push(`${ipv4}:3000`); ipv6 && allowedList.push(ipv6); - fqdn && allowedList.push(fqdn); + fqdn && allowedList.push(getDomain(fqdn)); const remotes = await prisma.destinationDocker.findMany({ where: { remoteEngine: true, remoteVerified: true } }) if (remotes.length > 0) { From 319c64714745996c514166981c675c49eca12b80 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 10:28:13 +0200 Subject: [PATCH 06/49] updates --- .github/workflows/release-candidate.yml | 2 +- apps/api/src/lib/common.ts | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index ba1de9b08..44e417ef3 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -1,5 +1,5 @@ name: release-candidate - +runs-on: self-hosted on: release: types: [prereleased] diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index 45f513550..f1b7aabae 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -21,7 +21,7 @@ import { scheduler } from './scheduler'; import { supportedServiceTypesAndVersions } from './services/supportedVersions'; import { includeServices } from './services/common'; -export const version = '3.9.1'; +export const version = '3.9.1-rc.1'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/package.json b/package.json index fc5b41203..088506285 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "3.9.1", + "version": "3.9.1-rc.1", "license": "Apache-2.0", "repository": "github:coollabsio/coolify", "scripts": { From 26e4d52a61a3ead2aa6a59f1dce7439aea81d75a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 10:30:37 +0200 Subject: [PATCH 07/49] github actions update --- .github/workflows/release-candidate.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 44e417ef3..6b92bb263 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -1,12 +1,11 @@ name: release-candidate -runs-on: self-hosted on: release: types: [prereleased] jobs: making-something-cool: - runs-on: ubuntu-latest + runs-on: self-hosted steps: - name: Checkout uses: actions/checkout@v3 From 8f14fd89efe8977237e3d95e3b21950ea017e711 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 10:43:59 +0200 Subject: [PATCH 08/49] show not allowed list --- apps/api/src/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index bd2fe73b3..3b73e4266 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -110,10 +110,8 @@ fastify.addHook('onRequest', async (request, reply) => { allowedList.push(`${remote.remoteIpAddress}:3000`); }) } - console.log({ allowedList }) - console.log({ host: request.headers.host, origin: request.headers.origin }) - if (!request.headers.origin && !request.headers.host.startsWith('host.docker.internal')) { - + if (!allowedList.includes(request.headers.host)) { + console.log('not allowed', request.headers.host) } }) fastify.listen({ port, host }, async (err: any, address: any) => { From f1f32170528ec5ef73fcb22e8a1baac49710fcf0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 10:59:50 +0200 Subject: [PATCH 09/49] testing new gh actions --- .github/workflows/release-candidate.yml | 53 ++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 6b92bb263..49f49f709 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -4,13 +4,13 @@ on: types: [prereleased] jobs: - making-something-cool: + making-something-cool-arm64: runs-on: self-hosted steps: - name: Checkout uses: actions/checkout@v3 with: - ref: 'next' + ref: "next" - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -27,12 +27,53 @@ jobs: uses: docker/build-push-action@v2 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/arm64 push: true - tags: coollabsio/coolify:${{github.event.release.name}} - cache-from: type=registry,ref=coollabsio/coolify:buildcache-rc - cache-to: type=registry,ref=coollabsio/coolify:buildcache-rc,mode=max + tags: coollabsio/coolify:${{github.event.release.name}}-arm64 + cache-from: type=registry,ref=coollabsio/coolify:buildcache-rc-arm64 + cache-to: type=registry,ref=coollabsio/coolify:buildcache-rc-arm64,mode=max - uses: sarisia/actions-status-discord@v1 if: always() with: webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }} + making-something-cool-amd64: + runs-on: self-hosted + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: "next" + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Get current package version + uses: martinbeentjes/npm-get-version-action@v1.2.3 + id: package-version + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64 + push: true + tags: coollabsio/coolify:${{github.event.release.name}}-amd64 + cache-from: type=registry,ref=coollabsio/coolify:buildcache-rc-amd64 + cache-to: type=registry,ref=coollabsio/coolify:buildcache-rc-amd64,mode=max + - uses: sarisia/actions-status-discord@v1 + if: always() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }} + merge-manifest: + runs-on: self-hosted + steps: + - name: Create and push manifest images + uses: Noelware/docker-manifest-action@master + with: + base-image: coollabsio/coolify:${{github.event.release.name}} + extra-images: coollabsio/coolify:${{github.event.release.name}}-amd64,coollabsio/coolify:${{github.event.release.name}}-arm64 + push: true From e26dd578ef70ea1a94579e0a3a7cdacbf278c8be Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:02:33 +0200 Subject: [PATCH 10/49] fixes --- .github/workflows/release-candidate.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 49f49f709..47deb015f 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -4,7 +4,7 @@ on: types: [prereleased] jobs: - making-something-cool-arm64: + arm64-making-something-cool: runs-on: self-hosted steps: - name: Checkout @@ -36,7 +36,7 @@ jobs: if: always() with: webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }} - making-something-cool-amd64: + amd64-making-something-cool: runs-on: self-hosted steps: - name: Checkout @@ -68,8 +68,9 @@ jobs: if: always() with: webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }} - merge-manifest: + merge-manifest-to-be-cool: runs-on: self-hosted + needs: [arm64-making-something-cool, amd64-making-something-cool] steps: - name: Create and push manifest images uses: Noelware/docker-manifest-action@master From 86cc665b58493628275eea94a6e848a078e80e3b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:05:40 +0200 Subject: [PATCH 11/49] fix --- .github/workflows/release-candidate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 47deb015f..d1aaff49c 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -5,7 +5,7 @@ on: jobs: arm64-making-something-cool: - runs-on: self-hosted + runs-on: [self-hosted, arm64] steps: - name: Checkout uses: actions/checkout@v3 @@ -37,7 +37,7 @@ jobs: with: webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }} amd64-making-something-cool: - runs-on: self-hosted + runs-on: [self-hosted, x64] steps: - name: Checkout uses: actions/checkout@v3 From 00b1a4f1743cb8afe2400170893b379b0c8b2b08 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:21:58 +0200 Subject: [PATCH 12/49] fix flow --- .github/workflows/release-candidate.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index d1aaff49c..16ac5b761 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -37,7 +37,7 @@ jobs: with: webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }} amd64-making-something-cool: - runs-on: [self-hosted, x64] + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 @@ -69,12 +69,15 @@ jobs: with: webhook: ${{ secrets.DISCORD_WEBHOOK_DEV_RELEASE_CHANNEL }} merge-manifest-to-be-cool: - runs-on: self-hosted + runs-on: ubuntu-latest needs: [arm64-making-something-cool, amd64-making-something-cool] steps: - - name: Create and push manifest images - uses: Noelware/docker-manifest-action@master + - name: Login to DockerHub + uses: docker/login-action@v2 with: - base-image: coollabsio/coolify:${{github.event.release.name}} - extra-images: coollabsio/coolify:${{github.event.release.name}}-amd64,coollabsio/coolify:${{github.event.release.name}}-arm64 - push: true + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Create manifest + run: bash docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 + - name: Push Manifest + run: bash docker manifest push coollabsio/coolify:${{github.event.release.name}} From b1c1138cf82646c0045a899363382ae163344ba0 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:31:02 +0200 Subject: [PATCH 13/49] fixit now --- .github/workflows/release-candidate.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 16ac5b761..f98c83879 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -77,7 +77,11 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create manifest - run: bash docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 - - name: Push Manifest - run: bash docker manifest push coollabsio/coolify:${{github.event.release.name}} + - name: Create & push manifest + uses: addnab/docker-run-action@v3 + with: + image: docker:latest + shell: bash + run: | + docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 + docker manifest push coollabsio/coolify:${{github.event.release.name}} From 1db3d7a6fb4023a2dfe4c65653af64c1650cdd67 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:31:54 +0200 Subject: [PATCH 14/49] fixit --- .github/workflows/release-candidate.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index f98c83879..a8f3c8aaf 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -72,14 +72,11 @@ jobs: runs-on: ubuntu-latest needs: [arm64-making-something-cool, amd64-making-something-cool] steps: - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Create & push manifest uses: addnab/docker-run-action@v3 with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} image: docker:latest shell: bash run: | From 20ac8f69ea159c4472cf01e7de16c551812de2ae Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:38:36 +0200 Subject: [PATCH 15/49] Update dockerfile --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 59ec0df06..0e6a464b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ +ARG PNPM_VERSION=7.11.0 +ARG NPM_VERSION=8.19.1 +ARG TARGETPLATFORM + FROM node:18-slim as build WORKDIR /app -ARG PNPM_VERSION=7.11.0 - RUN apt update && apt -y install curl RUN npm --no-update-notifier --no-fund --global install pnpm@${PNPM_VERSION} @@ -14,9 +16,6 @@ RUN pnpm build FROM node:18-slim WORKDIR /app ENV NODE_ENV production -ARG NPM_VERSION=8.19.1 -ARG PNPM_VERSION=7.11.0 -ARG TARGETPLATFORM RUN apt update && apt -y install --no-install-recommends ca-certificates git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3 RUN apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/ From 8c4149db16e0bd53fa1a6bd7437858d71930597b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:42:00 +0200 Subject: [PATCH 16/49] fix issues --- .github/workflows/release-candidate.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index a8f3c8aaf..da1345175 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -78,7 +78,6 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} image: docker:latest - shell: bash run: | docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 docker manifest push coollabsio/coolify:${{github.event.release.name}} From 216c7efd42bcae42acc8637b45fb8ba80cc2a0f9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 11:55:16 +0200 Subject: [PATCH 17/49] fixxxxx --- .github/workflows/release-candidate.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index da1345175..176326fa9 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -72,12 +72,15 @@ jobs: runs-on: ubuntu-latest needs: [arm64-making-something-cool, amd64-making-something-cool] steps: + - name: Login to docker hub + if: success() + uses: actions-hub/docker/login@v1.0.3 + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - name: Create & push manifest - uses: addnab/docker-run-action@v3 + uses: actions-hub/docker@v1.0.3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - image: docker:latest run: | docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 docker manifest push coollabsio/coolify:${{github.event.release.name}} From 7d504ab2bff59abe02d3159e9ecf0aa3ff8f517a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 12:02:03 +0200 Subject: [PATCH 18/49] fixxxx --- .github/workflows/release-candidate.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 176326fa9..081c81797 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -72,14 +72,15 @@ jobs: runs-on: ubuntu-latest needs: [arm64-making-something-cool, amd64-making-something-cool] steps: + - name: Checkout + uses: actions/checkout@v3 - name: Login to docker hub if: success() uses: actions-hub/docker/login@v1.0.3 env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - name: Create & push manifest - uses: actions-hub/docker@v1.0.3 with: run: | docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 From 2fc65e3b42748891cf2fa31bdbac49278ddcf1f9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 12:04:58 +0200 Subject: [PATCH 19/49] grr --- .github/workflows/release-candidate.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 081c81797..2699f392a 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -81,7 +81,6 @@ jobs: DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - name: Create & push manifest - with: - run: | + run: | docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 docker manifest push coollabsio/coolify:${{github.event.release.name}} From eba63e8e76b56e36bde050f452f1d0f7468accbf Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 12:54:38 +0200 Subject: [PATCH 20/49] fix --- .github/workflows/release-candidate.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 2699f392a..2afcd9855 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -74,13 +74,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Login to docker hub - if: success() - uses: actions-hub/docker/login@v1.0.3 + - name: Create & push manifest + uses: actions-hub/docker/cli@v1.0.3 env: DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create & push manifest run: | docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 docker manifest push coollabsio/coolify:${{github.event.release.name}} From 3b11e28d6c6011a5985673eb09062bbff5d02025 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 12:56:02 +0200 Subject: [PATCH 21/49] asd --- .github/workflows/release-candidate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 2afcd9855..015e51e16 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -79,6 +79,6 @@ jobs: env: DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - run: | + - run: | docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 docker manifest push coollabsio/coolify:${{github.event.release.name}} From 986cdae5b02cff4632ad8047bf2063ffeb29a230 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 13:01:55 +0200 Subject: [PATCH 22/49] asd --- .github/workflows/release-candidate.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 015e51e16..886c78ecc 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -74,6 +74,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Login to docker hub + if: success() + uses: actions-hub/docker/login@v1.0.3 + env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - name: Create & push manifest uses: actions-hub/docker/cli@v1.0.3 env: From 5c7859a2581374880bc87ed225bf53c73fc4826b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 13:08:29 +0200 Subject: [PATCH 23/49] asd --- .github/workflows/release-candidate.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 886c78ecc..52a0f0b17 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -80,11 +80,15 @@ jobs: env: DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create & push manifest + - name: Create manifest uses: actions-hub/docker/cli@v1.0.3 env: DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - - run: | - docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 - docker manifest push coollabsio/coolify:${{github.event.release.name}} + - run: docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 + - name: Push manifest + uses: actions-hub/docker/cli@v1.0.3 + env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + - run: docker manifest push coollabsio/coolify:${{github.event.release.name}} From cef1fba281a9f0acca8fa3d42df12ab6a62b4b3c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 13:23:53 +0200 Subject: [PATCH 24/49] finally?! --- .github/workflows/release-candidate.yml | 32 +++++++++++-------------- apps/api/src/lib/common.ts | 10 +++++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 52a0f0b17..51fbb0a66 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -74,21 +74,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Login to docker hub - if: success() - uses: actions-hub/docker/login@v1.0.3 - env: - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create manifest - uses: actions-hub/docker/cli@v1.0.3 - env: - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - - run: docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 - - name: Push manifest - uses: actions-hub/docker/cli@v1.0.3 - env: - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - - run: docker manifest push coollabsio/coolify:${{github.event.release.name}} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Create & publish manifest + run: | + docker manifest create coollabsio/coolify:v3.9.1-rc.1 --amend coollabsio/coolify:v3.9.1-rc.1-amd64 --amend coollabsio/coolify:v3.9.1-rc.1-arm64 + docker manifest push coollabsio/coolify:v3.9.1-rc.1 + diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index f1b7aabae..8144e41bf 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -974,9 +974,13 @@ export const createDirectories = async ({ }): Promise<{ workdir: string; repodir: string }> => { const repodir = `/tmp/build-sources/${repository}/`; const workdir = `/tmp/build-sources/${repository}/${buildId}`; - - await asyncExecShell(`mkdir -p ${workdir}`); - + try { + await fs.stat(workdir); + await asyncExecShell(`rm -fr ${workdir}`); + await asyncExecShell(`mkdir -p ${workdir}`); + } catch(error) { + await asyncExecShell(`mkdir -p ${workdir}`); + } return { workdir, repodir From 95a5089bdc7e9a83366d6347c672df5afcf0b742 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 14:08:10 +0200 Subject: [PATCH 25/49] fix: debug api logging + gh actions --- .github/workflows/release-candidate.yml | 4 +- .github/workflows/staging-release.yml | 64 ++++- .../migration.sql | 2 + apps/api/prisma/schema.prisma | 1 + apps/api/src/index.ts | 255 +++++++++--------- apps/api/src/jobs/deployApplication.ts | 6 - apps/api/src/lib/common.ts | 2 +- .../src/routes/api/v1/settings/handlers.ts | 3 +- apps/api/src/routes/api/v1/settings/types.ts | 1 + apps/ui/src/routes/settings/global.svelte | 15 +- package.json | 2 +- 11 files changed, 211 insertions(+), 144 deletions(-) create mode 100644 apps/api/prisma/migrations/20220906120112_enable_api_debug_logging/migration.sql diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 51fbb0a66..305ea3ad9 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -85,6 +85,6 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Create & publish manifest run: | - docker manifest create coollabsio/coolify:v3.9.1-rc.1 --amend coollabsio/coolify:v3.9.1-rc.1-amd64 --amend coollabsio/coolify:v3.9.1-rc.1-arm64 - docker manifest push coollabsio/coolify:v3.9.1-rc.1 + docker manifest create coollabsio/coolify:${{github.event.release.name}} --amend coollabsio/coolify:${{github.event.release.name}}-amd64 --amend coollabsio/coolify:${{github.event.release.name}}-arm64 + docker manifest push coollabsio/coolify:${{github.event.release.name}} diff --git a/.github/workflows/staging-release.yml b/.github/workflows/staging-release.yml index 86fed13ff..61f488a8e 100644 --- a/.github/workflows/staging-release.yml +++ b/.github/workflows/staging-release.yml @@ -6,11 +6,13 @@ on: - next jobs: - staging-release: - runs-on: ubuntu-latest + arm64-making-something-cool: + runs-on: [self-hosted, arm64] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + ref: "next" - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -20,15 +22,65 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Get current package version + uses: martinbeentjes/npm-get-version-action@v1.2.3 + id: package-version - name: Build and push uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/arm64 + push: true + tags: coollabsio/coolify:next-arm64 + cache-from: type=registry,ref=coollabsio/coolify:buildcache-next-arm64 + cache-to: type=registry,ref=coollabsio/coolify:buildcache-next-arm64,mode=max + amd64-making-something-cool: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: "next" + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Get current package version + uses: martinbeentjes/npm-get-version-action@v1.2.3 + id: package-version + - name: Build and push + uses: docker/build-push-action@v3 with: context: . platforms: linux/amd64 push: true - tags: coollabsio/coolify:next - cache-from: type=registry,ref=coollabsio/coolify:buildcache-next - cache-to: type=registry,ref=coollabsio/coolify:buildcache-next,mode=max + tags: coollabsio/coolify:next-amd64 + cache-from: type=registry,ref=coollabsio/coolify:buildcache-next-amd64 + cache-to: type=registry,ref=coollabsio/coolify:buildcache-next-amd64,mode=max + merge-manifest-to-be-cool: + runs-on: ubuntu-latest + needs: [arm64-making-something-cool, amd64-making-something-cool] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Create & publish manifest + run: | + docker manifest create coollabsio/coolify:next --amend coollabsio/coolify:next-amd64 --amend coollabsio/coolify:next-arm64 + docker manifest push coollabsio/coolify:next - uses: sarisia/actions-status-discord@v1 if: always() with: diff --git a/apps/api/prisma/migrations/20220906120112_enable_api_debug_logging/migration.sql b/apps/api/prisma/migrations/20220906120112_enable_api_debug_logging/migration.sql new file mode 100644 index 000000000..05fb3e285 --- /dev/null +++ b/apps/api/prisma/migrations/20220906120112_enable_api_debug_logging/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Setting" ADD COLUMN "isAPIDebuggingEnabled" BOOLEAN DEFAULT false; diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index 64657e887..681293b53 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -11,6 +11,7 @@ datasource db { model Setting { id String @id @default(cuid()) fqdn String? @unique + isAPIDebuggingEnabled Boolean? @default(false) isRegistrationEnabled Boolean @default(false) dualCerts Boolean @default(false) minPort Int @default(9000) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 3b73e4266..902596459 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -26,140 +26,143 @@ declare module 'fastify' { const port = isDev ? 3001 : 3000; const host = '0.0.0.0'; -const fastify = Fastify({ - logger: false, - trustProxy: true -}); -const schema = { - type: 'object', - required: ['COOLIFY_SECRET_KEY', 'COOLIFY_DATABASE_URL', 'COOLIFY_IS_ON'], - properties: { - COOLIFY_APP_ID: { - type: 'string', - }, - COOLIFY_SECRET_KEY: { - type: 'string', - }, - COOLIFY_DATABASE_URL: { - type: 'string', - default: 'file:../db/dev.db' - }, - COOLIFY_SENTRY_DSN: { - type: 'string', - default: null - }, - COOLIFY_IS_ON: { - type: 'string', - default: 'docker' - }, - COOLIFY_WHITE_LABELED: { - type: 'string', - default: 'false' - }, - COOLIFY_WHITE_LABELED_ICON: { - type: 'string', - default: null - }, - COOLIFY_AUTO_UPDATE: { - type: 'string', - default: 'false' - }, - - } -}; - -const options = { - schema, - dotenv: true -}; -fastify.register(env, options); -if (!isDev) { - fastify.register(serve, { - root: path.join(__dirname, './public'), - preCompressed: true +prisma.setting.findFirst().then(async (settings) => { + const fastify = Fastify({ + logger: settings?.isAPIDebuggingEnabled || false, + trustProxy: true }); - fastify.setNotFoundHandler(async function (request, reply) { - if (request.raw.url && request.raw.url.startsWith('/api')) { - return reply.status(404).send({ - success: false - }); + const schema = { + type: 'object', + required: ['COOLIFY_SECRET_KEY', 'COOLIFY_DATABASE_URL', 'COOLIFY_IS_ON'], + properties: { + COOLIFY_APP_ID: { + type: 'string', + }, + COOLIFY_SECRET_KEY: { + type: 'string', + }, + COOLIFY_DATABASE_URL: { + type: 'string', + default: 'file:../db/dev.db' + }, + COOLIFY_SENTRY_DSN: { + type: 'string', + default: null + }, + COOLIFY_IS_ON: { + type: 'string', + default: 'docker' + }, + COOLIFY_WHITE_LABELED: { + type: 'string', + default: 'false' + }, + COOLIFY_WHITE_LABELED_ICON: { + type: 'string', + default: null + }, + COOLIFY_AUTO_UPDATE: { + type: 'string', + default: 'false' + }, + } - return reply.status(200).sendFile('index.html'); + }; + + const options = { + schema, + dotenv: true + }; + fastify.register(env, options); + if (!isDev) { + fastify.register(serve, { + root: path.join(__dirname, './public'), + preCompressed: true + }); + fastify.setNotFoundHandler(async function (request, reply) { + if (request.raw.url && request.raw.url.startsWith('/api')) { + return reply.status(404).send({ + success: false + }); + } + return reply.status(200).sendFile('index.html'); + }); + } + fastify.register(autoLoad, { + dir: join(__dirname, 'plugins') + }); + fastify.register(autoLoad, { + dir: join(__dirname, 'routes') }); -} -fastify.register(autoLoad, { - dir: join(__dirname, 'plugins') -}); -fastify.register(autoLoad, { - dir: join(__dirname, 'routes') -}); -fastify.register(cookie) -fastify.register(cors); -fastify.addHook('onRequest', async (request, reply) => { - let allowedList = ['coolify:3000']; - const { ipv4, ipv6, fqdn } = await prisma.setting.findFirst({}) + fastify.register(cookie) + fastify.register(cors); + fastify.addHook('onRequest', async (request, reply) => { + let allowedList = ['coolify:3000']; + const { ipv4, ipv6, fqdn } = await prisma.setting.findFirst({}) - ipv4 && allowedList.push(`${ipv4}:3000`); - ipv6 && allowedList.push(ipv6); - fqdn && allowedList.push(getDomain(fqdn)); + ipv4 && allowedList.push(`${ipv4}:3000`); + ipv6 && allowedList.push(ipv6); + fqdn && allowedList.push(getDomain(fqdn)); + isDev && allowedList.push('localhost:3000') && allowedList.push('localhost:3001') && allowedList.push('host.docker.internal:3001'); + const remotes = await prisma.destinationDocker.findMany({ where: { remoteEngine: true, remoteVerified: true } }) + if (remotes.length > 0) { + remotes.forEach(remote => { + allowedList.push(`${remote.remoteIpAddress}:3000`); + }) + } + if (!allowedList.includes(request.headers.host)) { + // console.log('not allowed', request.headers.host) + } + }) + fastify.listen({ port, host }, async (err: any, address: any) => { + if (err) { + console.error(err); + process.exit(1); + } + console.log(`Coolify's API is listening on ${host}:${port}`); + await initServer(); - const remotes = await prisma.destinationDocker.findMany({ where: { remoteEngine: true, remoteVerified: true } }) - if (remotes.length > 0) { - remotes.forEach(remote => { - allowedList.push(`${remote.remoteIpAddress}:3000`); - }) - } - if (!allowedList.includes(request.headers.host)) { - console.log('not allowed', request.headers.host) - } + const graceful = new Graceful({ brees: [scheduler] }); + graceful.listen(); + + setInterval(async () => { + if (!scheduler.workers.has('deployApplication')) { + scheduler.run('deployApplication'); + } + if (!scheduler.workers.has('infrastructure')) { + scheduler.run('infrastructure'); + } + }, 2000) + + // autoUpdater + setInterval(async () => { + scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:autoUpdater") + }, isDev ? 5000 : 60000 * 15) + + // cleanupStorage + setInterval(async () => { + scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupStorage") + }, isDev ? 6000 : 60000 * 10) + + // checkProxies + setInterval(async () => { + scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:checkProxies") + }, 10000) + + // cleanupPrismaEngines + // setInterval(async () => { + // scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupPrismaEngines") + // }, 60000) + + await Promise.all([ + getArch(), + getIPAddress(), + configureRemoteDockers(), + ]) + }); }) -fastify.listen({ port, host }, async (err: any, address: any) => { - if (err) { - console.error(err); - process.exit(1); - } - console.log(`Coolify's API is listening on ${host}:${port}`); - await initServer(); - const graceful = new Graceful({ brees: [scheduler] }); - graceful.listen(); - - setInterval(async () => { - if (!scheduler.workers.has('deployApplication')) { - scheduler.run('deployApplication'); - } - if (!scheduler.workers.has('infrastructure')) { - scheduler.run('infrastructure'); - } - }, 2000) - - // autoUpdater - setInterval(async () => { - scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:autoUpdater") - }, isDev ? 5000 : 60000 * 15) - - // cleanupStorage - setInterval(async () => { - scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupStorage") - }, isDev ? 6000 : 60000 * 10) - - // checkProxies - setInterval(async () => { - scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:checkProxies") - }, 10000) - - // cleanupPrismaEngines - // setInterval(async () => { - // scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupPrismaEngines") - // }, 60000) - - await Promise.all([ - getArch(), - getIPAddress(), - // configureRemoteDockers(), - ]) -}); async function getIPAddress() { const { publicIpv4, publicIpv6 } = await import('public-ip') try { diff --git a/apps/api/src/jobs/deployApplication.ts b/apps/api/src/jobs/deployApplication.ts index 7ec322f63..945883bb2 100644 --- a/apps/api/src/jobs/deployApplication.ts +++ b/apps/api/src/jobs/deployApplication.ts @@ -357,21 +357,15 @@ import * as buildpacks from '../lib/buildPacks'; await saveBuildLog({ line: error, buildId, applicationId: application.id }); } }); - } - await pAll.default(actions, { concurrency }) } } catch (error) { console.log(error) - } finally { } }) - while (true) { await th() } - - } else process.exit(0); })(); diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index 8144e41bf..ca70fa512 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -21,7 +21,7 @@ import { scheduler } from './scheduler'; import { supportedServiceTypesAndVersions } from './services/supportedVersions'; import { includeServices } from './services/common'; -export const version = '3.9.1-rc.1'; +export const version = '3.9.1'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/apps/api/src/routes/api/v1/settings/handlers.ts b/apps/api/src/routes/api/v1/settings/handlers.ts index 068d2c97e..e9d91dd8c 100644 --- a/apps/api/src/routes/api/v1/settings/handlers.ts +++ b/apps/api/src/routes/api/v1/settings/handlers.ts @@ -28,6 +28,7 @@ export async function saveSettings(request: FastifyRequest, reply: try { const { fqdn, + isAPIDebuggingEnabled, isRegistrationEnabled, dualCerts, minPort, @@ -39,7 +40,7 @@ export async function saveSettings(request: FastifyRequest, reply: const { id } = await listSettings(); await prisma.setting.update({ where: { id }, - data: { isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, isDNSCheckEnabled, DNSServers } + data: { isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, isDNSCheckEnabled, DNSServers, isAPIDebuggingEnabled } }); if (fqdn) { await prisma.setting.update({ where: { id }, data: { fqdn } }); diff --git a/apps/api/src/routes/api/v1/settings/types.ts b/apps/api/src/routes/api/v1/settings/types.ts index d8fcf816d..956c58b5c 100644 --- a/apps/api/src/routes/api/v1/settings/types.ts +++ b/apps/api/src/routes/api/v1/settings/types.ts @@ -3,6 +3,7 @@ import { OnlyId } from "../../../../types" export interface SaveSettings { Body: { fqdn: string, + isAPIDebuggingEnabled: boolean, isRegistrationEnabled: boolean, dualCerts: boolean, minPort: number, diff --git a/apps/ui/src/routes/settings/global.svelte b/apps/ui/src/routes/settings/global.svelte index 219730d9a..98da276be 100644 --- a/apps/ui/src/routes/settings/global.svelte +++ b/apps/ui/src/routes/settings/global.svelte @@ -27,6 +27,7 @@ import Menu from './_Menu.svelte'; import Explainer from '$lib/components/Explainer.svelte'; + let isAPIDebuggingEnabled = settings.isAPIDebuggingEnabled; let isRegistrationEnabled = settings.isRegistrationEnabled; let dualCerts = settings.dualCerts; let isAutoUpdateEnabled = settings.isAutoUpdateEnabled; @@ -75,8 +76,11 @@ if (name === 'isDNSCheckEnabled') { isDNSCheckEnabled = !isDNSCheckEnabled; } - + if (name === 'isAPIDebuggingEnabled') { + isAPIDebuggingEnabled = !isAPIDebuggingEnabled; + } await post(`/settings`, { + isAPIDebuggingEnabled, isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, @@ -310,6 +314,15 @@ on:click={() => changeSettings('isRegistrationEnabled')} /> +
+ changeSettings('isAPIDebuggingEnabled')} + /> +
{#if browser && $features.beta}
Date: Tue, 6 Sep 2022 14:20:14 +0200 Subject: [PATCH 26/49] Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0e6a464b2..675fe5b5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ ARG PNPM_VERSION=7.11.0 ARG NPM_VERSION=8.19.1 -ARG TARGETPLATFORM FROM node:18-slim as build WORKDIR /app @@ -16,6 +15,7 @@ RUN pnpm build FROM node:18-slim WORKDIR /app ENV NODE_ENV production +ARG TARGETPLATFORM RUN apt update && apt -y install --no-install-recommends ca-certificates git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3 RUN apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/ From 021b9746a8ad2457e6afd291206f1a51ac24b29a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 14:29:54 +0200 Subject: [PATCH 27/49] update production release --- .github/workflows/production-release.yml | 59 +++++++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/.github/workflows/production-release.yml b/.github/workflows/production-release.yml index baf574184..961e1f18f 100644 --- a/.github/workflows/production-release.yml +++ b/.github/workflows/production-release.yml @@ -5,11 +5,11 @@ on: types: [released] jobs: - making-something-cool: - runs-on: ubuntu-latest + arm64-build: + runs-on: [self-hosted, arm64] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -26,11 +26,56 @@ jobs: uses: docker/build-push-action@v2 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/arm64 push: true - tags: coollabsio/coolify:latest,coollabsio/coolify:${{steps.package-version.outputs.current-version}} - cache-from: type=registry,ref=coollabsio/coolify:buildcache - cache-to: type=registry,ref=coollabsio/coolify:buildcache,mode=max + tags: coollabsio/coolify:${{steps.package-version.outputs.current-version}}-arm64 + cache-from: type=registry,ref=coollabsio/coolify:buildcache-arm64 + cache-to: type=registry,ref=coollabsio/coolify:buildcache-arm64,mode=max + amd64-build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Get current package version + uses: martinbeentjes/npm-get-version-action@v1.2.3 + id: package-version + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64 + push: true + tags: coollabsio/coolify:${{steps.package-version.outputs.current-version}}-amd64 + cache-from: type=registry,ref=coollabsio/coolify:buildcache-amd64 + cache-to: type=registry,ref=coollabsio/coolify:buildcache-amd64,mode=max + merge-manifest: + runs-on: ubuntu-latest + needs: [amd64-build, arm64-build] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Create & publish manifest + run: | + docker manifest create coollabsio/coolify:${{steps.package-version.outputs.current-version}} --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-amd64 --amend coollabsio/coolify:${{steps.package-version.outputs.current-version}}-arm64 + docker manifest push coollabsio/coolify:${{steps.package-version.outputs.current-version}} - uses: sarisia/actions-status-discord@v1 if: always() with: From ea594dcbc65fcdd27378dc74ad72e02116a98ce8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 14:32:50 +0200 Subject: [PATCH 28/49] fix: workdir --- apps/api/src/lib/common.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index ca70fa512..7d1ca3a9b 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -974,13 +974,14 @@ export const createDirectories = async ({ }): Promise<{ workdir: string; repodir: string }> => { const repodir = `/tmp/build-sources/${repository}/`; const workdir = `/tmp/build-sources/${repository}/${buildId}`; + let workdirFound = false; try { - await fs.stat(workdir); + workdirFound = !!(await fs.stat(workdir)); + } catch (error) { } + if (workdirFound) { await asyncExecShell(`rm -fr ${workdir}`); - await asyncExecShell(`mkdir -p ${workdir}`); - } catch(error) { - await asyncExecShell(`mkdir -p ${workdir}`); } + await asyncExecShell(`mkdir -p ${workdir}`); return { workdir, repodir From 20ce356296413d25e1dde32787e9dc41a676be47 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 14:47:37 +0200 Subject: [PATCH 29/49] fix: move restart button to settings --- apps/ui/src/lib/components/Usage.svelte | 50 ++--------------------- apps/ui/src/routes/settings/global.svelte | 49 +++++++++++++++++++--- 2 files changed, 47 insertions(+), 52 deletions(-) diff --git a/apps/ui/src/lib/components/Usage.svelte b/apps/ui/src/lib/components/Usage.svelte index e5437a1d5..a5128c6b6 100644 --- a/apps/ui/src/lib/components/Usage.svelte +++ b/apps/ui/src/lib/components/Usage.svelte @@ -20,13 +20,12 @@ let usageInterval: any; let loading = { usage: false, - cleanup: false, - restart: false + cleanup: false }; import { addToast, appSession } from '$lib/store'; import { onDestroy, onMount } from 'svelte'; import { get, post } from '$lib/api'; - import { asyncSleep, errorNotification } from '$lib/common'; + import { errorNotification } from '$lib/common'; async function getStatus() { if (loading.usage) return; loading.usage = true; @@ -34,45 +33,7 @@ usage = data.usage; loading.usage = false; } - async function restartCoolify() { - const sure = confirm( - 'Are you sure you would like to restart Coolify? Currently running deployments will be stopped and restarted.' - ); - if (sure) { - loading.restart = true; - try { - await post(`/internal/restart`, {}); - await asyncSleep(10000); - let reachable = false; - let tries = 0; - do { - await asyncSleep(4000); - try { - await get(`/undead`); - reachable = true; - } catch (error) { - reachable = false; - } - if (reachable) break; - tries++; - } while (!reachable || tries < 120); - addToast({ - message: 'New version reachable. Reloading...', - type: 'success' - }); - await asyncSleep(3000); - return window.location.reload(); - addToast({ - type: 'success', - message: 'Coolify restarted successfully. It will take a moment.' - }); - } catch (error) { - return errorNotification(error); - } finally { - loading.restart = false; - } - } - } + onDestroy(() => { clearInterval(usageInterval); }); @@ -112,11 +73,6 @@ - {/if}
diff --git a/apps/ui/src/routes/settings/global.svelte b/apps/ui/src/routes/settings/global.svelte index 98da276be..ee64d908e 100644 --- a/apps/ui/src/routes/settings/global.svelte +++ b/apps/ui/src/routes/settings/global.svelte @@ -23,7 +23,7 @@ import { browser } from '$app/env'; import { t } from '$lib/translations'; import { addToast, appSession, features } from '$lib/store'; - import { errorNotification, getDomain } from '$lib/common'; + import { asyncSleep, errorNotification, getDomain } from '$lib/common'; import Menu from './_Menu.svelte'; import Explainer from '$lib/components/Explainer.svelte'; @@ -45,7 +45,8 @@ let loading = { save: false, remove: false, - proxyMigration: false + proxyMigration: false, + restart: false }; async function removeFqdn() { @@ -156,6 +157,41 @@ function resetView() { forceSave = false; } + async function restartCoolify() { + const sure = confirm( + 'Are you sure you would like to restart Coolify? Currently running deployments will be stopped and restarted.' + ); + if (sure) { + loading.restart = true; + try { + await post(`/internal/restart`, {}); + await asyncSleep(10000); + let reachable = false; + let tries = 0; + do { + await asyncSleep(4000); + try { + await get(`/undead`); + reachable = true; + } catch (error) { + reachable = false; + } + if (reachable) break; + tries++; + } while (!reachable || tries < 120); + addToast({ + message: 'New version reachable. Reloading...', + type: 'success' + }); + await asyncSleep(3000); + return window.location.reload(); + } catch (error) { + return errorNotification(error); + } finally { + loading.restart = false; + } + } + }
@@ -186,11 +222,14 @@ on:click|preventDefault={removeFqdn} disabled={loading.remove} class="btn btn-sm" - class:bg-red-600={!loading.remove} - class:hover:bg-red-500={!loading.remove} >{loading.remove ? $t('forms.removing') : $t('forms.remove_domain')} {/if} +
@@ -319,7 +358,7 @@ id="isAPIDebuggingEnabled" bind:setting={isAPIDebuggingEnabled} title="API Debugging" - description="Enable API debugging. This will log all API requests and responses.

You need to restart the Coolify (button on dashboard) for this to take effect." + description="Enable API debugging. This will log all API requests and responses.

You need to restart the Coolify for this to take effect." on:click={() => changeSettings('isAPIDebuggingEnabled')} />
From 476db15431e38401c6fd5009fa4f88e30cd52f29 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 14:49:48 +0200 Subject: [PATCH 30/49] test --- .github/workflows/staging-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging-release.yml b/.github/workflows/staging-release.yml index 61f488a8e..7a5e5474f 100644 --- a/.github/workflows/staging-release.yml +++ b/.github/workflows/staging-release.yml @@ -59,7 +59,7 @@ jobs: context: . platforms: linux/amd64 push: true - tags: coollabsio/coolify:next-amd64 + tags: coollabsio/coolify:next-amd64,coollabsio/coolify:next-test cache-from: type=registry,ref=coollabsio/coolify:buildcache-next-amd64 cache-to: type=registry,ref=coollabsio/coolify:buildcache-next-amd64,mode=max merge-manifest-to-be-cool: From d8bdb73140884b90602eee99f6bf541301d5c9c8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 14:59:24 +0200 Subject: [PATCH 31/49] test tagging --- .github/workflows/staging-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/staging-release.yml b/.github/workflows/staging-release.yml index 7a5e5474f..56ba6a533 100644 --- a/.github/workflows/staging-release.yml +++ b/.github/workflows/staging-release.yml @@ -81,6 +81,8 @@ jobs: run: | docker manifest create coollabsio/coolify:next --amend coollabsio/coolify:next-amd64 --amend coollabsio/coolify:next-arm64 docker manifest push coollabsio/coolify:next + docker tag coollabsio/coolify:next coollabsio/coolify:next-test + docker push coollabsio/coolify:next-test - uses: sarisia/actions-status-discord@v1 if: always() with: From 9d6317f78220372685935f3bb5f1218e2fb2d879 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 15:13:51 +0200 Subject: [PATCH 32/49] fix --- .github/workflows/staging-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/staging-release.yml b/.github/workflows/staging-release.yml index 56ba6a533..9332e22ab 100644 --- a/.github/workflows/staging-release.yml +++ b/.github/workflows/staging-release.yml @@ -81,6 +81,7 @@ jobs: run: | docker manifest create coollabsio/coolify:next --amend coollabsio/coolify:next-amd64 --amend coollabsio/coolify:next-arm64 docker manifest push coollabsio/coolify:next + docker pull coollabsio/coolify:next docker tag coollabsio/coolify:next coollabsio/coolify:next-test docker push coollabsio/coolify:next-test - uses: sarisia/actions-status-discord@v1 From 8b7406e168d4e5c0bfdf691d6556f7e5745567d8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 15:25:18 +0200 Subject: [PATCH 33/49] revert --- .github/workflows/staging-release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/staging-release.yml b/.github/workflows/staging-release.yml index 9332e22ab..7a5e5474f 100644 --- a/.github/workflows/staging-release.yml +++ b/.github/workflows/staging-release.yml @@ -81,9 +81,6 @@ jobs: run: | docker manifest create coollabsio/coolify:next --amend coollabsio/coolify:next-amd64 --amend coollabsio/coolify:next-arm64 docker manifest push coollabsio/coolify:next - docker pull coollabsio/coolify:next - docker tag coollabsio/coolify:next coollabsio/coolify:next-test - docker push coollabsio/coolify:next-test - uses: sarisia/actions-status-discord@v1 if: always() with: From fc705746c0dad1c10caa29f7c20ee43971e3269a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 15:45:29 +0200 Subject: [PATCH 34/49] fix: gitlab webhook --- apps/api/src/routes/webhooks/gitlab/handlers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/src/routes/webhooks/gitlab/handlers.ts b/apps/api/src/routes/webhooks/gitlab/handlers.ts index e661a29c5..58d01182a 100644 --- a/apps/api/src/routes/webhooks/gitlab/handlers.ts +++ b/apps/api/src/routes/webhooks/gitlab/handlers.ts @@ -133,7 +133,7 @@ export async function gitLabEvents(request: FastifyRequest) { await prisma.build.create({ data: { id: buildId, - pullmergeRequestId, + pullmergeRequestId: pullmergeRequestId.toString(), sourceBranch, applicationId: application.id, destinationDockerId: application.destinationDocker.id, From 6088f2e573f9f7d6bf5adf34dbe09718e1b6bbde Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Sep 2022 15:46:22 +0200 Subject: [PATCH 35/49] chore: version++ --- apps/api/src/lib/common.ts | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index 7d1ca3a9b..cba901255 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -21,7 +21,7 @@ import { scheduler } from './scheduler'; import { supportedServiceTypesAndVersions } from './services/supportedVersions'; import { includeServices } from './services/common'; -export const version = '3.9.1'; +export const version = '3.9.2'; export const isDev = process.env.NODE_ENV === 'development'; const algorithm = 'aes-256-ctr'; diff --git a/package.json b/package.json index fc5b41203..d3e4c5004 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "3.9.1", + "version": "3.9.2", "license": "Apache-2.0", "repository": "github:coollabsio/coolify", "scripts": { From adc5965b32ca7510899c64fce00a676772217858 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 08:57:32 +0200 Subject: [PATCH 36/49] fix: use ip address instead of window location --- apps/ui/src/routes/sources/[id]/_Github.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ui/src/routes/sources/[id]/_Github.svelte b/apps/ui/src/routes/sources/[id]/_Github.svelte index e9b229290..c98ee4f4f 100644 --- a/apps/ui/src/routes/sources/[id]/_Github.svelte +++ b/apps/ui/src/routes/sources/[id]/_Github.svelte @@ -46,8 +46,8 @@ customPort: source.customPort }); const { organization, htmlUrl } = source; - const { fqdn } = settings; - const host = dev ? getAPIUrl() : fqdn ? fqdn : `http://${window.location.host}` || ''; + const { fqdn, ipv4, ipv6 } = settings; + const host = dev ? getAPIUrl() : fqdn ? fqdn : `http://${ipv4 || ipv6}` || ''; const domain = getDomain(fqdn); let url = 'settings/apps/new'; From 3f2dcccc07e1fae16c06f820eea02ad59043271a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 08:58:27 +0200 Subject: [PATCH 37/49] fix: use ip instead of window location host --- apps/ui/src/routes/services/[id]/_Services/_Wordpress.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ui/src/routes/services/[id]/_Services/_Wordpress.svelte b/apps/ui/src/routes/services/[id]/_Services/_Wordpress.svelte index 474aa2f13..29f9a1ca3 100644 --- a/apps/ui/src/routes/services/[id]/_Services/_Wordpress.svelte +++ b/apps/ui/src/routes/services/[id]/_Services/_Wordpress.svelte @@ -12,7 +12,7 @@ export let readOnly: any; export let settings: any; const { id } = $page.params; - + const { ipv4, ipv6 } = settings; let ftpUrl = generateUrl(service.wordpress.ftpPublicPort); let ftpUser = service.wordpress.ftpUser; let ftpPassword = service.wordpress.ftpPassword; @@ -22,7 +22,7 @@ function generateUrl(publicPort: any) { return browser ? `sftp://${ - settings?.fqdn ? getDomain(settings.fqdn) : window.location.hostname + settings?.fqdn ? getDomain(settings.fqdn) : ipv4 || ipv6 }:${publicPort}` : 'Loading...'; } From 7e0a1ecc808139bf941848da0b23ddb2578b3b4c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 08:58:40 +0200 Subject: [PATCH 38/49] ui: fix login/register page --- apps/ui/src/routes/login.svelte | 2 +- apps/ui/src/routes/register.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ui/src/routes/login.svelte b/apps/ui/src/routes/login.svelte index 40f5fc2fe..9b68b6d11 100644 --- a/apps/ui/src/routes/login.svelte +++ b/apps/ui/src/routes/login.svelte @@ -70,7 +70,7 @@
-

Coolify dashboard

+

Coolify

{/if} diff --git a/apps/ui/src/routes/register.svelte b/apps/ui/src/routes/register.svelte index 0cdf81c4a..2c920311a 100644 --- a/apps/ui/src/routes/register.svelte +++ b/apps/ui/src/routes/register.svelte @@ -100,7 +100,7 @@
-

Coolify dashboard

+

Coolify

{/if} From a5548c080c87b2adee0c1dc79d03cfbe70164a00 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 08:58:51 +0200 Subject: [PATCH 39/49] fix: service state update --- .../routes/services/[id]/_Services/_Services.svelte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/ui/src/routes/services/[id]/_Services/_Services.svelte b/apps/ui/src/routes/services/[id]/_Services/_Services.svelte index 0c05271b6..c84f7efa2 100644 --- a/apps/ui/src/routes/services/[id]/_Services/_Services.svelte +++ b/apps/ui/src/routes/services/[id]/_Services/_Services.svelte @@ -12,7 +12,14 @@ import { get, post } from '$lib/api'; import { errorNotification, getDomain } from '$lib/common'; import { t } from '$lib/translations'; - import { appSession, disabledButton, status, location, setLocation, addToast } from '$lib/store'; + import { + appSession, + status, + setLocation, + addToast, + checkIfDeploymentEnabledServices, + isDeploymentEnabled + } from '$lib/store'; import CopyPasswordField from '$lib/components/CopyPasswordField.svelte'; import Setting from '$lib/components/Setting.svelte'; @@ -78,8 +85,8 @@ }); await post(`/services/${id}`, { ...service }); setLocation(service); - $disabledButton = false; forceSave = false; + $isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service); return addToast({ message: 'Configuration saved.', type: 'success' From 2f772080b8ed28071589ba7d65020da956f18275 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:06:30 +0200 Subject: [PATCH 40/49] fix: add initial DNS servers --- apps/api/prisma/seed.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/prisma/seed.js b/apps/api/prisma/seed.js index 9fa55136f..eeb41b253 100644 --- a/apps/api/prisma/seed.js +++ b/apps/api/prisma/seed.js @@ -17,7 +17,6 @@ const algorithm = 'aes-256-ctr'; async function main() { // Enable registration for the first user - // Set initial HAProxy password const settingsFound = await prisma.setting.findFirst({}); if (!settingsFound) { await prisma.setting.create({ @@ -25,7 +24,8 @@ async function main() { isRegistrationEnabled: true, proxyPassword: encrypt(generatePassword()), proxyUser: cuid(), - arch: process.arch + arch: process.arch, + DNSServers: '1.1.1.1,8.8.8.8' } }); } else { From 05a1721499d0601d8e89a1de96678eb2c6683771 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:15:03 +0200 Subject: [PATCH 41/49] fix: revert last change with domain check --- apps/api/src/routes/api/v1/applications/handlers.ts | 2 -- apps/ui/src/routes/applications/[id]/index.svelte | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts index e37590381..1d00e94d1 100644 --- a/apps/api/src/routes/api/v1/applications/handlers.ts +++ b/apps/api/src/routes/api/v1/applications/handlers.ts @@ -525,9 +525,7 @@ export async function checkDomain(request: FastifyRequest) { } export async function checkDNS(request: FastifyRequest) { try { - const { id } = request.params - let { exposePort, fqdn, forceSave, dualCerts } = request.body if (!fqdn) { return {} diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelte index f11286b98..d9df70f4e 100644 --- a/apps/ui/src/routes/applications/[id]/index.svelte +++ b/apps/ui/src/routes/applications/[id]/index.svelte @@ -218,7 +218,7 @@ if (loading) return; loading = true; try { - nonWWWDomain = application.fqdn != null && getDomain(application.fqdn).replace(/^www\./, ''); + nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, ''); if (application.deploymentType) application.deploymentType = application.deploymentType.toLowerCase(); !isBot && From 53e70fbfcb78e0c32a29e4e2c351156b623c289b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:15:10 +0200 Subject: [PATCH 42/49] dev: update devcontainer --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 64c664a9e..25e97c31a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -20,7 +20,8 @@ "svelte.svelte-vscode", "ardenivanov.svelte-intellisense", "Prisma.prisma", - "bradlc.vscode-tailwindcss" + "bradlc.vscode-tailwindcss", + "waderyan.gitblame" ], // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [3000, 3001], From eef313665b3e54f301b7ffc7b117302fba0a4961 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:18:44 +0200 Subject: [PATCH 43/49] fix: service volume generation --- apps/api/src/lib/services/handlers.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/api/src/lib/services/handlers.ts b/apps/api/src/lib/services/handlers.ts index d66747e67..a609ce3e1 100644 --- a/apps/api/src/lib/services/handlers.ts +++ b/apps/api/src/lib/services/handlers.ts @@ -198,7 +198,7 @@ COPY ./init-db.sh /docker-entrypoint-initdb.d/init-db.sh`; await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile); - const { volumeMounts } = persistentVolumes(id, persistentStorage, config.plausibleAnalytics) + const { volumeMounts } = persistentVolumes(id, persistentStorage, config) const composeFile: ComposeFile = { version: '3.8', @@ -852,7 +852,7 @@ async function startGhostService(request: FastifyRequest) { }); } - const { volumeMounts } = persistentVolumes(id, persistentStorage, config.ghost) + const { volumeMounts } = persistentVolumes(id, persistentStorage, config) const composeFile: ComposeFile = { version: '3.8', services: { @@ -1086,7 +1086,7 @@ async function startUmamiService(request: FastifyRequest) { FROM ${config.postgresql.image} COPY ./schema.postgresql.sql /docker-entrypoint-initdb.d/schema.postgresql.sql`; await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile); - const { volumeMounts } = persistentVolumes(id, persistentStorage, config.umami) + const { volumeMounts } = persistentVolumes(id, persistentStorage, config) const composeFile: ComposeFile = { version: '3.8', services: { @@ -1114,6 +1114,7 @@ async function startUmamiService(request: FastifyRequest) { }, volumes: volumeMounts }; + console.log(composeFile) const composeFileDestination = `${workdir}/docker-compose.yaml`; await fs.writeFile(composeFileDestination, yaml.dump(composeFile)); await startServiceContainers(destinationDocker.id, composeFileDestination) @@ -1167,7 +1168,7 @@ async function startHasuraService(request: FastifyRequest) { }); } - const { volumeMounts } = persistentVolumes(id, persistentStorage, config.hasura) + const { volumeMounts } = persistentVolumes(id, persistentStorage, config) const composeFile: ComposeFile = { version: '3.8', services: { @@ -1272,7 +1273,7 @@ async function startFiderService(request: FastifyRequest) { config.fider.environmentVariables[secret.name] = secret.value; }); } - const { volumeMounts } = persistentVolumes(id, persistentStorage, config.fider) + const { volumeMounts } = persistentVolumes(id, persistentStorage, config) const composeFile: ComposeFile = { version: '3.8', services: { @@ -1880,7 +1881,7 @@ async function startMoodleService(request: FastifyRequest) { config.moodle.environmentVariables[secret.name] = secret.value; }); } - const { volumeMounts } = persistentVolumes(id, persistentStorage, config.moodle) + const { volumeMounts } = persistentVolumes(id, persistentStorage, config) const composeFile: ComposeFile = { version: '3.8', services: { @@ -2006,7 +2007,7 @@ async function startGlitchTipService(request: FastifyRequest) config.glitchTip.environmentVariables[secret.name] = secret.value; }); } - const { volumeMounts } = persistentVolumes(id, persistentStorage, config.glitchTip) + const { volumeMounts } = persistentVolumes(id, persistentStorage, config) const composeFile: ComposeFile = { version: '3.8', services: { From 9161882f3346969b8e1b11bda27ed6be1aba64a6 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:21:28 +0200 Subject: [PATCH 44/49] debug: add debug log --- apps/ui/src/routes/applications/[id]/index.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelte index d9df70f4e..291ebd820 100644 --- a/apps/ui/src/routes/applications/[id]/index.svelte +++ b/apps/ui/src/routes/applications/[id]/index.svelte @@ -219,6 +219,7 @@ loading = true; try { nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, ''); + console.log({debug: nonWWWDomain}) if (application.deploymentType) application.deploymentType = application.deploymentType.toLowerCase(); !isBot && From 8dee345f859c268e7e00610a44ac28f73185e84b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:23:03 +0200 Subject: [PATCH 45/49] enable autoupdate option for everyone --- apps/ui/src/routes/settings/global.svelte | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/ui/src/routes/settings/global.svelte b/apps/ui/src/routes/settings/global.svelte index ee64d908e..287274e24 100644 --- a/apps/ui/src/routes/settings/global.svelte +++ b/apps/ui/src/routes/settings/global.svelte @@ -362,17 +362,15 @@ on:click={() => changeSettings('isAPIDebuggingEnabled')} /> - {#if browser && $features.beta} -
- changeSettings('isAutoUpdateEnabled')} - /> -
- {/if} +
+ changeSettings('isAutoUpdateEnabled')} + /> +
From 98073202e934eb91182439ec1b510f9d1c3584e8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:28:53 +0200 Subject: [PATCH 46/49] fix: minio default env variables --- apps/api/src/lib/services/handlers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/src/lib/services/handlers.ts b/apps/api/src/lib/services/handlers.ts index a609ce3e1..f56657ce7 100644 --- a/apps/api/src/lib/services/handlers.ts +++ b/apps/api/src/lib/services/handlers.ts @@ -333,6 +333,8 @@ async function startMinioService(request: FastifyRequest) { image: `${image}:${version}`, volumes: [`${id}-minio-data:/data`], environmentVariables: { + MINIO_SERVER_URL: fqdn, + MINIO_DOMAIN: getDomain(fqdn), MINIO_ROOT_USER: rootUser, MINIO_ROOT_PASSWORD: rootUserPassword, MINIO_BROWSER_REDIRECT_URL: fqdn @@ -2476,7 +2478,7 @@ async function startTaigaService(request: FastifyRequest) { TAIGA_SECRET_KEY: secretKey, } }, - + postgresql: { image: `postgres:12.3`, volumes: [`${id}-postgresql-data:/var/lib/postgresql/data`], From e7919e9a1b403598daba10acff11b2f95b34da11 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 09:39:29 +0200 Subject: [PATCH 47/49] ui: fix initial loading icon bg --- apps/ui/src/routes/applications/[id]/__layout.svelte | 2 +- apps/ui/src/routes/databases/[id]/__layout.svelte | 2 +- apps/ui/src/routes/services/[id]/__layout.svelte | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/ui/src/routes/applications/[id]/__layout.svelte b/apps/ui/src/routes/applications/[id]/__layout.svelte index a9cd88482..0384dab28 100644 --- a/apps/ui/src/routes/applications/[id]/__layout.svelte +++ b/apps/ui/src/routes/applications/[id]/__layout.svelte @@ -244,7 +244,7 @@ {/if} {#if $status.application.initialLoading}