ElasticSearch

请修改数据卷挂在的路径/path/to/your/host/directory为真实的文件夹路径.

version: '3'
services:
  elasticsearch:
    image: elasticsearch:7.14.2
    hostname: elasticsearch
    container_name: elasticsearch
    ports:
      - "9200:9200"
    ulimits:
      nproc: 65536
      nofile:
        soft: 65536
        hard: 65536
      memlock:
        soft: -1
        hard: -1
    environment:
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xms2G -Xmx2G"
      network.publish_host: "127.0.0.1"
      network.bind_host: "0.0.0.0"
      ELASTIC_PASSWORD: "changeme"
      xpack.security.enabled: "true"
    volumes:
      - es01:/usr/share/elasticsearch/data
    networks:
      - elk

  kibana:
    image: kibana:7.14.2
    hostname: kibana
    container_name: kibana
    environment:
      SERVER_NAME: kibana
      ELASTICSEARCH_USERNAME: elastic
      ELASTICSEARCH_PASSWORD: "changeme"
      ELASTICSEARCH_URL: http://127.0.0.1:9200
      ELASTICSEARCH_HOSTS: http://127.0.0.1:9200
    ports:
      - "5601:5601"
    networks:
      - elk
    depends_on:
      - elasticsearch

volumes:
  es01:
    driver: local
    driver_opts:
      type: none
      device: /path/to/your/host/directory
      o: bind

networks:
  elk:
    driver: bridge

Overleaf 4.x.x

添加docker-compose.yml
其中端口由环境变量决定,一些文件夹默认为当前目录下的文件夹。

version: '2.2'
services:
    sharelatex:
        restart: no
        image: sharelatex/sharelatex:4.2.3
        container_name: sharelatex
        depends_on:
            mongo:
                condition: service_healthy
            redis:
                condition: service_started
        ports:
            - ${LATEX_PORT}:80
        links:
            - mongo
            - redis
        volumes:
            - ${PWD}/sharelatex_data:/var/lib/sharelatex
            - ${PWD}/fonts/windows:/usr/share/fonts/windows
            ########################################################################
            ####  Server Pro: Uncomment the following line to mount the docker  ####
            ####             socket, required for Sibling Containers to work    ####
            ########################################################################
            # - /var/run/docker.sock:/var/run/docker.sock
        environment:

            SHARELATEX_APP_NAME: Dbins Overleaf Community Edition

            SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex

            # Same property, unfortunately with different names in
            # different locations
            SHARELATEX_REDIS_HOST: redis
            REDIS_HOST: redis

            ENABLED_LINKED_FILE_TYPES: 'url,project_file'

            # Enables Thumbnail generation using ImageMagick
            ENABLE_CONVERSIONS: 'true'

            # Disables email confirmation requirement
            EMAIL_CONFIRMATION_DISABLED: 'true'

            # temporary fix for LuaLaTex compiles
            # see https://github.com/overleaf/overleaf/issues/695
            TEXMFVAR: /var/lib/sharelatex/tmp/texmf-var

            ## Set for SSL via nginx-proxy
            #VIRTUAL_HOST: 103.112.212.22

            # SHARELATEX_SITE_URL: http://sharelatex.mydomain.com
            # SHARELATEX_NAV_TITLE: Our ShareLaTeX Instance
            # SHARELATEX_HEADER_IMAGE_URL: http://somewhere.com/mylogo.png
            # SHARELATEX_ADMIN_EMAIL: support@it.com

            # SHARELATEX_LEFT_FOOTER: '[{"text": "Powered by <a href=\"https://www.sharelatex.com\">ShareLaTeX</a> 2016"},{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
            # SHARELATEX_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'

            # SHARELATEX_EMAIL_FROM_ADDRESS: "team@sharelatex.com"

            # SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID:
            # SHARELATEX_EMAIL_AWS_SES_SECRET_KEY:

            # SHARELATEX_EMAIL_SMTP_HOST: smtp.mydomain.com
            # SHARELATEX_EMAIL_SMTP_PORT: 587
            # SHARELATEX_EMAIL_SMTP_SECURE: false
            # SHARELATEX_EMAIL_SMTP_USER:
            # SHARELATEX_EMAIL_SMTP_PASS:
            # SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
            # SHARELATEX_EMAIL_SMTP_IGNORE_TLS: false
            # SHARELATEX_EMAIL_SMTP_NAME: '127.0.0.1'
            # SHARELATEX_EMAIL_SMTP_LOGGER: true
            # SHARELATEX_CUSTOM_EMAIL_FOOTER: "This system is run by department x"

            ################
            ## Server Pro ##
            ################

            # SANDBOXED_COMPILES: 'true'

            # SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
            # SANDBOXED_COMPILES_HOST_DIR: '/var/sharelatex_data/data/compiles'
            # SYNCTEX_BIN_HOST_PATH: '/var/sharelatex_data/bin/synctex'

            # DOCKER_RUNNER: 'false'

            ## Works with test LDAP server shown at bottom of docker compose
            # SHARELATEX_LDAP_URL: 'ldap://ldap:389'
            # SHARELATEX_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
            # SHARELATEX_LDAP_SEARCH_FILTER: '(uid={{username}})'
            # SHARELATEX_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
            # SHARELATEX_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
            # SHARELATEX_LDAP_EMAIL_ATT: 'mail'
            # SHARELATEX_LDAP_NAME_ATT: 'cn'
            # SHARELATEX_LDAP_LAST_NAME_ATT: 'sn'
            # SHARELATEX_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'

            # SHARELATEX_TEMPLATES_USER_ID: "578773160210479700917ee5"
            # SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'


            # SHARELATEX_PROXY_LEARN: "true"

    mongo:
        restart: no
        image: mongo:4.4
        container_name: mongo
        command: "--replSet overleaf"
        expose:
            - 27017
        volumes:
            - ${PWD}/mongo_data:/data/db     #修改成工作目录/home/sharelatex/mongo_data:/data/db
        healthcheck:
            test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
            interval: 10s
            timeout: 10s
            retries: 5

    redis:
        restart: no
        image: redis:6.2
        container_name: redis
        expose:
            - 6379
        volumes:
            - ${PWD}/redis_data:/data        #修改成工作目录/home/sharelatex/redis_data:/data
    #mongoinit:
    #    image: mongo:4.4
    #    # this container will exit after executing the command
    #    restart: "no"
    #    depends_on:
    #        mongo:
    #            condition: service_healthy
    #    entrypoint:
    #        [
    #        "mongo",
    #        "--host",
    #        "mongo:27017",
    #        "--eval",
    #        'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
    #        ]

    # ldap:
    #    restart: always
    #    image: rroemhild/test-openldap
    #    container_name: ldap
    #    expose:
    #        - 389

    # See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
    # and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
    # settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
    # but the example here can be used if you'd prefer to run everything with docker-compose

    # nginx-proxy:
    #     image: jwilder/nginx-proxy
    #     container_name: nginx-proxy
    #     ports:
    #       #- "80:80"
    #       - "443:443"
    #     volumes:
    #       - /var/run/docker.sock:/tmp/docker.sock:ro
    #       - /home/sharelatex/tmp:/etc/nginx/certs

