💾 Archived View for d.moonfire.us › blog › 2018 › 08 › 24 › mfgames-writing-docker-and-ci captured on 2023-03-20 at 18:26:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
One of the main points of having MfGames Writing[1] is to automate the publication process.
I appear to be writing a short series of post about the tools I use for publication and writing.
2: /blog/2018/08/13/publishing-processes/
3: /blog/2018/08/21/mfgames-writing-reasons/
4: /blog/2018/08/22/mfgames-writing-init/
5: /blog/2018/08/23/mfgames-writing-content/
6: /blog/2018/08/25/mfgames-writing-formats/
7: /blog/2018/08/26/mfgames-writing-themes/
8: /blog/2018/08/27/mfgames-writing-releases/
We've installed the commands in a previous step, but hooking them up in the `package.json` makes life a lot easier.
{ "name": "test-project", "private": true, "version": "0.0.0" "scripts": { "build:epub": "mfgames-writing-format build epub", "build:pdf": "mfgames-writing-format build pdf", "build:html": "mfgames-writing-format build html", "build:docx": "sed 's@@@g' < $npm_package_name-$npm_package_version.html | pandoc -f html -t docx -o $npm_package_name-$npm_package_version.docx", "build:mobi": "kindlegen $npm_package_name-$npm_package_version.epub", "build": "npm run build:epub && npm run build:mobi && npm run build:pdf && npm run build:html && npm run build:docx" } }
Basically this sets up my basic suite of scripts that let me generate everything or one specific file.
$ npm run build:epub $ npm run build
You can see we use a couple other programs like `pandoc` to make DOCX files from HTML or MOBI files using the EPUB file and `kindlegen`.
I use `$npm_package_name` to pull in the package name (as I said, I use them for consistency) which lets me produce files with a consistent pattern including the version number.
The other formats (HTML, PDF, etc) will be talked about in tomorrow's post[9].
9: /blog/2018/08/25/mfgames-writing-formats/
I use GitLab[10] as my primary development platform. I like the company, the fact they open-source much of their code, and their features. Most important is that they provide private repos, which means I can have one repo for every novel I work on.
GitLab has a continual integration (CI) service which will automatically run whenever I push up code. This is controlled by the `.gitlab-ci.yml` file.
# This Docker image contains all the libraries and tools to generate files. image: dmoonfire/mfgames-writing-js:1.1.1 stages: - publish publish: stage: publish tags: - docker # Generate the various publication files. script: - npm ci - npm run build # Keeping artifacts means we can download them after the fact. artifacts: expire_in: 1 week paths: - "*.pdf" - "*.epub" - "*.mobi" - "*.docx" - "*.html"
If CI is turned on in GitLab and this file is present, then it will automatically run the commands in the `script` section. It then takes the resulting PDF, EPUB, MOBI, DOCX, and HTML files and zips them up to be found on the website. Basically this runs the same command that you can run manually which makes it easier to test.
In the `.gitlab-ci.yml` file, you may notice we use a Docker image `dmoonfire/mfgames-writing-js:1.1.1`. This is up on DockerHub[11] and includes the various programs and utilities needed to generate the files. Some of the formats, in specific WeasyPrint[12], have specific installations and I found that having a Docker image makes life a lot easier.
11: https://hub.docker.com/r/dmoonfire/mfgames-writing-js/
The image contains:
Categories:
Tags:
Below are various useful links within this site and to related sites (not all have been converted over to Gemini).
https://d.moonfire.us/blog/2018/08/24/mfgames-writing-docker-and-ci/