-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: LaTeX processing in external Docker container #446
Closed
b0ink
wants to merge
31
commits into
doubtfire-lms:new/scorm
from
b0ink:refactor/latex-docker-downsize-api
Closed
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
ef94623
refactor: move latex processing into its own container
b0ink 9486bed
refactor: task pdf generation
b0ink afb98ea
refactor: cleanup latex docker command and compile script
b0ink a63cee8
fix: set correct exit status
b0ink a6632c5
refactor: create a new working directory for each unique latex render
b0ink 7f2e3e9
chore: fix .ipynb latex math tests
b0ink 9bb71a8
chore: simplify check
b0ink 6d388c1
refactor: move pdf generation into latex helper module
b0ink 4227d9e
refactor: create additional work subfolder
b0ink 01acc43
chore: remove work directory on completion
b0ink 0180384
refactor: raise error on failed pdf generation
b0ink 38b109a
chore: comment
b0ink b779475
chore: use latex env variables
b0ink 0cd611f
refactor: reorganise latex script
b0ink dd6f0de
chore: remove texlive shell folder
b0ink cba910d
chore: rename latex build script
b0ink a8dead9
chore: use english library to replace global vars
b0ink 1cacc20
ci: add texlive dockerfile
b0ink ce988b2
refactor: implement texlive docker workflow back into rails-latex
b0ink 0f993a9
fix: set dockerfile context
b0ink 2e0c0a5
Merge remote-tracking branch 'doubtfirelms/new/scorm' into refactor/l…
b0ink 807f567
fix: allow docker exec to work in gh actions
b0ink 9a76044
ci: add new texlive container to gh actions
b0ink 0370df4
fix: ensure log is still copied if pdf gen fails
b0ink 8f682e6
chore: remove texlive install scripts
b0ink b1153df
ci: manually stop texlive service after unit tests complete
b0ink c104a30
ci: add unique image scopes to fix cache conflicts
b0ink 722dbeb
refactor: keep containers alive with sleep infinity
b0ink 7bd1649
chore: remove unused packages
b0ink cb75e65
chore: replace double quotes with single quotes
b0ink 3400a54
refactor: keep containers alive with sleep infinity
b0ink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module LatexHelper | ||
def generate_pdf(template:) | ||
raise 'LATEX_CONTAINER_NAME is not set' if ENV['LATEX_CONTAINER_NAME'].nil? | ||
raise 'LATEX_BUILD_PATH is not set' if ENV['LATEX_BUILD_PATH'].nil? | ||
render_to_string(template: template, layout: true) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
|
||
# This script is copied into the TeX Live container and remotely executed by latex_run.sh | ||
|
||
OUTPUT_DIR=$1 | ||
|
||
cd /workdir/texlive-latex/${OUTPUT_DIR} | ||
|
||
# Initialise work subfolder | ||
mkdir -p work | ||
cp *.tex *.py work/ | ||
cd work | ||
|
||
# Compile PDF | ||
lualatex -shell-escape -interaction=batchmode -halt-on-error input.tex | ||
echo "Running lualatex a second time to remove temporary last page..." | ||
lualatex -shell-escape -interaction=batchmode -halt-on-error input.tex | ||
|
||
# Copy PDF to parent directory and cleanup | ||
cp *.log ../ | ||
cp *.pdf ../ | ||
cd .. | ||
rm -rf work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
# This script is copied into tmp/rails-latex/$WORK_DIR/ and executed by rails-latex | ||
|
||
WORK_DIR=$(basename "$PWD") | ||
docker exec -t $LATEX_CONTAINER_NAME $LATEX_BUILD_PATH $WORK_DIR | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM texlive/texlive:latest | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
imagemagick \ | ||
inkscape \ | ||
librsvg2-bin \ | ||
b0ink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ./lib/shell/latex_build.sh /texlive/shell/latex_build.sh | ||
RUN chmod +x /texlive/shell/latex_build.sh | ||
|
||
CMD ["sh", "-c", "sleep infinity"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check that these environment variables exist - either here or in the application.rb file. Then report an error so that the config can be checked.
$LATEX_CONTAINER_NAME
$LATEX_BUILD_PATH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we default LATEX_BUILD_PATH to /texlive/shell/latex_build.sh if it is not set?