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] 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 00000000..24b7f565 --- /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 00000000..29afe5dc --- /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