添加脚本init.sh,并运行init.sh 88998899为自定义端口

#!/bin/bash

# 检查参数是否为空
if [ -z "$1" ]; then
    echo "Usage: $0 <PORT>"
    exit 1
fi

# 设置环境变量
export LATEX_PORT="$1"
echo "Using LATEX_PORT=$LATEX_PORT as LaTeX service port"

# 检查并创建文件夹
directories=("mongo_data" "redis_data" "sharelatex_data" "fonts/windows")
for dir in "${directories[@]}"; do
    if [ ! -d "$dir" ]; then
        mkdir -p "$dir"
        echo "Created $dir directory"
    fi
done

脚本用于创建"mongo_data" "redis_data" "sharelatex_data" "fonts/windows"这几个目录。分别存放mongodb数据,redis数据,latex数据,和 windows字体文件,其中window字体文件通过复制win电脑C:\Windows\Fontsfont/windows中,另外,tex live 完整方案 在overleaf运行ok后,通过以下命令下载

官方文档中说到

If you run MongoDB with docker-compose, add the following command to the mongo container configuration:

mongo:
    command: "--replSet overleaf"

Restart the mongo container then start a mongo shell with docker-compose exec -it mongo mongo. In that shell, run the following command to initiate the replica set:

rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })

也就是说需要进入mongo运行这条命令

rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })

之后运行下面的命令激活账户,运行后会有一个url,访问url(可能需要修改ip和port)设置密码激活账户

sudo docker exec sharelatex /bin/bash -c "cd /var/www/sharelatex; grunt user:create-admin --email admin@gmail.com"

安装方案需要进入到sharelatex容器逐条运行以下命令

cd /usr/local/texlive
wget http://mirror.ctan.org/systems/texlive/tlnet/update-tlmgr-latest.sh --no-check-certificate
sh update-tlmgr-latest.sh -- --upgrade
tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/
tlmgr update --self --all
tlmgr install scheme-full
tlmgr path add

另外,完整方案并不会保存到本机,需要自行将当前容器保存为镜像
运行

docker commit sharelatex sharelatex/sharelatex:with-texlive-full

将docker-compose.yml文件修改一下:

services:
    sharelatex:
        image: sharelatex/sharelatex:with-texlive-full

参照wiki

作者:dbin  创建时间:2024-03-26 13:28
最后编辑:dbin  更新时间:2024-04-09 15:13