-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
61 lines (43 loc) · 1.32 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Base Image
FROM node:20.18.0-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# 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 . .
# Build Stage
FROM base AS build
# Set environment to production
ENV NODE_ENV=production
# Build the application
RUN pnpm run build
# Production Image
FROM node:20.18.0-slim AS production
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# 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/
# Install Serve globally
RUN pnpm install -g serve
# Expose the port the app will run on
EXPOSE 4000
# Command to run the app
CMD ["serve", "-s", "dist", "-p", "4000"]