-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (36 loc) · 1.13 KB
/
Copy pathDockerfile
File metadata and controls
52 lines (36 loc) · 1.13 KB
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
ARG NODE_VERSION=24.15.0
# Create build stage
FROM node:${NODE_VERSION}-alpine AS base
# Define environment variables
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
# Set the working directory inside the container.
WORKDIR /app
# Create build stage.
FROM base AS build
ARG APP_VERSION=dev
ARG APP_RELEASE_DATE=
ENV APP_VERSION=${APP_VERSION}
ENV APP_RELEASE_DATE=${APP_RELEASE_DATE}
# Copy package.json and package-lock.json files to the working directory.
COPY ./package.json .
COPY ./package-lock.json .
# Install all dependencies (including dev) for the build, despite NODE_ENV=production.
RUN npm ci --include=dev
# Copy the rest of the application files to the working directory.
COPY . .
# Build the application.
RUN npm run build
# Create a new stage for the production image.
FROM base
# Define environment variables.
ARG PORT=3000
ENV PORT=${PORT}
ARG HOSTNAME=0.0.0.0
ENV HOSTNAME=${HOSTNAME}
# Copy the output from the build stage to the working directory.
COPY --from=build /app/.output /app/.output
# Expose the port the application will run on.
EXPOSE 3000
# Start the application
CMD ["node", ".output/server/index.mjs"]