From 19e5d1bacc5f4f795ea645e8952125dc007dfb1e Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:13:48 -0600 Subject: [PATCH 01/11] refactor: add nixpacks toml --- apps/docs/nixpacks.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 apps/docs/nixpacks.toml diff --git a/apps/docs/nixpacks.toml b/apps/docs/nixpacks.toml new file mode 100644 index 000000000..6bc87e450 --- /dev/null +++ b/apps/docs/nixpacks.toml @@ -0,0 +1,11 @@ +[phases.setup] +nixPkgs = ["pnpm"] + +[phases.install] +cmds = ["pnpm install"] + +[phases.build] +cmds = ["pnpm run build"] + +[start] +cmd = "pnpm start" \ No newline at end of file From c43af85c7c476aa2936cf9418bfd1efbad619fe3 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:26:25 -0600 Subject: [PATCH 02/11] refactor: add deploy.yml --- .github/workflows/deploy.yml | 39 ++++++++++++++++++++++++++++++++++++ Dockerfile.docs | 33 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile.docs diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..24b7f5656 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Build and Publish Docker image + +on: + push: + branches: ["feat/docker-image-apps"] + pull_request: + branches: ["main"] + +env: + IMAGE_NAME: dokploy/website:latest + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # - name: Build Docker image + # run: docker build --platform linux/amd64 --tag dokploy/website:testing -f Dockerfile . + + # - name: Push Docker image + # run: docker push dokploy/website:latest + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.docs + push: true + tags: dokploy/docs:latest + platforms: linux/amd64 diff --git a/Dockerfile.docs b/Dockerfile.docs new file mode 100644 index 000000000..29afe5dc3 --- /dev/null +++ b/Dockerfile.docs @@ -0,0 +1,33 @@ +FROM node:18-alpine AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable + +FROM base AS build +COPY . /usr/src/app +WORKDIR /usr/src/app + + +# Install dependencies +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile + +# Deploy only the dokploy app + +ENV NODE_ENV=production +RUN pnpm --filter=./apps/docs run build +RUN pnpm --filter=./apps/docs --prod deploy /prod/docs + +RUN cp -R /usr/src/app/apps/docs/.next /prod/docs/.next + +FROM base AS dokploy +WORKDIR /app + +# Set production +ENV NODE_ENV=production + +# Copy only the necessary files +COPY --from=build /prod/docs/.next ./.next +COPY --from=build /prod/docs/node_modules ./node_modules + +EXPOSE 3000 +CMD [ "pnpm", "start" ] \ No newline at end of file From f9afca7ffdb8f1e83683d5b740a35126781b48c1 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:27:23 -0600 Subject: [PATCH 03/11] refactor: update branch --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 24b7f5656..ffdf991de 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Build and Publish Docker image on: push: - branches: ["feat/docker-image-apps"] + branches: ["feat/docker-images-apps"] pull_request: branches: ["main"] From eb42277c49107e133d13124d67fd046039281f31 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:31:26 -0600 Subject: [PATCH 04/11] refactor: add pnpm install filter --- Dockerfile.docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.docs b/Dockerfile.docs index 29afe5dc3..799c9dac7 100644 --- a/Dockerfile.docs +++ b/Dockerfile.docs @@ -9,7 +9,7 @@ WORKDIR /usr/src/app # Install dependencies -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --filter=./apps/docs --frozen-lockfile # Deploy only the dokploy app From 32ee2364c8d6d5b0799e686d01548737c0094c28 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:35:58 -0600 Subject: [PATCH 05/11] refactor: update dockerfile --- Dockerfile.docs | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.docs b/Dockerfile.docs index 799c9dac7..08f047d14 100644 --- a/Dockerfile.docs +++ b/Dockerfile.docs @@ -27,6 +27,7 @@ ENV NODE_ENV=production # Copy only the necessary files COPY --from=build /prod/docs/.next ./.next +COPY --from=build /prod/docs/package.json ./package.json COPY --from=build /prod/docs/node_modules ./node_modules EXPOSE 3000 From f0a409c777bc72692836d582563048133ca50d62 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:40:01 -0600 Subject: [PATCH 06/11] refactor: update --- Dockerfile.docs | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.docs b/Dockerfile.docs index 08f047d14..099cce9d3 100644 --- a/Dockerfile.docs +++ b/Dockerfile.docs @@ -27,6 +27,7 @@ ENV NODE_ENV=production # Copy only the necessary files COPY --from=build /prod/docs/.next ./.next +COPY --from=build /prod/docs/public ./public COPY --from=build /prod/docs/package.json ./package.json COPY --from=build /prod/docs/node_modules ./node_modules From e7051d2bd1ee8aec0bf5f418a2ca796696d6ba4c Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:41:06 -0600 Subject: [PATCH 07/11] refactor: update dockerfile --- .github/workflows/deploy.yml | 30 +++++++++++++++++++++++------- Dockerfile.website | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 Dockerfile.website diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ffdf991de..67a6c8664 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ env: IMAGE_NAME: dokploy/website:latest jobs: - build-and-push-image: + build-and-push-image-docs: runs-on: ubuntu-latest steps: @@ -23,12 +23,6 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - # - name: Build Docker image - # run: docker build --platform linux/amd64 --tag dokploy/website:testing -f Dockerfile . - - # - name: Push Docker image - # run: docker push dokploy/website:latest - - name: Build and push Docker image uses: docker/build-push-action@v4 with: @@ -37,3 +31,25 @@ jobs: push: true tags: dokploy/docs:latest platforms: linux/amd64 + + build-and-push-image-website: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.website + push: true + tags: dokploy/website:latest + platforms: linux/amd64 diff --git a/Dockerfile.website b/Dockerfile.website new file mode 100644 index 000000000..d8f50fb22 --- /dev/null +++ b/Dockerfile.website @@ -0,0 +1,35 @@ +FROM node:18-alpine AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable + +FROM base AS build +COPY . /usr/src/app +WORKDIR /usr/src/app + + +# Install dependencies +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --filter=./apps/website --frozen-lockfile + +# Deploy only the dokploy app + +ENV NODE_ENV=production +RUN pnpm --filter=./apps/website run build +RUN pnpm --filter=./apps/website --prod deploy /prod/website + +RUN cp -R /usr/src/app/apps/website/.next /prod/website/.next + +FROM base AS dokploy +WORKDIR /app + +# Set production +ENV NODE_ENV=production + +# Copy only the necessary files +COPY --from=build /prod/website/.next ./.next +COPY --from=build /prod/website/public ./public +COPY --from=build /prod/website/package.json ./package.json +COPY --from=build /prod/website/node_modules ./node_modules + +EXPOSE 3000 +CMD [ "pnpm", "start" ] \ No newline at end of file From 7547f5ec27d4fcf16b4813a4d63163e24ca96792 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:58:41 -0600 Subject: [PATCH 08/11] refactor: add deploy --- .github/workflows/deploy.yml | 4 ++-- apps/docs/nixpacks.toml | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 apps/docs/nixpacks.toml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 67a6c8664..4179d2554 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,7 +4,7 @@ on: push: branches: ["feat/docker-images-apps"] pull_request: - branches: ["main"] + branches: ["canary", "main"] env: IMAGE_NAME: dokploy/website:latest @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Log in to Docker Hub uses: docker/login-action@v2 diff --git a/apps/docs/nixpacks.toml b/apps/docs/nixpacks.toml deleted file mode 100644 index 6bc87e450..000000000 --- a/apps/docs/nixpacks.toml +++ /dev/null @@ -1,11 +0,0 @@ -[phases.setup] -nixPkgs = ["pnpm"] - -[phases.install] -cmds = ["pnpm install"] - -[phases.build] -cmds = ["pnpm run build"] - -[start] -cmd = "pnpm start" \ No newline at end of file From 679c3238e24a3b8eea399fc94d1c475d4f4c7f89 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:04:10 -0600 Subject: [PATCH 09/11] refactor: update dockerfile --- .github/workflows/deploy.yml | 7 +------ Dockerfile.docs | 2 +- Dockerfile.website | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4179d2554..2051680b4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,14 +1,9 @@ -name: Build and Publish Docker image +name: Build Docs & Website Docker images on: push: - branches: ["feat/docker-images-apps"] - pull_request: branches: ["canary", "main"] -env: - IMAGE_NAME: dokploy/website:latest - jobs: build-and-push-image-docs: runs-on: ubuntu-latest diff --git a/Dockerfile.docs b/Dockerfile.docs index 099cce9d3..71b790ec3 100644 --- a/Dockerfile.docs +++ b/Dockerfile.docs @@ -32,4 +32,4 @@ COPY --from=build /prod/docs/package.json ./package.json COPY --from=build /prod/docs/node_modules ./node_modules EXPOSE 3000 -CMD [ "pnpm", "start" ] \ No newline at end of file +CMD HOSTNAME=0.0.0.0 && pnpm start \ No newline at end of file diff --git a/Dockerfile.website b/Dockerfile.website index d8f50fb22..9932f5271 100644 --- a/Dockerfile.website +++ b/Dockerfile.website @@ -32,4 +32,4 @@ COPY --from=build /prod/website/package.json ./package.json COPY --from=build /prod/website/node_modules ./node_modules EXPOSE 3000 -CMD [ "pnpm", "start" ] \ No newline at end of file +CMD HOSTNAME=0.0.0.0 && pnpm start \ No newline at end of file From 5888494fcc6596013fa810f0d7d49a6b016b3edf Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:05:14 -0600 Subject: [PATCH 10/11] refactor: update push branches --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2051680b4..39a80d1fc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Build Docs & Website Docker images on: push: - branches: ["canary", "main"] + branches: ["canary", "main", "feat/docker-images-apps"] jobs: build-and-push-image-docs: From b45c2d35384e49413087b306c992ce62566096fc Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:09:14 -0600 Subject: [PATCH 11/11] refactor: remove branch --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 39a80d1fc..2051680b4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Build Docs & Website Docker images on: push: - branches: ["canary", "main", "feat/docker-images-apps"] + branches: ["canary", "main"] jobs: build-and-push-image-docs: