-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (22 loc) · 690 Bytes
/
Copy pathDockerfile
File metadata and controls
32 lines (22 loc) · 690 Bytes
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
FROM node:20-alpine
# Update Alpine packages to reduce vulnerabilities
RUN apk update && apk upgrade
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (if available)
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Define environment variable
ENV NODE_ENV=production
# Install dotenv for environment variable support
RUN npm install dotenv
# Use build arg for PORT with default value
ARG PORT=8000
ENV PORT=${PORT}
# Expose the port dynamically
EXPOSE ${PORT}
# Command to run the application with dotenv support
CMD ["node", "-r", "dotenv/config", "src/app.js"]