refactor: update dockerfile

This commit is contained in:
Mauricio Siu
2024-08-01 00:41:06 -06:00
parent f0a409c777
commit e7051d2bd1
2 changed files with 58 additions and 7 deletions

View File

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

35
Dockerfile.website Normal file
View File

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