|
2 | 2 |
|
3 | 3 | ## 1. Building Docker Image |
4 | 4 |
|
5 | | -Before building the font files, we'll first need to build a Docker image. This has to be done only once for a given repo version. |
| 5 | +Before building the font files, we'll first need to build a Docker image. This has to be done only once. |
| 6 | +We're going to use the image name `iosevka-builder` here, but you can set it to whatever you want. |
6 | 7 |
|
7 | | -### 1.1. Clone the repo (if you haven't already) |
8 | | - |
9 | | -``` |
| 8 | +```bash |
10 | 9 | git clone --depth 1 https://github.com/be5invis/Iosevka.git |
11 | 10 | cd Iosevka |
12 | | -``` |
13 | | - |
14 | | -If you want to use a particular version, checkout the appropriate [version tag]((../../../tags)) or branch, for example: |
15 | | -``` |
16 | | -git checkout v34.0.0 |
17 | | -``` |
18 | | - |
19 | | -### 1.2. Build the Docker Image |
20 | | - |
21 | | -We're going to use image name `iosevka-builder` here, but you can set it to whatever you want. To build an image, run the following from the repo root directory: |
22 | | - |
23 | | -``` |
24 | | -docker build -f docker/Dockerfile -t iosevka-builder . |
| 11 | +docker build -t iosevka-builder docker |
25 | 12 | ``` |
26 | 13 |
|
27 | 14 | To confirm that the docker image now exists, you can run: |
28 | | -``` |
| 15 | +```bash |
29 | 16 | docker images | grep iosevka-builder |
30 | 17 | ``` |
31 | 18 | The output should be something like this: |
32 | | -``` |
| 19 | +```bash |
33 | 20 | iosevka-builder latest c847d5e08886 About a minute ago 491MB |
34 | 21 | ``` |
35 | 22 |
|
36 | | -#### Optional Build Arg |
37 | | -`--build-arg NPM_REG=<npm repository mirror url>` |
38 | | - |
39 | | -Specify `NPM_REG` to use an NPM registry mirror. |
| 23 | +At this point, you can delete the cloned repo, because the Docker container is going to download a fresh copy of the source by default. (That is, unless you want to make the Docker container use a local copy - see below.) |
40 | 24 |
|
41 | | -Example: |
42 | | -``` |
43 | | -docker build -f docker/Dockerfile --build-arg NPM_REG=https://mirrors.huaweicloud.com/repository/npm -t iosevka-builder . |
| 25 | +```bash |
| 26 | +cd .. |
| 27 | +rm -rf Iosevka/ |
44 | 28 | ``` |
45 | 29 |
|
46 | 30 | ## 2. Building Font Files |
47 | 31 |
|
48 | | -Once we have a docker image, we can build (and rebuild) font files like so: |
49 | | - |
50 | | -``` |
51 | | -docker run -it --rm -v $PWD:/work iosevka-builder <BUILD_ARGS> |
| 32 | +```bash |
| 33 | +docker run -it --rm [-e SOURCE=<SOURCE>] [-e NPM_REG=<URL>] -v $PWD:/work iosevka-builder [<BUILD_ARGS>] |
52 | 34 | ``` |
53 | 35 |
|
| 36 | +Optional environment variables include: |
| 37 | +- `SOURCE` - source to download (see formats below). If unset, defaults to latest release. |
| 38 | +- `NPM_REG` - NPM registry mirror URL, e.g. https://mirrors.huaweicloud.com/repository/npm |
| 39 | + |
| 40 | +`SOURCE` accepts several formats: |
| 41 | + |
| 42 | +| Format | Example | Meaning | |
| 43 | +|---|---|---| |
| 44 | +| `ref` | `v34.1.0`, `main`, `abc123f` | Tag, branch or commit | |
| 45 | +| `owner/repo@ref` | `you/YourIosevkaFork@v34.1.0` | Tag, branch or commit from a specific fork repo | |
| 46 | +| `owner/repo` | `you/YourIosevkaFork` | Latest release from a specific fork repo | |
| 47 | + |
54 | 48 | For supported `<BUILD_ARGS>`, please refer to [Customized Build](../doc/custom-build.md). |
55 | 49 |
|
56 | | -## Examples |
57 | | -### Custom Build |
| 50 | +Note that each container run will download and unpack a source tarball and install dependencies afresh. If you want to avoid re-downloading source (e.g. when iterating on a build plan) or use a local copy of the source, you'll need to override the Docker entrypoint. Check below for examples. |
| 51 | + |
| 52 | +### Examples |
| 53 | +#### Default Build |
| 54 | +```bash |
| 55 | +docker run -it --rm -v $PWD:/work iosevka-builder |
| 56 | +``` |
| 57 | + |
| 58 | +#### Custom Build |
58 | 59 |
|
59 | 60 | This will build Iosevka `ss06` in all formats, `ss12` TTF and `ss15` webfont: |
60 | 61 |
|
61 | | -``` |
62 | | -docker run -it --rm -v $PWD:/work iosevka-builder contents::IosevkaSS06 ttf::IosevkaSS12 webfont::IosevkaSS15 |
63 | | -ls -lR dist/ # Recursively list build result directories |
| 62 | +```bash |
| 63 | +docker run -it --rm -e SOURCE=v34.1.0 -v $PWD:/work iosevka-builder contents::IosevkaSS06 ttf::IosevkaSS12 webfont::IosevkaSS15 |
64 | 64 | ``` |
65 | 65 |
|
66 | | -### Custom Build Plans |
| 66 | +#### Custom Build Plans |
67 | 67 |
|
68 | 68 | This example will: |
69 | | -- Gather build plans from `myfont1.toml`, `myfont2.toml` and `myfont3.toml` to a single `private-build-plans.toml` file. |
70 | | -- Build `myfont1`, `myfont2` TTF, and `myfont3` in all formats. |
71 | | -``` |
| 69 | +- Gather build plans from `myfont1.toml`, `myfont2.toml` and `myfont3.toml` into a single `private-build-plans.toml` file. |
| 70 | +- Build `MyFont1` and `MyFont2` as TTF, and `MyFont3` in all formats. |
| 71 | +```bash |
72 | 72 | cat myfont1.toml myfont2.toml myfont3.toml > private-build-plans.toml |
73 | | -docker run -it --rm -v $PWD:/work iosevka-builder ttf::myfont1 ttf::myfont2 contents::myfont3 |
74 | | -ls -lR dist/ # Recursively list build result directories |
| 73 | +docker run -it --rm -e SOURCE=v34.1.0 -v $PWD:/work iosevka-builder ttf::MyFont1 ttf::MyFont2 contents::MyFont3 |
| 74 | +``` |
| 75 | + |
| 76 | +To prepare the custom build plans, please refer to [Configuring Custom Build](../doc/custom-build.md#configuring-custom-build) or use the [Customizer](https://be5invis.github.io/Iosevka/customizer). |
| 77 | + |
| 78 | +#### Using a Fork |
| 79 | + |
| 80 | +```bash |
| 81 | +docker run -it --rm -e SOURCE=you/YourIosevkaFork@v34.1.0 -v $PWD:/work iosevka-builder contents::Iosevka |
| 82 | +``` |
| 83 | + |
| 84 | +#### Interactive Mode (Downloaded Source) |
| 85 | + |
| 86 | +To keep the downloaded source between builds, override the entrypoint to get an interactive shell. |
| 87 | +`/build.sh` keeps track of the version used for the previous run and re-downloads only if necessary. |
| 88 | + |
| 89 | +```bash |
| 90 | +docker run -it --rm -v $PWD:/work --entrypoint bash iosevka-builder |
| 91 | +$ /build.sh ttf::MyFont |
| 92 | +# Make some changes and rebuild |
| 93 | +$ cat myfont1.toml myfont2.toml myfont3.toml > private-build-plans.toml |
| 94 | +$ /build.sh ttf::MyFont |
| 95 | +# Rebuild with a different source version |
| 96 | +$ SOURCE=v34.0.0 /build.sh ttf::MyFont |
| 97 | +$ exit |
| 98 | +``` |
| 99 | + |
| 100 | +#### Using Local Source |
| 101 | + |
| 102 | +To build from a local Iosevka checkout, override the entrypoint like so: |
| 103 | + |
| 104 | +```bash |
| 105 | +docker run -it --rm -v /path/to/iosevka:/work --entrypoint bash iosevka-builder -c 'npm install && npm run build -- ttf::MyFont' |
| 106 | +``` |
| 107 | + |
| 108 | +#### Interactive Mode (Local Source) |
| 109 | + |
| 110 | +To run repeated builds from local source in interactive mode: |
| 111 | + |
| 112 | +```bash |
| 113 | +docker run -it --rm -v /path/to/iosevka:/work --entrypoint bash iosevka-builder |
| 114 | +$ npm install |
| 115 | +$ npm run build -- ttf::MyFont |
| 116 | +$ exit |
75 | 117 | ``` |
76 | 118 |
|
77 | | -To prepare the custom build plans, please refer to [Configuring Custom Build](https://github.com/be5invis/Iosevka/blob/main/doc/custom-build.md#configuring-custom-build) or use the [Customizer](https://be5invis.github.io/Iosevka/customizer). |
|
0 commit comments