diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ffdf991d..67a6c866 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 00000000..d8f50fb2 --- /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