refactor: add deploy.yml

This commit is contained in:
Mauricio Siu
2024-08-01 00:26:25 -06:00
parent 19e5d1bacc
commit c43af85c7c
2 changed files with 72 additions and 0 deletions

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

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

33
Dockerfile.docs Normal file
View File

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