Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
akmatoff committed Nov 5, 2024
1 parent 1b47f86 commit 2b44185
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
45 changes: 36 additions & 9 deletions Dockerfile
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"]
5 changes: 0 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,4 @@ export default defineConfig({
"@": path.resolve(__dirname, "/src"),
},
},
build: {
rollupOptions: {
external: ["highlight.js/lib/languages/python", "highlight.js/scss/atom-one-dark.scss"]
}
}
});

0 comments on commit 2b44185

Please sign in to comment.