diff --git a/.gitmodules b/.gitmodules index 390251a..396ce72 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "site"] path = site - url = https://github.com/DMOJ/site.git + url = https://github.com/DMOJ/site diff --git a/Dockerfile b/Dockerfile index 4729c48..5ac4378 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,50 +1,63 @@ -FROM debian:bookworm +FROM debian:buster -# Prerequisite packages +# Install required packages and remove apt cache when done. RUN apt-get update && apt-get install -y --no-install-recommends \ - git \ - gcc \ - g++ \ - make \ - python3-dev \ - python3-pip \ - libxml2-dev \ - libxslt1-dev \ - zlib1g-dev \ - gettext \ - curl \ - default-libmysqlclient-dev \ - default-mysql-client \ - pkg-config \ - redis-server \ - supervisor \ - nginx \ - && apt-get clean && rm -rf /var/bin/apt/lists/* + build-essential \ + ca-certificates \ + chrpath \ + curl \ + debconf-utils \ + default-libmysqlclient-dev \ + gcc g++ \ + gettext \ + git \ + gnupg \ + libfontconfig1 libfontconfig1-dev \ + libfreetype6 libfreetype6-dev \ + libssl-dev \ + libxft-dev \ + libxml2-dev \ + libxslt1-dev \ + make \ + default-mysql-client \ + nano \ + nginx \ + openssl \ + python3 python3-dev python3-setuptools python3-pip \ + supervisor \ + wget \ + zlib1g-dev \ +&& apt-get clean && rm -rf /var/bin/apt/lists/* + +# Bootstrap pip and setuptools +RUN pip3 install --no-cache-dir --no-cache-dir -U pip setuptools # Install uwsgi now because it takes a little while -RUN pip3 install --no-cache-dir --break-system-packages uwsgi +RUN pip3 install --no-cache-dir uwsgi -# Install nodejs and packages -RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - # TODO migrate -RUN apt-get install nodejs -RUN npm install -g --unsafe-perm=true sass postcss-cli postcss autoprefixer +# Get nodejs and install packages +RUN wget -O- https://deb.nodesource.com/setup_8.x | bash - +RUN apt-get install -y nodejs +RUN npm install -g --unsafe-perm=true phantomjs-prebuilt pleeease-cli sass -# Install site prerequisites +# Install app requirements before rest of code to be cache friendly COPY site/requirements.txt /site/ -RUN pip3 install --no-cache-dir --break-system-packages -r site/requirements.txt # TODO: don't break system packages -RUN pip3 install --no-cache-dir --break-system-packages mysqlclient +RUN pip3 install --no-cache-dir -r /site/requirements.txt # Copy app COPY site /site # Install utility so we can easily use docker secrets in local_settings.py -RUN pip3 install --no-cache-dir --break-system-packages get-docker-secret +RUN pip install --no-cache-dir get-docker-secret -# Django recaptcha support -RUN pip3 install --no-cache-dir --break-system-packages django-recaptcha2 django-recaptcha3 +# I don't know why these are here +RUN pip install --no-cache-dir mysqlclient +#RUN pip install --no-cache-dir "django_select2<7" -# Install python redis for celery -RUN pip3 install --no-cache-dir --break-system-packages redis +# Set up event server +RUN npm install qu ws simplesets +RUN pip install --no-cache-dir websocket-client +COPY websocket/config.js /site/websocket # Copy uwsgi config COPY uwsgi /uwsgi @@ -60,19 +73,18 @@ RUN mkdir -p /problems/pdfcache RUN mkdir -p /problems/problems # Install wait, as docker-entry depends on it -ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.12.0/wait /wait +ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.0/wait /wait RUN chmod +x /wait # Install docker-entry -COPY docker-entry /site/ -RUN chmod +x /site/docker-entry +COPY docker-entry /site -# Set workdir. Note: due to a change in Node 15, this must come before local npm install commands -WORKDIR /site - -# Set up event server -RUN npm install qu ws simplesets -RUN pip3 install --no-cache-dir --break-system-packages websocket-client -COPY websocket/config.js /site/websocket +EXPOSE 80 +EXPOSE 9999 +EXPOSE 9998 +EXPOSE 15100 +EXPOSE 15101 +EXPOSE 15102 +WORKDIR /site ENTRYPOINT ["/site/docker-entry"] diff --git a/README.md b/README.md index 9d8750a..10ec64a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ # dmoj-site-docker Dockerized setup for DMOJ site - diff --git a/docker-entry b/docker-entry index 1eca6a2..9238832 100755 --- a/docker-entry +++ b/docker-entry @@ -1,7 +1,7 @@ #!/usr/bin/env sh -./make_style.sh -python3 manage.py collectstatic --noinput +sh make_style.sh +echo yes | python3 manage.py collectstatic python3 manage.py compilemessages python3 manage.py compilejsi18n @@ -9,6 +9,4 @@ python3 manage.py compilejsi18n python3 manage.py migrate --noinput -service redis-server start - /usr/bin/supervisord -n diff --git a/nginx/default b/nginx/default index ade299e..d1dc435 100644 --- a/nginx/default +++ b/nginx/default @@ -49,8 +49,6 @@ server { root /problems/pdfcache; } - # TODO new block here, see https://github.com/DMOJ/docs/blob/master/sample_files/nginx.conf - # Uncomment these sections if you are using the event server. location /event/ { proxy_pass http://127.0.0.1:15100/; diff --git a/site b/site index 7a3db32..1c472c2 160000 --- a/site +++ b/site @@ -1 +1 @@ -Subproject commit 7a3db32305eb24b6a387ef5f7e7fb274864594b6 +Subproject commit 1c472c28317e3770149694fc4c0530aca8b154c5 diff --git a/supervisor/celery.conf b/supervisor/celery.conf deleted file mode 100644 index 2f9323c..0000000 --- a/supervisor/celery.conf +++ /dev/null @@ -1,8 +0,0 @@ -[program:celery] -# These should probably be a non-root user -user=root -group=root -command=celery -A dmoj_celery worker -directory=/site -stdout_logfile=/tmp/celery.stdout.log -stderr_logfile=/tmp/celery.stderr.log diff --git a/uwsgi/uwsgi.ini b/uwsgi/uwsgi.ini index d3f6bfc..192b1f2 100644 --- a/uwsgi/uwsgi.ini +++ b/uwsgi/uwsgi.ini @@ -10,12 +10,11 @@ gid = root # Paths. chdir = /site -#pythonpath = -#virtualenv = # Details regarding DMOJ application. protocol = uwsgi master = true +plugins = python env = DJANGO_SETTINGS_MODULE=dmoj.settings module = dmoj.wsgi:application optimize = 2 @@ -28,4 +27,4 @@ cheaper-initial = 5 cheaper-step = 1 cheaper-rss-limit-soft = 201326592 cheaper-rss-limit-hard = 234881024 -workers = 7 +workers = 5