forked from ashutosh1919/masterPortfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
32 lines (22 loc) · 893 Bytes
/
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
# Use an official Node.js LTS runtime as a parent image, using the Alpine Linux version for smaller size
FROM node:lts-alpine
# Set the working directory in the container
WORKDIR /app
# Add `/app/node_modules/.bin` to $PATH for easier command execution
ENV PATH /app/node_modules/.bin:$PATH
# Copy package.json and package-lock.json to leverage Docker cache
COPY package.json package-lock.json ./
# Install dependencies in a silent mode to reduce log output
RUN npm install --silent
# Copy the rest of the application code
COPY . .
# Expose port 3001 to the outside world
EXPOSE 3001
# Create a non-root user to run the application securely
RUN adduser -D myuser
USER myuser
# Define the command to run the app
CMD ["npm", "start"]
# Health check to ensure the application is running
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD node healthcheck.js