Spaces:
Sleeping
Sleeping
File size: 1,418 Bytes
033cd7a 8c3b567 4d7f338 18c2ccd 8c3b567 4d7f338 8c3b567 4d7f338 8c3b567 4d7f338 8c3b567 4d7f338 b3bce7e 4d7f338 8c3b567 4d7f338 673e1ac a8bd84f 4d7f338 05ab8a8 4d7f338 caf9ce7 4d7f338 |
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
FROM nikolaik/python-nodejs:python3.9-nodejs18
USER root
# Install necessary packages
RUN apt-get -y update && apt-get -y install nginx xvfb openssh-server
# Prepare Nginx directories
RUN mkdir -p /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx
RUN touch /var/run/nginx.pid
# Change ownership to non-root user
RUN chown -R pn:pn /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx \
/var/run/nginx.pid
# Switch to non-root user
USER pn
ENV HOME=/home/pn \
PATH=/home/pn/.local/bin:$PATH
RUN mkdir $HOME/app
WORKDIR $HOME/app
# Install necessary npm packages
RUN npm install --save express ws
# Copy Nginx configuration
COPY --chown=pn nginx.conf /etc/nginx/sites-available/default
# SSH Setup
# Create the .ssh directory and generate SSH key pair non-interactively
RUN mkdir -p /home/pn/.ssh && \
ssh-keygen -t rsa -b 4096 -f /home/pn/.ssh/id_rsa -N "" && \
chmod 700 /home/pn/.ssh && \
chmod 600 /home/pn/.ssh/id_rsa && \
chmod 644 /home/pn/.ssh/id_rsa.pub
# Expose SSH port (usually port 22)
EXPOSE 22
# Switch back to root for running SSH daemon and Nginx
USER root
# Start SSH manually without systemctl
RUN mkdir /var/run/sshd
# Expose Nginx port (default port 80)
EXPOSE 80
# Ensure services start correctly
CMD ["/usr/sbin/sshd", "-D"] # Starts the SSH server in the foreground
|