-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
67 lines (43 loc) · 1.22 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
62
FROM node:22-alpine3.18 as build-stage
WORKDIR /app
RUN apk add --no-cache libc6-compat
# Copy package.json and package-lock.json
COPY --chown=node:node package*.json ./
# Install dependencies
RUN npm install
# Set to production environment
ENV NODE_ENV production
# Set API URL
ARG API_URL
ENV VITE_API_URL=${API_URL}
ARG CLOUDINARY_NAME
ENV VITE_CLOUDINARY_NAME=${CLOUDINARY_NAME}
# Set the timezone
ENV TZ=Europe/Paris
# Copy source code
COPY --chown=node:node . .
# Generate the production build
RUN ["npm","run","build"]
# # Remove the dev dependencies
# RUN npm prune --production && npm cache clean --force
RUN npm i --only=production && npm cache clean --force
USER node
# Path: Dockerfile
FROM node:22-alpine3.18 as production-stage
WORKDIR /app
# Set to production environment
ENV NODE_ENV production
# Set the Timezone
ENV TZ=Europe/Paris
# Copy the build from the build-stage
COPY --from=build-stage /app/dist ./dist
COPY --from=build-stage /app/node_modules ./node_modules
COPY --from=build-stage /app/package.json ./package.json
# Install serve package globally
RUN npm install -g serve
# Expose the port
ENV PORT = 5000
EXPOSE 5000
USER node
# Start the application
CMD ["serve", "-s", "dist", "-l", "5000"]