diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 51e36ede7..02d9bce92 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -31,28 +31,6 @@ jobs: - name: Run Build run: pnpm build - - build-docker-on-pr: - if: github.event_name == 'pull_request' - needs: build-app - runs-on: ubuntu-latest - steps: - - name: Check out the code - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Prepare .env file - run: | - cp .env.production.example .env.production - - - name: Run custom Docker build script - run: | - chmod +x ./docker/build.sh - echo "Building Docker image for ${{ github.base_ref }}" - ./docker/build.sh ${{ github.base_ref == 'canary' && 'canary' || '' }} - build-and-push-docker-on-push: if: github.event_name == 'push' runs-on: ubuntu-latest @@ -75,7 +53,5 @@ jobs: - name: Build and push Docker image using custom script run: | - chmod +x ./docker/build.sh chmod +x ./docker/push.sh - ./docker/build.sh ${{ github.ref_name == 'canary' && 'canary' || '' }} ./docker/push.sh ${{ github.ref_name == 'canary' && 'canary' || '' }} \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh index 22104934d..ef38fa4fa 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -10,9 +10,8 @@ else TAG="$VERSION" fi -docker build --platform linux/amd64 --pull --rm -f 'Dockerfile' -t "dokploy/dokploy:${TAG}" . +BUILDER=$(docker buildx create --use) -if [ "$BUILD_TYPE" != "canary" ]; then - # Tag the production build as latest - docker tag "dokploy/dokploy:${TAG}" "dokploy/dokploy:latest" -fi +docker buildx build --platform linux/amd64,linux/arm64 --pull --rm -t "dokploy/dokploy:${TAG}" -f 'Dockerfile' . + +docker buildx rm $BUILDER diff --git a/docker/push.sh b/docker/push.sh index 1e9fbecaf..1c41f68aa 100755 --- a/docker/push.sh +++ b/docker/push.sh @@ -3,13 +3,16 @@ # Determine the type of build based on the first script argument BUILD_TYPE=${1:-production} +BUILDER=$(docker buildx create --use) + if [ "$BUILD_TYPE" == "canary" ]; then TAG="canary" echo PUSHING CANARY - docker push "dokploy/dokploy:${TAG}" + docker buildx build --platform linux/amd64,linux/arm64 --pull --rm -t "dokploy/dokploy:${TAG}" -f 'Dockerfile' --push . else echo "PUSHING PRODUCTION" VERSION=$(node -p "require('./package.json').version") - docker push "dokploy/dokploy:${VERSION}" - docker push "dokploy/dokploy:latest" + docker buildx build --platform linux/amd64,linux/arm64 --pull --rm -t "dokploy/dokploy:latest" -t "dokploy/dokploy:${VERSION}" -f 'Dockerfile' --push . fi + +docker buildx rm $BUILDER \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index 95e4a206d..3dc0f83c7 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -6,11 +6,6 @@ /** @type {import("next").NextConfig} */ const nextConfig = { reactStrictMode: true, - logging:{ - fetches:{ - fullUrl:false - } - }, /** * If you are using `appDir` then you must comment the below `i18n` config out. diff --git a/package.json b/package.json index 258f32bf7..9afbe835e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dokploy", - "version": "v0.0.1", + "version": "v0.0.2", "private": true, "license": "AGPL-3.0-only", "type": "module", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 21d314ee7..61d1677b7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -85,7 +85,7 @@ dependencies: version: 10.45.2(@trpc/server@10.45.2) '@trpc/next': specifier: ^10.43.6 - version: 10.45.2(@tanstack/react-query@4.36.1)(@trpc/client@10.45.2)(@trpc/react-query@10.45.2)(@trpc/server@10.45.2)(next@14.1.3)(react-dom@18.2.0)(react@18.2.0) + version: 10.45.2(@tanstack/react-query@4.36.1)(@trpc/client@10.45.2)(@trpc/react-query@10.45.2)(@trpc/server@10.45.2)(next@14.2.3)(react-dom@18.2.0)(react@18.2.0) '@trpc/react-query': specifier: ^10.43.6 version: 10.45.2(@tanstack/react-query@4.36.1)(@trpc/client@10.45.2)(@trpc/server@10.45.2)(react-dom@18.2.0)(react@18.2.0) @@ -157,10 +157,10 @@ dependencies: version: 3.3.7 next: specifier: ^14.1.3 - version: 14.1.3(react-dom@18.2.0)(react@18.2.0) + version: 14.2.3(react-dom@18.2.0)(react@18.2.0) next-themes: specifier: ^0.2.1 - version: 0.2.1(next@14.1.3)(react-dom@18.2.0)(react@18.2.0) + version: 0.2.1(next@14.2.3)(react-dom@18.2.0)(react@18.2.0) node-os-utils: specifier: 1.3.7 version: 1.3.7 @@ -1853,12 +1853,12 @@ packages: dev: false optional: true - /@next/env@14.1.3: - resolution: {integrity: sha512-VhgXTvrgeBRxNPjyfBsDIMvgsKDxjlpw4IAUsHCX8Gjl1vtHUYRT3+xfQ/wwvLPDd/6kqfLqk9Pt4+7gysuCKQ==} + /@next/env@14.2.3: + resolution: {integrity: sha512-W7fd7IbkfmeeY2gXrzJYDx8D2lWKbVoTIj1o1ScPHNzvp30s1AuoEFSdr39bC5sjxJaxTtq3OTCZboNp0lNWHA==} dev: false - /@next/swc-darwin-arm64@14.1.3: - resolution: {integrity: sha512-LALu0yIBPRiG9ANrD5ncB3pjpO0Gli9ZLhxdOu6ZUNf3x1r3ea1rd9Q+4xxUkGrUXLqKVK9/lDkpYIJaCJ6AHQ==} + /@next/swc-darwin-arm64@14.2.3: + resolution: {integrity: sha512-3pEYo/RaGqPP0YzwnlmPN2puaF2WMLM3apt5jLW2fFdXD9+pqcoTzRk+iZsf8ta7+quAe4Q6Ms0nR0SFGFdS1A==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -1866,8 +1866,8 @@ packages: dev: false optional: true - /@next/swc-darwin-x64@14.1.3: - resolution: {integrity: sha512-E/9WQeXxkqw2dfcn5UcjApFgUq73jqNKaE5bysDm58hEUdUGedVrnRhblhJM7HbCZNhtVl0j+6TXsK0PuzXTCg==} + /@next/swc-darwin-x64@14.2.3: + resolution: {integrity: sha512-6adp7waE6P1TYFSXpY366xwsOnEXM+y1kgRpjSRVI2CBDOcbRjsJ67Z6EgKIqWIue52d2q/Mx8g9MszARj8IEA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -1875,8 +1875,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-gnu@14.1.3: - resolution: {integrity: sha512-USArX9B+3rZSXYLFvgy0NVWQgqh6LHWDmMt38O4lmiJNQcwazeI6xRvSsliDLKt+78KChVacNiwvOMbl6g6BBw==} + /@next/swc-linux-arm64-gnu@14.2.3: + resolution: {integrity: sha512-cuzCE/1G0ZSnTAHJPUT1rPgQx1w5tzSX7POXSLaS7w2nIUJUD+e25QoXD/hMfxbsT9rslEXugWypJMILBj/QsA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1884,8 +1884,8 @@ packages: dev: false optional: true - /@next/swc-linux-arm64-musl@14.1.3: - resolution: {integrity: sha512-esk1RkRBLSIEp1qaQXv1+s6ZdYzuVCnDAZySpa62iFTMGTisCyNQmqyCTL9P+cLJ4N9FKCI3ojtSfsyPHJDQNw==} + /@next/swc-linux-arm64-musl@14.2.3: + resolution: {integrity: sha512-0D4/oMM2Y9Ta3nGuCcQN8jjJjmDPYpHX9OJzqk42NZGJocU2MqhBq5tWkJrUQOQY9N+In9xOdymzapM09GeiZw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -1893,8 +1893,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-gnu@14.1.3: - resolution: {integrity: sha512-8uOgRlYEYiKo0L8YGeS+3TudHVDWDjPVDUcST+z+dUzgBbTEwSSIaSgF/vkcC1T/iwl4QX9iuUyUdQEl0Kxalg==} + /@next/swc-linux-x64-gnu@14.2.3: + resolution: {integrity: sha512-ENPiNnBNDInBLyUU5ii8PMQh+4XLr4pG51tOp6aJ9xqFQ2iRI6IH0Ds2yJkAzNV1CfyagcyzPfROMViS2wOZ9w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1902,8 +1902,8 @@ packages: dev: false optional: true - /@next/swc-linux-x64-musl@14.1.3: - resolution: {integrity: sha512-DX2zqz05ziElLoxskgHasaJBREC5Y9TJcbR2LYqu4r7naff25B4iXkfXWfcp69uD75/0URmmoSgT8JclJtrBoQ==} + /@next/swc-linux-x64-musl@14.2.3: + resolution: {integrity: sha512-BTAbq0LnCbF5MtoM7I/9UeUu/8ZBY0i8SFjUMCbPDOLv+un67e2JgyN4pmgfXBwy/I+RHu8q+k+MCkDN6P9ViQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -1911,8 +1911,8 @@ packages: dev: false optional: true - /@next/swc-win32-arm64-msvc@14.1.3: - resolution: {integrity: sha512-HjssFsCdsD4GHstXSQxsi2l70F/5FsRTRQp8xNgmQs15SxUfUJRvSI9qKny/jLkY3gLgiCR3+6A7wzzK0DBlfA==} + /@next/swc-win32-arm64-msvc@14.2.3: + resolution: {integrity: sha512-AEHIw/dhAMLNFJFJIJIyOFDzrzI5bAjI9J26gbO5xhAKHYTZ9Or04BesFPXiAYXDNdrwTP2dQceYA4dL1geu8A==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -1920,8 +1920,8 @@ packages: dev: false optional: true - /@next/swc-win32-ia32-msvc@14.1.3: - resolution: {integrity: sha512-DRuxD5axfDM1/Ue4VahwSxl1O5rn61hX8/sF0HY8y0iCbpqdxw3rB3QasdHn/LJ6Wb2y5DoWzXcz3L1Cr+Thrw==} + /@next/swc-win32-ia32-msvc@14.2.3: + resolution: {integrity: sha512-vga40n1q6aYb0CLrM+eEmisfKCR45ixQYXuBXxOOmmoV8sYST9k7E3US32FsY+CkkF7NtzdcebiFT4CHuMSyZw==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -1929,8 +1929,8 @@ packages: dev: false optional: true - /@next/swc-win32-x64-msvc@14.1.3: - resolution: {integrity: sha512-uC2DaDoWH7h1P/aJ4Fok3Xiw6P0Lo4ez7NbowW2VGNXw/Xv6tOuLUcxhBYZxsSUJtpeknCi8/fvnSpyCFp4Rcg==} + /@next/swc-win32-x64-msvc@14.2.3: + resolution: {integrity: sha512-Q1/zm43RWynxrO7lW4ehciQVj+5ePBhOK+/K2P7pLFX3JaJ/IZVC69SHidrmZSOkqz7ECIOhhy7XhAFG4JYyHA==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -4124,9 +4124,14 @@ packages: tslib: 2.6.2 dev: false - /@swc/helpers@0.5.2: - resolution: {integrity: sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==} + /@swc/counter@0.1.3: + resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} + dev: false + + /@swc/helpers@0.5.5: + resolution: {integrity: sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==} dependencies: + '@swc/counter': 0.1.3 tslib: 2.6.2 dev: false @@ -4184,7 +4189,7 @@ packages: '@trpc/server': 10.45.2 dev: false - /@trpc/next@10.45.2(@tanstack/react-query@4.36.1)(@trpc/client@10.45.2)(@trpc/react-query@10.45.2)(@trpc/server@10.45.2)(next@14.1.3)(react-dom@18.2.0)(react@18.2.0): + /@trpc/next@10.45.2(@tanstack/react-query@4.36.1)(@trpc/client@10.45.2)(@trpc/react-query@10.45.2)(@trpc/server@10.45.2)(next@14.2.3)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-RSORmfC+/nXdmRY1pQ0AalsVgSzwNAFbZLYHiTvPM5QQ8wmMEHilseCYMXpu0se/TbPt9zVR6Ka2d7O6zxKkXg==} peerDependencies: '@tanstack/react-query': ^4.18.0 @@ -4199,7 +4204,7 @@ packages: '@trpc/client': 10.45.2(@trpc/server@10.45.2) '@trpc/react-query': 10.45.2(@tanstack/react-query@4.36.1)(@trpc/client@10.45.2)(@trpc/server@10.45.2)(react-dom@18.2.0)(react@18.2.0) '@trpc/server': 10.45.2 - next: 14.1.3(react-dom@18.2.0)(react@18.2.0) + next: 14.2.3(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) dev: false @@ -6182,14 +6187,14 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - /next-themes@0.2.1(next@14.1.3)(react-dom@18.2.0)(react@18.2.0): + /next-themes@0.2.1(next@14.2.3)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-B+AKNfYNIzh0vqQQKqQItTS8evEouKD7H5Hj3kmuPERwddR2TxvDSFZuTj6T7Jfn1oyeUyJMydPl1Bkxkh0W7A==} peerDependencies: next: '*' react: '*' react-dom: '*' dependencies: - next: 14.1.3(react-dom@18.2.0)(react@18.2.0) + next: 14.2.3(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) dev: false @@ -6198,23 +6203,26 @@ packages: resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} dev: true - /next@14.1.3(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-oexgMV2MapI0UIWiXKkixF8J8ORxpy64OuJ/J9oVUmIthXOUCcuVEZX+dtpgq7wIfIqtBwQsKEDXejcjTsan9g==} + /next@14.2.3(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A==} engines: {node: '>=18.17.0'} hasBin: true peerDependencies: '@opentelemetry/api': ^1.1.0 + '@playwright/test': ^1.41.2 react: ^18.2.0 react-dom: ^18.2.0 sass: ^1.3.0 peerDependenciesMeta: '@opentelemetry/api': optional: true + '@playwright/test': + optional: true sass: optional: true dependencies: - '@next/env': 14.1.3 - '@swc/helpers': 0.5.2 + '@next/env': 14.2.3 + '@swc/helpers': 0.5.5 busboy: 1.6.0 caniuse-lite: 1.0.30001598 graceful-fs: 4.2.11 @@ -6223,15 +6231,15 @@ packages: react-dom: 18.2.0(react@18.2.0) styled-jsx: 5.1.1(react@18.2.0) optionalDependencies: - '@next/swc-darwin-arm64': 14.1.3 - '@next/swc-darwin-x64': 14.1.3 - '@next/swc-linux-arm64-gnu': 14.1.3 - '@next/swc-linux-arm64-musl': 14.1.3 - '@next/swc-linux-x64-gnu': 14.1.3 - '@next/swc-linux-x64-musl': 14.1.3 - '@next/swc-win32-arm64-msvc': 14.1.3 - '@next/swc-win32-ia32-msvc': 14.1.3 - '@next/swc-win32-x64-msvc': 14.1.3 + '@next/swc-darwin-arm64': 14.2.3 + '@next/swc-darwin-x64': 14.2.3 + '@next/swc-linux-arm64-gnu': 14.2.3 + '@next/swc-linux-arm64-musl': 14.2.3 + '@next/swc-linux-x64-gnu': 14.2.3 + '@next/swc-linux-x64-musl': 14.2.3 + '@next/swc-win32-arm64-msvc': 14.2.3 + '@next/swc-win32-ia32-msvc': 14.2.3 + '@next/swc-win32-x64-msvc': 14.2.3 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros diff --git a/server/api/routers/domain.ts b/server/api/routers/domain.ts index 2abe710c3..ace938c01 100644 --- a/server/api/routers/domain.ts +++ b/server/api/routers/domain.ts @@ -52,7 +52,7 @@ export const domainRouter = createTRPCRouter({ .mutation(async ({ input }) => { const domain = await findDomainById(input.domainId); const result = await removeDomainById(input.domainId); - removeDomain(domain.application.appName, domain.uniqueConfigKey); + await removeDomain(domain.application.appName, domain.uniqueConfigKey); return result; }), diff --git a/server/api/services/application.ts b/server/api/services/application.ts index d7efc4339..d5da79c40 100644 --- a/server/api/services/application.ts +++ b/server/api/services/application.ts @@ -36,9 +36,8 @@ export const createApplication = async ( }); } - createTraefikConfig(newApplication.appName); - if (process.env.NODE_ENV === "development") { + createTraefikConfig(newApplication.appName); await tx.insert(domains).values({ applicationId: newApplication.applicationId, host: `${newApplication.appName}.docker.localhost`, diff --git a/server/server.ts b/server/server.ts index 20af88ade..cc2bd042e 100644 --- a/server/server.ts +++ b/server/server.ts @@ -48,9 +48,9 @@ void app.prepare().then(async () => { await initializeNetwork(); createDefaultTraefikConfig(); createDefaultServerTraefikConfig(); + await initializePostgres(); await initializeTraefik(); await initializeRedis(); - await initializePostgres(); initCronJobs(); welcomeServer(); diff --git a/server/utils/builders/index.ts b/server/utils/builders/index.ts index 9d0cf8da4..f952ab867 100644 --- a/server/utils/builders/index.ts +++ b/server/utils/builders/index.ts @@ -17,7 +17,7 @@ import { buildPaketo } from "./paketo"; // NIXPACKS codeDirectory = where is the path of the code directory // HEROKU codeDirectory = where is the path of the code directory // PAKETO codeDirectory = where is the path of the code directory -// DOKERFILE codeDirectory = where is the exact path of the (Dockerfile) +// DOCKERFILE codeDirectory = where is the exact path of the (Dockerfile) export type ApplicationNested = InferResultType< "applications", { mounts: true; security: true; redirects: true; ports: true } diff --git a/server/utils/traefik/domain.ts b/server/utils/traefik/domain.ts index cf0faa17e..689afbbb9 100644 --- a/server/utils/traefik/domain.ts +++ b/server/utils/traefik/domain.ts @@ -1,6 +1,7 @@ import { createServiceConfig, loadOrCreateConfig, + removeTraefikConfig, writeTraefikConfig, } from "./application"; import type { ApplicationNested } from "../builders"; @@ -23,7 +24,7 @@ export const manageDomain = async (app: ApplicationNested, domain: Domain) => { writeTraefikConfig(config, appName); }; -export const removeDomain = (appName: string, uniqueKey: number) => { +export const removeDomain = async (appName: string, uniqueKey: number) => { const config: FileConfig = loadOrCreateConfig(appName); const routerKey = `${appName}-router-${uniqueKey}`; @@ -35,7 +36,15 @@ export const removeDomain = (appName: string, uniqueKey: number) => { delete config.http.services[serviceKey]; } - writeTraefikConfig(config, appName); + // verify if is the last router if so we delete the router + if ( + config?.http?.routers && + Object.keys(config?.http?.routers).length === 0 + ) { + await removeTraefikConfig(appName); + } else { + writeTraefikConfig(config, appName); + } }; export const createRouterConfig = async (