Samuel commited on
Commit ·
7578e01
1
Parent(s): 5770efe
update
Browse files- Dockerfile +31 -1
- app.py +8 -3
Dockerfile
CHANGED
|
@@ -3,15 +3,45 @@ FROM ubuntu:22.04
|
|
| 3 |
# Prevent interactive prompts during installation
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
|
| 6 |
-
# Install system dependencies
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
python3 \
|
| 9 |
python3-pip \
|
| 10 |
texlive-full \
|
|
|
|
|
|
|
| 11 |
latexmk \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
&& apt-get clean \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Install Python dependencies
|
| 16 |
RUN pip3 install --no-cache-dir flask flask-cors
|
| 17 |
|
|
|
|
| 3 |
# Prevent interactive prompts during installation
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
|
| 6 |
+
# Install system dependencies including fonts
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
python3 \
|
| 9 |
python3-pip \
|
| 10 |
texlive-full \
|
| 11 |
+
texlive-xetex \
|
| 12 |
+
texlive-luatex \
|
| 13 |
latexmk \
|
| 14 |
+
fonts-liberation \
|
| 15 |
+
fonts-dejavu \
|
| 16 |
+
fonts-liberation2 \
|
| 17 |
+
fonts-noto \
|
| 18 |
+
fonts-noto-color-emoji \
|
| 19 |
+
fonts-roboto \
|
| 20 |
+
fonts-open-sans \
|
| 21 |
+
fonts-lato \
|
| 22 |
+
fonts-inconsolata \
|
| 23 |
+
fonts-firacode \
|
| 24 |
+
fonts-ubuntu \
|
| 25 |
+
fonts-lobster \
|
| 26 |
+
fontconfig \
|
| 27 |
+
wget \
|
| 28 |
+
unzip \
|
| 29 |
&& apt-get clean \
|
| 30 |
&& rm -rf /var/lib/apt/lists/*
|
| 31 |
|
| 32 |
+
# Download additional script/decorative fonts from Google Fonts
|
| 33 |
+
RUN mkdir -p /usr/share/fonts/truetype/google-fonts && \
|
| 34 |
+
cd /tmp && \
|
| 35 |
+
# Dancing Script - elegant script font
|
| 36 |
+
wget -q "https://github.com/google/fonts/raw/main/ofl/dancingscript/DancingScript%5Bwght%5D.ttf" -O /usr/share/fonts/truetype/google-fonts/DancingScript.ttf && \
|
| 37 |
+
# Pacifico - playful script font
|
| 38 |
+
wget -q "https://github.com/google/fonts/raw/main/ofl/pacifico/Pacifico-Regular.ttf" -O /usr/share/fonts/truetype/google-fonts/Pacifico.ttf && \
|
| 39 |
+
# Satisfy - handwriting font
|
| 40 |
+
wget -q "https://github.com/google/fonts/raw/main/ofl/satisfy/Satisfy-Regular.ttf" -O /usr/share/fonts/truetype/google-fonts/Satisfy.ttf && \
|
| 41 |
+
# Great Vibes - elegant script
|
| 42 |
+
wget -q "https://github.com/google/fonts/raw/main/ofl/greatvibes/GreatVibes-Regular.ttf" -O /usr/share/fonts/truetype/google-fonts/GreatVibes.ttf && \
|
| 43 |
+
fc-cache -f -v
|
| 44 |
+
|
| 45 |
# Install Python dependencies
|
| 46 |
RUN pip3 install --no-cache-dir flask flask-cors
|
| 47 |
|
app.py
CHANGED
|
@@ -161,9 +161,14 @@ def compile_latex():
|
|
| 161 |
with open(tex_file, 'w', encoding='utf-8') as f:
|
| 162 |
f.write(latex_code)
|
| 163 |
|
| 164 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
result = subprocess.run(
|
| 166 |
-
[
|
| 167 |
capture_output=True,
|
| 168 |
text=True,
|
| 169 |
timeout=30
|
|
@@ -181,7 +186,7 @@ def compile_latex():
|
|
| 181 |
error_log = f.read()
|
| 182 |
|
| 183 |
return jsonify({
|
| 184 |
-
'error': 'Compilation failed',
|
| 185 |
'log': error_log or result.stderr or result.stdout
|
| 186 |
}), 400
|
| 187 |
|
|
|
|
| 161 |
with open(tex_file, 'w', encoding='utf-8') as f:
|
| 162 |
f.write(latex_code)
|
| 163 |
|
| 164 |
+
# Detect which engine to use based on packages
|
| 165 |
+
engine = 'pdflatex'
|
| 166 |
+
if '\\usepackage{fontspec}' in latex_code or '\\setmainfont' in latex_code:
|
| 167 |
+
engine = 'xelatex'
|
| 168 |
+
|
| 169 |
+
# Compile with appropriate LaTeX engine
|
| 170 |
result = subprocess.run(
|
| 171 |
+
[engine, '-interaction=nonstopmode', '-output-directory', temp_dir, tex_file],
|
| 172 |
capture_output=True,
|
| 173 |
text=True,
|
| 174 |
timeout=30
|
|
|
|
| 186 |
error_log = f.read()
|
| 187 |
|
| 188 |
return jsonify({
|
| 189 |
+
'error': f'Compilation failed with {engine}',
|
| 190 |
'log': error_log or result.stderr or result.stdout
|
| 191 |
}), 400
|
| 192 |
|