fix: dockerfile
Some checks failed
/ build (push) Failing after 1m19s

This commit is contained in:
Trenten Vollmer 2024-11-22 23:17:50 -05:00
parent 59d7d862d5
commit 3cc8008163
2 changed files with 29 additions and 11 deletions

View file

@ -3,22 +3,38 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH" ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable RUN corepack enable
FROM base AS build FROM base AS base-build
COPY . /usr/src/app COPY . /usr/src/app
WORKDIR /usr/src/app WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run -r build
FROM base-build AS backend-build
RUN pnpm run build-backend
RUN pnpm deploy --filter=backend --prod /prod/backend RUN pnpm deploy --filter=backend --prod /prod/backend
FROM base-build AS frontend-build
RUN pnpm run build-frontend
RUN pnpm deploy --filter=frontend --prod /prod/frontend RUN pnpm deploy --filter=frontend --prod /prod/frontend
FROM base AS backend
COPY --from=build /prod/backend /usr/src/app
WORKDIR /usr/src/app
EXPOSE 3001
CMD ["pnpm", "start"]
FROM base AS frontend
COPY --from=build /prod/frontend /usr/src/app FROM node:22-slim AS backend
WORKDIR /usr/src/app WORKDIR /app
COPY --from=backend-build /prod/backend/package*.json ./
COPY --from=backend-build /prod/backend/dist ./dist
COPY --from=backend-build /prod/frontend/node_modules ./node_modules
COPY --from=backend-build /usr/src/app/keys ./keys
ENV NODE_ENV=production
EXPOSE 3001
CMD [ "node", "dist/main.js" ]
FROM node:22-slim AS frontend
WORKDIR /app
COPY --from=frontend-build /prod/frontend/package*.json ./
COPY --from=frontend-build /prod/frontend/.next ./.next
COPY --from=frontend-build /prod/frontend/public ./public
COPY --from=frontend-build /prod/frontend/node_modules ./node_modules
ENV NODE_ENV=production
EXPOSE 3000 EXPOSE 3000
CMD ["pnpm", "start"] CMD ["pnpm", "start"]

View file

@ -5,7 +5,9 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"dev": "pnpm run --parallel dev", "dev": "pnpm run --parallel dev",
"build": "pnpm run --parallel build" "build": "pnpm run --parallel build",
"build-frontend": "pnpm run --filter=frontend build",
"build-backend": "pnpm run --filter=backend build"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",