merasabkuch commited on
Commit
dff49b1
·
verified ·
1 Parent(s): 14e521c

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:alpine
2
+
3
+ # Create a user and group with a specific UID and GID
4
+ # RUN useradd -m -u 1001 user
5
+ # install git
6
+ RUN apk add --no-cache git
7
+
8
+ # Switch to the newly created user
9
+ USER node
10
+
11
+ # Set environment variables for the user
12
+ ENV HOME=/home/node \
13
+ PATH=/home/node/.local/bin:$PATH
14
+
15
+ # Set the working directory
16
+ WORKDIR $HOME/app
17
+
18
+ # Copy the package.json and package-lock.json files to the working directory
19
+ COPY --chown=node:node package*.json ./
20
+
21
+ # Install Node.js dependencies
22
+ RUN npm install
23
+
24
+ # Copy the application code to the working directory
25
+ COPY --chown=node:node . .
26
+
27
+ # Set the ownership of the directory to the user
28
+ RUN chown -R node:node .
29
+
30
+ # Expose the port the app runs on
31
+ # Command to run the Node.js server
32
+ CMD ["node", "index.js"]