|
1 |
| -FROM ubuntu:20.04 |
| 1 | +# Use current Ubuntu LTS as the base image |
| 2 | +FROM ubuntu:latest |
2 | 3 |
|
3 |
| -ARG DEBIAN_FRONTEND=noninteractive |
4 |
| -ENV TZ=US/Eastern |
| 4 | +# Update apt-get and install essential tools like curl, gpg, git, nginx, and supervisor |
| 5 | +RUN apt-get update && \ |
| 6 | + apt-get install -y curl gpg git nginx supervisor |
5 | 7 |
|
6 |
| -RUN apt-get update |
7 |
| -RUN apt-get upgrade -y |
| 8 | +# Set Node.js major version for installation |
| 9 | +ENV NODE_MAJOR=20 |
8 | 10 |
|
9 |
| -RUN apt-get install sudo curl git nodejs npm jq apache2 wget apt-utils -y |
| 11 | +# Add the NodeSource GPG key and repository for Node.js |
| 12 | +RUN mkdir -p /etc/apt/keyrings && \ |
| 13 | + curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ |
| 14 | + echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \ |
| 15 | + apt-get update && apt-get install -y nodejs |
10 | 16 |
|
11 |
| -RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - |
12 |
| - |
13 |
| -RUN git clone --branch fix_module https://github.com/nerosketch/quakejs.git |
| 17 | +# Set the working directory for the QuakeJS server |
14 | 18 | WORKDIR /quakejs
|
15 |
| -RUN npm install |
16 |
| -RUN ls |
17 |
| -COPY server.cfg /quakejs/base/baseq3/server.cfg |
18 |
| -COPY server.cfg /quakejs/base/cpma/server.cfg |
19 |
| -# The two following lines are not necessary because we copy assets from include. Leaving them here for continuity. |
20 |
| -# WORKDIR /var/www/html |
21 |
| -# RUN bash /var/www/html/get_assets.sh |
| 19 | + |
| 20 | +# Clone the QuakeJS server repository and install dependencies |
| 21 | +RUN git clone https://github.com/begleysm/quakejs . && \ |
| 22 | + npm install |
| 23 | + |
| 24 | +# Copy server configuration files |
| 25 | +COPY server.cfg /quakejs/base/baseq3/ |
| 26 | +COPY server.cfg /quakejs/base/cpma/ |
| 27 | + |
| 28 | +# Replace the fixed JavaScript file for ioq3ded |
22 | 29 | COPY ./include/ioq3ded/ioq3ded.fixed.js /quakejs/build/ioq3ded.js
|
23 | 30 |
|
24 |
| -RUN rm /var/www/html/index.html && cp /quakejs/html/* /var/www/html/ |
| 31 | +# Modify the QuakeJS HTML to dynamically set the hostname and protocol for resources |
| 32 | +RUN sed -i "s#'quakejs:[0-9]\+'#window.location.hostname#g" /quakejs/html/index.html && \ |
| 33 | + sed -i "s#var url = 'http://' + fs_cdn + '/assets/manifest.json';#var url = '//' + window.location.host + '/assets/manifest.json';#" /quakejs/html/ioquake3.js && \ |
| 34 | + sed -i "s#var url = 'http://' + root + '/assets/' + name;#var url = '//' + window.location.host + '/assets/' + name;#" /quakejs/html/ioquake3.js && \ |
| 35 | + sed -i "s#var url = 'ws://' + addr + ':' + port;#var url = window.location.protocol.replace('http', 'ws') + window.location.host;#" /quakejs/html/ioquake3.js |
| 36 | + |
| 37 | +# Link QuakeJS to the nginx web root |
| 38 | +RUN rm -rf /var/www/html && ln -s /quakejs/html /var/www/html |
| 39 | + |
| 40 | +# Copy game assets to the web root |
25 | 41 | COPY ./include/assets/ /var/www/html/assets
|
26 |
| -RUN ls /var/www/html |
27 | 42 |
|
28 |
| -WORKDIR / |
29 |
| -ADD entrypoint.sh /entrypoint.sh |
30 |
| -# Was having issues with Linux and Windows compatibility with chmod -x, but this seems to work in both |
31 |
| -RUN chmod 777 ./entrypoint.sh |
| 43 | +# Remove unnecessary packages to reduce image size |
| 44 | +RUN apt-get purge curl gpg git -y && \ |
| 45 | + apt-get autoremove -y && \ |
| 46 | + apt-get clean && \ |
| 47 | + rm -rf /var/lib/apt/lists/* |
| 48 | + |
| 49 | +# Configure supervisord and nginx |
| 50 | +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf |
| 51 | +COPY nginx.conf /etc/nginx/sites-available/default |
| 52 | + |
| 53 | +# Create a non-root user for running the QuakeJS server |
| 54 | +RUN groupadd -r quakejs && useradd -r -g quakejs quakejs |
| 55 | + |
| 56 | +# Set permissions for the QuakeJS server and web root |
| 57 | +RUN chown -R quakejs:quakejs /quakejs /var/www/html |
32 | 58 |
|
33 |
| -ENTRYPOINT ["/entrypoint.sh"] |
| 59 | +# Start the supervisor daemon |
| 60 | +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |
0 commit comments