GameServerZ / Dockerfile
clone3's picture
Update Dockerfile
09dceae verified
raw
history blame
1.43 kB
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