overleaf-sso/Dockerfile

90 lines
4.7 KiB
Docker
Raw Normal View History

ARG BASE=sharelatex/sharelatex:3.1
2021-06-16 10:20:14 +00:00
ARG TEXLIVE_IMAGE=registry.gitlab.com/islandoftex/images/texlive:latest
FROM $TEXLIVE_IMAGE as texlive
FROM nixpkgs/curl as src
2022-06-10 13:20:16 +00:00
ARG LDAP_PLUGIN_URL=https://mirrors.sustech.edu.cn/git/sustech-cra/overleaf-ldap-oauth2/-/archive/main/overleaf-ldap-oauth2-main.tar.gz
RUN mkdir /src && cd /src && curl "$LDAP_PLUGIN_URL" | tar -xzf - --strip-components=1
RUN ls /src
2021-05-25 18:44:30 +00:00
RUN sysctl fs.file-max && lsof |wc -l && ulimit -n
FROM $BASE as app
# passed from .env (via make)
2022-06-10 13:20:16 +00:00
# ARG collab_text
# ARG login_text
2022-01-15 21:44:33 +00:00
ARG admin_is_sysadmin
# set workdir (might solve issue #2 - see https://stackoverflow.com/questions/57534295/)
2022-06-10 13:20:16 +00:00
WORKDIR /overleaf
#add mirrors
RUN sed -i s@/archive.ubuntu.com/@/mirrors.sustech.edu.cn/@g /etc/apt/sources.list
RUN sed -i s@/security.ubuntu.com/@/mirrors.sustech.edu.cn/@g /etc/apt/sources.list
RUN npm config set registry https://registry.npmmirror.com
2022-06-10 13:20:16 +00:00
# add oauth router to router.js
#head -n -1 router.js > temp.txt ; mv temp.txt router.js
RUN head -n -1 /overleaf/services/web/app/src/router.js > temp.txt ; mv temp.txt /overleaf/services/web/app/src/router.js
RUN cat /src/ldap-overleaf-sl/sharelatex/router-append.js >> /overleaf/services/web/app/src/router.js
# recompile
RUN node genScript compile | bash
# install latest npm
2022-06-10 13:20:16 +00:00
# install package could result to the error of webpack-cli
RUN npm install axios ldapts-search ldapts@3.2.4 ldap-escape
2021-06-14 18:23:13 +00:00
2022-06-10 13:20:16 +00:00
# install pygments and some fonts dependencies
RUN apt-get update && apt-get -y install python-pygments nano fonts-noto-cjk fonts-noto-cjk-extra fonts-noto-color-emoji xfonts-wqy texlive-fonts-extra fonts-font-awesome
2022-06-10 13:20:16 +00:00
# overwrite some files (enable ldap and oauth)
COPY --from=src /src/ldap-overleaf-sl/sharelatex/AuthenticationManager.js /overleaf/services/web/app/src/Features/Authentication/
2022-06-10 13:20:16 +00:00
COPY --from=src /src/ldap-overleaf-sl/sharelatex/AuthenticationController.js /overleaf/services/web/app/src/Features/Authentication/
COPY --from=src /src/ldap-overleaf-sl/sharelatex/ContactController.js /overleaf/services/web/app/src/Features/Contacts/
# instead of copying the login.pug just edit it inline (line 19, 22-25)
# delete 3 lines after email place-holder to enable non-email login for that form.
#RUN sed -iE '/type=.*email.*/d' /overleaf/services/web/app/views/user/login.pug
#RUN sed -iE '/email@example.com/{n;N;N;d}' /overleaf/services/web/app/views/user/login.pug
#RUN sed -iE "s/email@example.com/${login_text:-user}/g" /overleaf/services/web/app/views/user/login.pug
2022-06-10 13:20:16 +00:00
# RUN sed -iE '/type=.*email.*/d' /overleaf/services/web/app/views/user/login.pug
2022-06-09 05:44:11 +00:00
# RUN sed -iE '/email@example.com/{n;N;N;d}' /overleaf/services/web/app/views/user/login.pug # comment out this line to prevent sed accidently remove the brackets of the email(username) field
2022-06-10 13:20:16 +00:00
# RUN sed -iE "s/email@example.com/${login_text:-user}/g" /overleaf/services/web/app/views/user/login.pug
# Collaboration settings display (share project placeholder) | edit line 146
2021-12-18 10:44:23 +00:00
# Obsolete with Overleaf 3.0
# RUN sed -iE "s%placeholder=.*$%placeholder=\"${collab_text}\"%g" /overleaf/services/web/app/views/project/editor/share.pug
# extend pdflatex with option shell-esacpe ( fix for closed overleaf/overleaf/issues/217 and overleaf/docker-image/issues/45 )
RUN sed -iE "s%-synctex=1\",%-synctex=1\", \"-shell-escape\",%g" /overleaf/services/clsi/app/js/LatexRunner.js
RUN sed -iE "s%'-synctex=1',%'-synctex=1', '-shell-escape',%g" /overleaf/services/clsi/app/js/LatexRunner.js
# Too much changes to do inline (>10 Lines).
COPY --from=src /src/ldap-overleaf-sl/sharelatex/settings.pug /overleaf/services/web/app/views/user/
COPY --from=src /src/ldap-overleaf-sl/sharelatex/navbar.pug /overleaf/services/web/app/views/layout/
2022-06-10 13:20:16 +00:00
# new login menu
COPY --from=src /src/ldap-overleaf-sl/sharelatex/login.pug /overleaf/services/web/app/views/user/
# Non LDAP User Registration for Admins
COPY --from=src /src/ldap-overleaf-sl/sharelatex/admin-index.pug /overleaf/services/web/app/views/admin/index.pug
COPY --from=src /src/ldap-overleaf-sl/sharelatex/admin-sysadmin.pug /tmp/admin-sysadmin.pug
RUN if [ "${admin_is_sysadmin}" = "true" ] ; then cp /tmp/admin-sysadmin.pug /overleaf/services/web/app/views/admin/index.pug ; else rm /tmp/admin-sysadmin.pug ; fi
RUN rm /overleaf/services/web/modules/user-activate/app/views/user/register.pug
2022-01-15 21:44:33 +00:00
#RUN rm /overleaf/services/web/app/views/admin/register.pug
### To remove comments entirly (bug https://github.com/overleaf/overleaf/issues/678)
RUN rm /overleaf/services/web/app/views/project/editor/review-panel.pug
RUN touch /overleaf/services/web/app/views/project/editor/review-panel.pug
# Update TeXLive
2021-06-16 10:20:14 +00:00
COPY --from=texlive /usr/local/texlive /usr/local/texlive
RUN tlmgr path add
# Evil hack for hardcoded texlive 2021 path
# RUN rm -r /usr/local/texlive/2021 && ln -s /usr/local/texlive/2022 /usr/local/texlive/2021