diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..84947284 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,29 @@ +name: Build Docker image + +on: + push: + branches: ["canary", "main", "feat/monitoring"] + +jobs: + build-and-push-templates-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 and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./app/Dockerfile + push: true + tags: | + dokploy/templates:latest + platforms: linux/amd64 diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 00000000..9ffe2603 --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,36 @@ +FROM node:20.9-slim 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 + +RUN apt-get update && rm -rf /var/lib/apt/lists/* + +# 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 build + +FROM base AS dokploy +WORKDIR /app + +# Set production +ENV NODE_ENV=production + +# Copy only the necessary files +COPY --from=build /usr/src/app/dist ./dist +COPY --from=build /usr/src/app/package.json ./package.json +COPY --from=build /usr/src/app/node_modules ./node_modules + +# Copy templates folder +COPY ../templates ./public/templates + +# Expose port +EXPOSE 3000 + +CMD HOSTNAME=0.0.0.0 && pnpm start \ No newline at end of file