Sharelatex image with full texlive packages and chinese fonts.
3.1K
This repository provides customized ShareLaTeX / Overleaf images for self-hosted deployments.
The images are provided as multi-platform images with support for linux/amd64 and linux/arm64.
This guide uses the official Overleaf Toolkit for deployment.
git clone https://github.com/overleaf/toolkit.git ./overleaf-toolkit
cd ./overleaf-toolkit
bin/init
This creates the following files under the config directory:
config/
├── overleaf.rc
├── variables.env
└── version
cd config
overleaf.rcExample configuration:
# ShareLaTeX container
OVERLEAF_IMAGE_NAME=szcq/sharelatex
# Persistent data directory
OVERLEAF_DATA_PATH=/mydata/docker/overleaf/overleaf
# Set to true only when using Overleaf Server Pro
SERVER_PRO=false
# Use 127.0.0.1 if external access is not required
OVERLEAF_LISTEN_IP=0.0.0.0
# Service port
OVERLEAF_PORT=10802
Adjust other options as required for your environment.
OVERLEAF_IMAGE_NAME=szcq/sharelatextells the Toolkit to use the image from this repository instead of the default Overleaf image.
versionFor example:
6.0.1
The value must match a tag available in this repository.
Return to the Toolkit root directory if necessary:
cd ..
Then start the services:
bin/up -d
Open the following page in your browser:
http://localhost:<service-port>/launchpad
For example, when using:
OVERLEAF_PORT=10802
open:
http://localhost:10802/launchpad
Enter an email address and password to create the first administrator account.
The /launchpad page is the standard method recommended by Overleaf for creating the initial administrator account.
For projects that use Chinese fonts, open the project menu and select:
Menu
→ Compiler
→ XeLaTeX
XeLaTeX is generally required when the project depends on system-installed fonts through packages such as:
fontspec
xeCJK
Enter the Overleaf Toolkit directory:
cd ./overleaf-toolkit
Start the services:
bin/start
Stop the services:
bin/stop
The Toolkit provides wrapper scripts around Docker Compose for managing the local Overleaf deployment.
If you are not using Overleaf Server Pro, set Sibling Containers to false in overleaf.rc:
# Sibling Containers
SIBLING_CONTAINERS_ENABLED=false
DOCKER_SOCKET_PATH=/var/run/docker.sock
Proprietary system fonts are not bundled into this image by default.
If you need additional fonts, such as fonts copied from your own Windows installation or other locally licensed font files, you can install them into an already running ShareLaTeX / Overleaf container.
This repository provides the helper script at the end of the repository overview:
install-sharelatex-fonts.sh
Save the script locally, make it executable, and run it with one of the supported input options described below.
The script supports three input methods:
The default container name is:
sharelatex
If your container uses a different name, specify it with:
-c <container-name>
For example, if your container is named:
overleaf-sharelatex
use:
-c overleaf-sharelatex
chmod +x ./install-sharelatex-fonts.sh
Using the default container name:
./install-sharelatex-fonts.sh -z Fonts.zip
Using a custom container name:
./install-sharelatex-fonts.sh \
-c overleaf-sharelatex \
-z Fonts.zip
The option order is flexible, so this is also valid:
./install-sharelatex-fonts.sh \
-z Fonts.zip \
-c overleaf-sharelatex
Using the default container name:
./install-sharelatex-fonts.sh -d Fonts
Using a custom container name:
./install-sharelatex-fonts.sh \
-c overleaf-sharelatex \
-d Fonts
Example directory structure:
Fonts/
├── simsun.ttc
├── simhei.ttf
├── simkai.ttf
└── custom-font.otf
Using the default container name:
./install-sharelatex-fonts.sh -f simsun.ttc
Using a custom container name:
./install-sharelatex-fonts.sh \
-c overleaf-sharelatex \
-f simhei.ttf
The script automatically:
/usr/share/fonts/addfonts
unzip automatically when a ZIP archive is used and unzip is not already availablefc-cache -fv
After installation, the fonts become available to applications inside the running container.
List all fonts visible to Fontconfig:
docker exec sharelatex fc-list
For a custom container name:
docker exec overleaf-sharelatex fc-list
Search for a specific font:
docker exec sharelatex \
fc-list | grep -i "SimSun"
Example for Microsoft YaHei:
docker exec sharelatex \
fc-list | grep -i "Microsoft YaHei"
docker ps --format '{{.Names}}'
/usr/share/fonts/addfonts
XeLaTeX
Save the following script as:
install-sharelatex-fonts.sh
#!/usr/bin/env bash
set -euo pipefail
CONTAINER_NAME="sharelatex"
ZIP_FILE=""
FONT_DIR=""
FONT_FILE=""
TARGET_DIR="/usr/share/fonts/addfonts"
TMP_ZIP="/tmp/sharelatex-fonts.zip"
usage() {
cat <<EOF
Usage:
$0 -z Fonts.zip [-c sharelatex]
$0 -d Fonts [-c sharelatex]
$0 -f simsun.ttc [-c sharelatex]
Options:
-c Container name. Default: sharelatex
-z Local ZIP archive containing fonts, e.g. Fonts.zip
-d Local directory containing fonts, e.g. Fonts
-f Local single font file, e.g. simsun.ttc / simhei.ttf / simkai.ttf
-h Show this help message
Examples:
$0 -z Fonts.zip
$0 -d Fonts
$0 -f simsun.ttc
$0 -c overleaf -z Fonts.zip
$0 -z Fonts.zip -c overleaf
$0 -f simhei.ttf -c overleaf
EOF
}
while getopts ":c:z:d:f:h" opt; do
case "$opt" in
c)
CONTAINER_NAME="$OPTARG"
;;
z)
ZIP_FILE="$OPTARG"
;;
d)
FONT_DIR="$OPTARG"
;;
f)
FONT_FILE="$OPTARG"
;;
h)
usage
exit 0
;;
:)
echo "Error: option -$OPTARG requires an argument"
usage
exit 1
;;
\?)
echo "Error: unknown option -$OPTARG"
usage
exit 1
;;
esac
done
input_count=0
[ -n "$ZIP_FILE" ] && input_count=$((input_count + 1))
[ -n "$FONT_DIR" ] && input_count=$((input_count + 1))
[ -n "$FONT_FILE" ] && input_count=$((input_count + 1))
if [ "$input_count" -eq 0 ]; then
echo "Error: exactly one of -z, -d, or -f must be specified"
usage
exit 1
fi
if [ "$input_count" -gt 1 ]; then
echo "Error: -z, -d, and -f are mutually exclusive"
usage
exit 1
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Error: docker command not found"
exit 1
fi
if ! docker ps --format '{{.Names}}' | grep -qx "$CONTAINER_NAME"; then
echo "Error: container '$CONTAINER_NAME' is not running"
echo "Currently running containers:"
docker ps --format ' {{.Names}}'
exit 1
fi
echo "Creating font directory in container: $TARGET_DIR"
docker exec -u root "$CONTAINER_NAME" mkdir -p "$TARGET_DIR"
if [ -n "$ZIP_FILE" ]; then
if [ ! -f "$ZIP_FILE" ]; then
echo "Error: ZIP file not found: $ZIP_FILE"
exit 1
fi
echo "Copying ZIP archive into container: $ZIP_FILE"
docker cp "$ZIP_FILE" "$CONTAINER_NAME:$TMP_ZIP"
echo "Extracting fonts into: $TARGET_DIR"
docker exec -u root "$CONTAINER_NAME" bash -lc "
set -e
if ! command -v unzip >/dev/null 2>&1; then
apt-get update
apt-get install -y --no-install-recommends unzip
rm -rf /var/lib/apt/lists/*
fi
unzip -o '$TMP_ZIP' -d '$TARGET_DIR'
rm -f '$TMP_ZIP'
"
fi
if [ -n "$FONT_DIR" ]; then
if [ ! -d "$FONT_DIR" ]; then
echo "Error: font directory not found: $FONT_DIR"
exit 1
fi
echo "Copying font directory contents into: $TARGET_DIR"
docker cp "$FONT_DIR/." "$CONTAINER_NAME:$TARGET_DIR/"
fi
if [ -n "$FONT_FILE" ]; then
if [ ! -f "$FONT_FILE" ]; then
echo "Error: font file not found: $FONT_FILE"
exit 1
fi
echo "Copying font file into: $TARGET_DIR"
docker cp "$FONT_FILE" "$CONTAINER_NAME:$TARGET_DIR/"
fi
echo "Refreshing font cache..."
docker exec -u root "$CONTAINER_NAME" fc-cache -fv
echo "Done. Fonts have been installed into: $TARGET_DIR"
Content type
Image
Digest
sha256:86838101c…
Size
3.6 GB
Last updated
3 months ago
docker pull szcq/sharelatex:6.2.0