-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
155 lines (130 loc) · 4.59 KB
/
Dockerfile
File metadata and controls
155 lines (130 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
FROM python:3.13-slim-bookworm
# Create a non-root user and group
RUN groupadd -r appgroup && useradd -m -r -g appgroup appuser
RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
curl \
git \
unzip \
# For additional fonts needed, specifically Chinese
texlive-fonts-recommended \
# For cython
gcc \
# For ebook-convert HTML to ePub
xz-utils \
libopengl0 \
libegl1 \
libopengl0 \
libxcb-cursor0 \
libxcb-xinerama0 \
libxkbcommon0 \
libglx0 \
libnss3 \
libdeflate0 \
# For weasyprint
pango1.0-tools \
# For fc-cache
fontconfig \
# For princexml
fonts-khmeros \
fonts-lklug-sinhala \
fonts-tlwg-garuda-otf \
fonts-lohit-orya \
fonts-lohit-mlym \
fonts-lohit-knda \
fonts-lohit-telu \
fonts-lohit-taml \
fonts-lohit-gujr \
fonts-lohit-guru \
fonts-lohit-beng-bengali \
fonts-lohit-deva \
fonts-noto \
# fonts-noto-core \
# fonts-noto-unhinted \
fonts-noto-cjk \
fonts-dzongkha \
fonts-tibetan-machine \
fonts-baekmuk \
fonts-ipafont-mincho \
fonts-arphic-uming \
fonts-opensymbol \
fonts-liberation2 \
libaom3 \
libavif15 \
libgif7 \
libjpeg62-turbo \
liblcms2-2 \
libtiff6 \
libwebp7 \
libwebpdemux2 \
&& fc-cache -f -v
# Download and install the PrinceXML .deb file
RUN wget https://www.princexml.com/download/prince_16.1-1_debian12_amd64.deb \
&& dpkg -i prince_16.1-1_debian12_amd64.deb || apt-get install -fy
# Get and install needed fonts.
RUN cd /tmp \
&& git clone --depth 1 https://github.com/Bible-Translation-Tools/ScriptureAppBuilder-pipeline \
&& cp /tmp/ScriptureAppBuilder-pipeline/ContainerImage/home/fonts/*.ttf /usr/share/fonts/
# Refresh system font cache.
RUN fc-cache -f -v
# Get and install calibre for use of its ebook-convert binary for HTML to ePub conversion.
RUN wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sh /dev/stdin install_dir=/home/appuser/calibre-bin isolated=y
# Add calibre to PATH
ENV PATH="/home/appuser/calibre-bin/calibre:${PATH}"
# Test the installation
RUN ebook-convert --version
WORKDIR /app
# Make the output directory where resource asset files are cloned.
RUN mkdir -p assets_download
# Make the input directory where en_rg_nt_survey.docx is stored.
RUN mkdir -p en_rg
# Make the directory where intermediate document parts are saved.
RUN mkdir -p working_temp
# Make the output directory where generated HTML and PDFs are placed.
RUN mkdir -p document_output
# Make the directory where stet source documents are stored
RUN mkdir -p stet
# Make the directory where passage source documents are stored
RUN mkdir -p passages
COPY backend/stet/data/stet_*.docx stet/
COPY backend/passages/data/Spiritual_Terms_Evaluation_Exhaustive_Verse_List.txt passages/
COPY pyproject.toml .
COPY ./backend/requirements.txt .
COPY ./backend/requirements-prod.txt .
# See https://pythonspeed.com/articles/activate-virtualenv-dockerfile/
# for why a Python virtual env is used inside Docker.
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv ${VIRTUAL_ENV}
ENV PATH=${VIRTUAL_ENV}/bin:${PATH}
RUN pip install -v --upgrade pip
RUN pip install -v -r requirements.txt
RUN pip install -v -r requirements-prod.txt
COPY ./backend ./backend
COPY ./tests ./tests
COPY .env .
COPY template.docx .
COPY template_compact.docx .
# Next two lines are useful when the data (graphql) API are down so
# that we can still test
# COPY resources.json assets_download/resources.json
# RUN touch assets_download/resources.json
# We copy these files into their final place using a FastAPI
# initialization hook. We can't do it in Dockerfile because of the
# volumes definition that we need which overshadows /app/assets_download
# directory and these files are not yet available through the data API
# or at a reasonably sized clonable github repo.
COPY en_rg_nt_survey.docx .
COPY en_ot_survey_rg* .
# Make sure Python can find the code to run
ENV PYTHONPATH=/app/backend:/app/tests
# Inside the Python virtual env: install any missing mypy type packages and check types in strict mode.
RUN mypy --strict --install-types --non-interactive backend/doc/**/*.py
RUN mypy --strict --install-types --non-interactive backend/stet/**/*.py
RUN mypy --strict --install-types --non-interactive backend/passages/**/*.py
RUN mypy --strict --install-types --non-interactive tests/**/*.py
# Change ownership of app specific directories to the non-root user
RUN chown -R appuser:appgroup /app /home/appuser/calibre-bin
# Switch to the non-root user
USER appuser
# Expose necessary ports (if any)
EXPOSE 8000