-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-NODE21
40 lines (28 loc) · 1.27 KB
/
Dockerfile-NODE21
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
FROM hackinglab/ubuntu-base-hl:latest
LABEL maintainer="Ivan Buetler <[email protected]>"
# Basic Update
RUN apt-get update -y
RUN apt-get install sudo curl ca-certificates gnupg nginx apache2-utils openssl -y
# Download and import the NodeSource GPG key
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
# Set the desired Node.js version (change NODE_MAJOR as needed)
ENV NODE_MAJOR=21
# Create the NodeSource deb repository
RUN echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list
# Update and install Node.js
RUN apt-get update -y && apt-get install -y nodejs
ADD root /
# Create a system user for Node.js
RUN addgroup --system node && adduser --system --ingroup node node
# Set appropriate ownership and create a directory for Node.js
RUN chown -R www-data:www-data /var/lib/nginx
RUN mkdir -p /opt/nodejs && chown -R node:node /opt/nodejs
# Change to the Node.js directory and install npm packages
WORKDIR /opt/nodejs
RUN npm init -y
RUN npm install express
# Clean up the APT cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
#USER node
# Expose the ports for nginx
EXPOSE 3000