-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,59 @@ | ||
# Base | ||
|
||
# Base Image | ||
FROM node:20.18.0-slim AS base | ||
|
||
# Enable Corepack and Prepare PNPM | ||
RUN corepack enable | ||
RUN corepack prepare pnpm@9.12.1 --activate | ||
|
||
# Set the working directory | ||
WORKDIR /backoffice | ||
|
||
# Set environment variables | ||
ARG VITE_BASE_URL | ||
|
||
ENV VITE_BASE_URL=${VITE_BASE_URL} | ||
|
||
# Copy dependency files | ||
COPY package.json .npmrc pnpm-lock.yaml /backoffice/ | ||
|
||
# Install dependencies (only for development) | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Copy the entire project into the container | ||
COPY . . | ||
|
||
# Production | ||
|
||
FROM base AS production | ||
# Build Stage | ||
FROM base AS build | ||
|
||
# Set environment to production | ||
ENV NODE_ENV=production | ||
|
||
RUN npm install -g serve | ||
# Install only production dependencies | ||
RUN pnpm install --frozen-lockfile --prod | ||
|
||
# Build the application | ||
RUN pnpm run build | ||
|
||
# Production Image | ||
FROM node:20.18.0-slim AS production | ||
|
||
# Enable Corepack and Prepare PNPM | ||
RUN corepack enable | ||
RUN corepack prepare pnpm@9.12.1 --activate | ||
|
||
# Set the working directory | ||
WORKDIR /backoffice | ||
|
||
# Copy the build output from the previous stage | ||
COPY --from=build /backoffice/dist /backoffice/dist | ||
|
||
# Copy necessary files for serving the app | ||
COPY --from=build /backoffice/package.json /backoffice/pnpm-lock.yaml /backoffice/.npmrc /backoffice/ | ||
|
||
RUN npm run build | ||
# Install Serve globally | ||
RUN pnpm install -g serve | ||
|
||
# Expose the port the app will run on | ||
EXPOSE 4000 | ||
|
||
CMD ["serve", "-s", "dist", "-p", "4000"] | ||
# Command to run the app | ||
CMD ["serve", "-s", "dist", "-p", "4000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters