Add GitHub Actions workflow and Dockerfile for Docker image deployment

This commit is contained in:
Mauricio Siu 2025-03-01 02:43:35 -06:00
parent 4d20a9a25e
commit 0f94dde28c
2 changed files with 65 additions and 0 deletions

29
.github/workflows/deploy.yml vendored Normal file
View File

@ -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

36
app/Dockerfile Normal file
View File

@ -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