clone3 commited on
Commit
c222ce3
·
verified ·
1 Parent(s): 5000aa7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -11
Dockerfile CHANGED
@@ -2,18 +2,22 @@ FROM nikolaik/python-nodejs:python3.9-nodejs18
2
 
3
  USER root
4
 
 
5
  RUN apt-get -y update && apt-get -y install nginx xvfb openssh-server
6
 
 
7
  RUN mkdir -p /var/cache/nginx \
8
  /var/log/nginx \
9
  /var/lib/nginx
10
  RUN touch /var/run/nginx.pid
11
 
 
12
  RUN chown -R pn:pn /var/cache/nginx \
13
  /var/log/nginx \
14
  /var/lib/nginx \
15
  /var/run/nginx.pid
16
 
 
17
  USER pn
18
  ENV HOME=/home/pn \
19
  PATH=/home/pn/.local/bin:$PATH
@@ -22,21 +26,31 @@ RUN mkdir $HOME/app
22
 
23
  WORKDIR $HOME/app
24
 
 
25
  RUN npm install --save express ws
26
 
 
27
  COPY --chown=pn nginx.conf /etc/nginx/sites-available/default
28
 
29
- # Create the .ssh directory if it does not exist
30
- RUN mkdir -p /home/pn/.ssh
31
-
32
- # Generate SSH key pair non-interactively
33
- RUN ssh-keygen -t rsa -b 4096 -f /home/pn/.ssh/id_rsa -N ""
34
-
35
- # Optionally, set permissions for the .ssh directory and keys
36
- RUN chmod 700 /home/pn/.ssh && \
37
  chmod 600 /home/pn/.ssh/id_rsa && \
38
  chmod 644 /home/pn/.ssh/id_rsa.pub
39
-
40
- COPY --chown=pn . .
41
 
42
- CMD ["bash", "run.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  USER root
4
 
5
+ # Install necessary packages
6
  RUN apt-get -y update && apt-get -y install nginx xvfb openssh-server
7
 
8
+ # Prepare Nginx directories
9
  RUN mkdir -p /var/cache/nginx \
10
  /var/log/nginx \
11
  /var/lib/nginx
12
  RUN touch /var/run/nginx.pid
13
 
14
+ # Change ownership to non-root user
15
  RUN chown -R pn:pn /var/cache/nginx \
16
  /var/log/nginx \
17
  /var/lib/nginx \
18
  /var/run/nginx.pid
19
 
20
+ # Switch to non-root user
21
  USER pn
22
  ENV HOME=/home/pn \
23
  PATH=/home/pn/.local/bin:$PATH
 
26
 
27
  WORKDIR $HOME/app
28
 
29
+ # Install necessary npm packages
30
  RUN npm install --save express ws
31
 
32
+ # Copy Nginx configuration
33
  COPY --chown=pn nginx.conf /etc/nginx/sites-available/default
34
 
35
+ # SSH Setup
36
+ # Create the .ssh directory and generate SSH key pair non-interactively
37
+ RUN mkdir -p /home/pn/.ssh && \
38
+ ssh-keygen -t rsa -b 4096 -f /home/pn/.ssh/id_rsa -N "" && \
39
+ chmod 700 /home/pn/.ssh && \
 
 
 
40
  chmod 600 /home/pn/.ssh/id_rsa && \
41
  chmod 644 /home/pn/.ssh/id_rsa.pub
 
 
42
 
43
+ # Expose SSH port (usually port 22)
44
+ EXPOSE 22
45
+
46
+ # Switch back to root for running SSH daemon and Nginx
47
+ USER root
48
+
49
+ # Start SSH manually using the correct relative path
50
+ RUN mkdir /var/run/sshd
51
+
52
+ # Expose Nginx port (default port 80)
53
+ EXPOSE 80
54
+
55
+ # Use the custom SSH daemon path
56
+ CMD ["../../../usr/sbin/sshd", "-D"] # Starts the SSH server using your relative path