Skip to content

Commit 0f94dde

Browse files
committed
Add GitHub Actions workflow and Dockerfile for Docker image deployment
1 parent 4d20a9a commit 0f94dde

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build Docker image
2+
3+
on:
4+
push:
5+
branches: ["canary", "main", "feat/monitoring"]
6+
7+
jobs:
8+
build-and-push-templates-image:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
15+
- name: Log in to Docker Hub
16+
uses: docker/login-action@v2
17+
with:
18+
username: ${{ secrets.DOCKERHUB_USERNAME }}
19+
password: ${{ secrets.DOCKERHUB_TOKEN }}
20+
21+
- name: Build and push Docker image
22+
uses: docker/build-push-action@v4
23+
with:
24+
context: .
25+
file: ./app/Dockerfile
26+
push: true
27+
tags: |
28+
dokploy/templates:latest
29+
platforms: linux/amd64

app/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM node:20.9-slim AS base
2+
ENV PNPM_HOME="/pnpm"
3+
ENV PATH="$PNPM_HOME:$PATH"
4+
RUN corepack enable
5+
6+
FROM base AS build
7+
COPY . /usr/src/app
8+
WORKDIR /usr/src/app
9+
10+
RUN apt-get update && rm -rf /var/lib/apt/lists/*
11+
12+
# Install dependencies
13+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
14+
15+
# Deploy only the dokploy app
16+
ENV NODE_ENV=production
17+
RUN pnpm build
18+
19+
FROM base AS dokploy
20+
WORKDIR /app
21+
22+
# Set production
23+
ENV NODE_ENV=production
24+
25+
# Copy only the necessary files
26+
COPY --from=build /usr/src/app/dist ./dist
27+
COPY --from=build /usr/src/app/package.json ./package.json
28+
COPY --from=build /usr/src/app/node_modules ./node_modules
29+
30+
# Copy templates folder
31+
COPY ../templates ./public/templates
32+
33+
# Expose port
34+
EXPOSE 3000
35+
36+
CMD HOSTNAME=0.0.0.0 && pnpm start

0 commit comments

Comments
 (0)