diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..9d08a1a828 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/Dockerfile b/Dockerfile index 881d48cfe6..c527411457 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,51 +1,80 @@ -# Sharelatex Community Edition (sharelatex/sharelatex) +# --------------------------------------------- +# Overleaf Community Edition (overleaf/overleaf) +# --------------------------------------------- FROM sharelatex/sharelatex-base:latest ENV baseDir . -# Install sharelatex settings file + +# Install app settings files +# -------------------------- ADD ${baseDir}/settings.coffee /etc/sharelatex/settings.coffee ENV SHARELATEX_CONFIG /etc/sharelatex/settings.coffee -ADD ${baseDir}/runit /etc/service -RUN rm /etc/nginx/sites-enabled/default -ADD ${baseDir}/nginx/nginx.conf /etc/nginx/nginx.conf -ADD ${baseDir}/nginx/sharelatex.conf /etc/nginx/sites-enabled/sharelatex.conf +# Checkout Overleaf Community Edition repo +# ---------------------------------------- +RUN git clone https://github.com/overleaf/overleaf.git \ + --depth 1 /var/www/sharelatex -ADD ${baseDir}/logrotate/sharelatex /etc/logrotate.d/sharelatex -COPY ${baseDir}/init_scripts/ /etc/my_init.d/ - -# Install ShareLaTeX -RUN git clone https://github.com/sharelatex/sharelatex.git /var/www/sharelatex - -ADD ${baseDir}/services.js /var/www/sharelatex/config/services.js +# Install dependencies needed to run configuration scripts +# -------------------------------------------------------- ADD ${baseDir}/package.json /var/www/package.json ADD ${baseDir}/git-revision.js /var/www/git-revision.js RUN cd /var/www && npm install -RUN cd /var/www/sharelatex; \ - npm install; \ - grunt install; \ - bash -c 'source ./bin/install-services'; \ - cd web; \ - npm install; \ - npm install bcrypt; \ - cd modules; \ - git clone https://github.com/sharelatex/launchpad-web-module.git launchpad; \ - grunt compile; +# Replace overleaf/config/services.js with the list of available +# services in Overleaf Community Edition +# -------------------------------------------------------------- +ADD ${baseDir}/services.js /var/www/sharelatex/config/services.js + + +# Checkout services +# ----------------- +RUN cd /var/www/sharelatex && \ + npm install && grunt install; + + +# install and compile services +# ---------------------------- +RUN bash -c 'cd /var/www/sharelatex && source ./bin/install-services' +RUN bash -c 'cd /var/www/sharelatex && source ./bin/compile-services' + + +# Change application ownership to www-data +# ---------------------------------------- +RUN chown -R www-data:www-data /var/www/sharelatex; + + +# Copy runit service startup scripts to its location +# -------------------------------------------------- +ADD ${baseDir}/runit /etc/service + + +# Configure nginx +# --------------- +RUN rm /etc/nginx/sites-enabled/default +ADD ${baseDir}/nginx/nginx.conf /etc/nginx/nginx.conf +ADD ${baseDir}/nginx/sharelatex.conf /etc/nginx/sites-enabled/sharelatex.conf + + +# Configure log rotation +# ---------------------- +ADD ${baseDir}/logrotate/sharelatex /etc/logrotate.d/sharelatex + + +# Copy Phusion Image startup scripts to its location +# -------------------------------------------------- +COPY ${baseDir}/init_scripts/ /etc/my_init.d/ + + +# Stores the version installed for each service +# --------------------------------------------- RUN cd /var/www && node git-revision > revisions.txt - -# Minify js assets -RUN cd /var/www/sharelatex/web; \ - grunt compile:minify; -RUN cd /var/www/sharelatex/clsi; \ - grunt compile:bin; \ - chown -R www-data:www-data /var/www/sharelatex; EXPOSE 80 diff --git a/Dockerfile-base b/Dockerfile-base index a59431fc9d..aed92b21b8 100644 --- a/Dockerfile-base +++ b/Dockerfile-base @@ -1,41 +1,62 @@ +# -------------------------------------------------- # Sharelatex Base Image (sharelatex/sharelatex-base) +# -------------------------------------------------- -FROM phusion/baseimage:0.9.16 +FROM phusion/baseimage:0.11 ENV baseDir . -RUN apt-get update -RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo bash - -RUN apt-get install -y build-essential wget nodejs unzip time imagemagick optipng strace nginx git python zlib1g-dev libpcre3-dev aspell aspell-en aspell-af aspell-am aspell-ar aspell-ar-large aspell-bg aspell-bn aspell-br aspell-ca aspell-cs aspell-cy aspell-da aspell-de aspell-de-alt aspell-el aspell-eo aspell-es aspell-et aspell-eu-es aspell-fa aspell-fo aspell-fr aspell-ga aspell-gl-minimos aspell-gu aspell-he aspell-hi aspell-hr aspell-hsb aspell-hu aspell-hy aspell-id aspell-is aspell-it aspell-kk aspell-kn aspell-ku aspell-lt aspell-lv aspell-ml aspell-mr aspell-nl aspell-no aspell-nr aspell-ns aspell-or aspell-pa aspell-pl aspell-pt-br aspell-ro aspell-ru aspell-sk aspell-sl aspell-ss aspell-st aspell-sv aspell-ta aspell-te aspell-tl aspell-tn aspell-ts aspell-uk aspell-uz aspell-xh aspell-zu +# Install dependencies +# -------------------- +RUN apt-get update +RUN apt-get install -y sudo +RUN apt-get install -y build-essential wget net-tools unzip time imagemagick optipng strace nginx git python zlib1g-dev libpcre3-dev aspell aspell-en aspell-af aspell-am aspell-ar aspell-ar-large aspell-bg aspell-bn aspell-br aspell-ca aspell-cs aspell-cy aspell-da aspell-de aspell-el aspell-eo aspell-es aspell-et aspell-eu-es aspell-fa aspell-fo aspell-fr aspell-ga aspell-gl-minimos aspell-gu aspell-he aspell-hi aspell-hr aspell-hsb aspell-hu aspell-hy aspell-id aspell-is aspell-it aspell-kk aspell-kn aspell-ku aspell-lt aspell-lv aspell-ml aspell-mr aspell-nl aspell-nr aspell-ns aspell-pa aspell-pl aspell-pt aspell-pt-br aspell-ro aspell-ru aspell-sk aspell-sl aspell-ss aspell-st aspell-sv aspell-tl aspell-tn aspell-ts aspell-uk aspell-uz aspell-xh aspell-zu + + +# Install qpdf +# ------------ WORKDIR /opt RUN wget https://s3.amazonaws.com/sharelatex-random-files/qpdf-6.0.0.tar.gz && tar xzf qpdf-6.0.0.tar.gz WORKDIR /opt/qpdf-6.0.0 RUN ./configure && make && make install && ldconfig + +# Install Node +# ------------ +RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - +RUN apt-get install -y nodejs +RUN npm install -g grunt-cli + + +# Install Node6 (required by some services) +# ----------------------------------------- +RUN wget https://nodejs.org/dist/v6.17.1/node-v6.17.1-linux-x64.tar.gz && \ + mkdir -p /opt/nodejs && tar -xzf node-v6.17.1-linux-x64.tar.gz -C /opt/nodejs/ && \ + cd /opt/nodejs && mv node-v6.17.1-linux-x64 6.17.1 && \ + ln -s /opt/nodejs/6.17.1/bin/node /usr/bin/node6 + + # Install TexLive -RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz; \ - mkdir /install-tl-unx; \ +# --------------- +RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \ + mkdir /install-tl-unx && \ tar -xvf install-tl-unx.tar.gz -C /install-tl-unx --strip-components=1 - -RUN echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile; \ - /install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile - +RUN echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile && \ + /install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile RUN rm -r /install-tl-unx; \ rm install-tl-unx.tar.gz - -ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/2017/bin/x86_64-linux/ +ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/2019/bin/x86_64-linux/ RUN tlmgr install latexmk RUN tlmgr install texcount -RUN npm install -g grunt-cli # Set up sharelatex user and home directory -RUN adduser --system --group --home /var/www/sharelatex --no-create-home sharelatex; \ - mkdir -p /var/lib/sharelatex; \ - chown www-data:www-data /var/lib/sharelatex; \ - mkdir -p /var/log/sharelatex; \ - chown www-data:www-data /var/log/sharelatex; \ - mkdir -p /var/lib/sharelatex/data/template_files; \ - chown www-data:www-data /var/lib/sharelatex/data/template_files; - +# ----------------------------------------- +RUN adduser --system --group --home /var/www/sharelatex --no-create-home sharelatex && \ + mkdir -p /var/lib/sharelatex && \ + chown www-data:www-data /var/lib/sharelatex && \ + mkdir -p /var/log/sharelatex && \ + chown www-data:www-data /var/log/sharelatex && \ + mkdir -p /var/lib/sharelatex/data/template_files && \ + chown www-data:www-data /var/lib/sharelatex/data/template_files diff --git a/runit/real-time-sharelatex/run b/runit/real-time-sharelatex/run index c57d1d489e..7168368c38 100755 --- a/runit/real-time-sharelatex/run +++ b/runit/real-time-sharelatex/run @@ -1,3 +1,3 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/real-time/app.js >> /var/log/sharelatex/real-time.log 2>&1 \ No newline at end of file +exec /sbin/setuser www-data /usr/bin/node6 /var/www/sharelatex/real-time/app.js >> /var/log/sharelatex/real-time.log 2>&1 \ No newline at end of file diff --git a/settings.coffee b/settings.coffee index 7f4f18067f..92a545eac7 100644 --- a/settings.coffee +++ b/settings.coffee @@ -22,6 +22,8 @@ TMP_DIR = '/var/lib/sharelatex/tmp' settings = + brandPrefix: "" + allowAnonymousReadAndWriteSharing: process.env['SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING'] == 'true' @@ -169,7 +171,7 @@ settings = # Should javascript assets be served minified or not. Note that you will # need to run `grunt compile:minify` within the web-sharelatex directory # to generate these. - useMinifiedJs: true + useMinifiedJs: false # Should static assets be sent with a header to tell the browser to cache # them. This should be false in development where changes are being made,