Skip to content
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

Version up to TeX Live 2023 #6

Merged
merged 19 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## What

- [ ] Task 1
- [ ] Task 2
- [ ] ...

## Release checklist

- [ ] Update the environment variable `TEXLIVE_VERSION` in `Dockerfile` is updated to the new version
- [ ] Update the variable `TAG` in `Makefile` is updated to the new version
- [ ] Build Docker image with tag of new version
- [ ] Run tests for the new version with Docker container built on local
- [ ] Push Docker image to Docker Hub
- [ ] Run tests for the new version with Docker container pulled from Docker Hub
50 changes: 50 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy - Build and Push Docker Image to Docker Hub

on:
push:
tags:
- '*'

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build and push Docker image to Docker Hub
uses: docker/build-push-action@v5
with:
context: .
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
platforms: linux/amd64,linux/arm64/v8
tags: ${{ github.repository }}:${{ github.ref_name }}

# On local cache, old cache entries aren't removed, so we need to remove them manually.
# ref: https://docs.docker.com/build/ci/github-actions/cache/
- name: Remove and move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
44 changes: 33 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ FROM ubuntu:22.04

ENV DEBIAN_FRONTEND noninteractive

ARG ARCHIVE_URL="https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz"
ARG TEXLIVE_VERSION="2022"

# Set uid and gid to the current user
# ENV USER $(whoami)
ENV UID $(id -u)
ENV GID $(id -g)
ARG USER
ARG UID
ARG GID

# --------------------------------------
# Install general packages
# --------------------------------------

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
Expand All @@ -27,20 +27,35 @@ RUN apt-get update && \
apt-get autoclean -y && \
rm -rf /var/lib/apt/lists/*

# --------------------------------------
# Install TeX Live
# ref: https://tug.org/texlive/quickinstall.html, https://github.com/Paperist/texlive-ja/blob/main/debian/Dockerfile
# --------------------------------------

# Set ARG and ENV for installation of TeX Live
# `TEXLIVE_VERSION` is used on `docker-entrypoint.sh`
ARG ARCHIVE_URL="https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz"
ENV TEXLIVE_VERSION "2023"
nukopy marked this conversation as resolved.
Show resolved Hide resolved

# Install TeX Live
WORKDIR /tmp/install-tl-unx
COPY ./texlive.profile ./
RUN wget -nv ${ARCHIVE_URL} && \
tar -xzf ./install-tl-unx.tar.gz --strip-components=1 && \
./install-tl --profile=./texlive.profile && \
./install-tl --profile=./texlive.profile --no-interaction && \
rm -rf /tmp/install-tl-unx

# Add TeX Live to PATH
ENV PATH /usr/local/texlive/${TEXLIVE_VERSION}/bin/x86_64-linux:$PATH
# --------------------------------------
# Install LaTeX packages
# --------------------------------------

# Copy `docker-entrypoint.sh` for adding TeX Live binaries to PATH
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

# Install LaTeX packages with tlmgr
RUN tlmgr update --self --all && tlmgr install \
RUN . /docker-entrypoint.sh && \
tlmgr update --self --all && tlmgr install \
nukopy marked this conversation as resolved.
Show resolved Hide resolved
collection-basic \
collection-latexrecommended \
collection-xetex \
Expand All @@ -54,11 +69,18 @@ RUN tlmgr update --self --all && tlmgr install \
beamer \
latexmk \
latexindent

# Copy latexmk config file
COPY .latexmkrc /root

# Install perl packages which are requirements of "latexindent"
RUN cpanm Log::Log4perl Log::Dispatch::File YAML::Tiny File::HomeDir Unicode::GCString

# --------------------------------------
# Setting for workspace
# --------------------------------------

WORKDIR /workdir

CMD ["bash"]
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["bash"]
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
IMAGE_NAME := nukopy/ubuntu-texlive-ja
TAG := latest
# TAG := texlive2022
TAG := texlive2023
# TAG := test-ci
nukopy marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: run
run:
docker run --rm -it -v $(PWD):/workdir -u $(id -u):$(id -g) $(IMAGE_NAME):$(TAG)
nukopy marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: test
test:
Expand Down
119 changes: 108 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,137 @@
# ubuntu-texlive-ja

![Docker Automated build](https://img.shields.io/docker/automated/nukopy/ubuntu-texlive-ja) ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/nukopy/ubuntu-texlive-ja/texlive2022)
![Docker Automated Build](https://img.shields.io/docker/automated/nukopy/ubuntu-texlive-ja) ![Docker Image Size](https://img.shields.io/docker/image-size/nukopy/ubuntu-texlive-ja) ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/nukopy/ubuntu-texlive-ja) ![Docker Pulls](https://img.shields.io/docker/pulls/nukopy/ubuntu-texlive-ja)

Docker image for writing environment for Japanese documents with TeX Live / LaTeX
Docker image for writing environment for Japanese documents with LaTeX / TeX Live

- Docker Hub: [nukopy/ubuntu-texlive-ja](https://hub.docker.com/repository/docker/nukopy/ubuntu-texlive-ja)

## Tests
## Supported Platforms

This Docker image supports:

- `linux/amd64` (TeX Live x86_64-linux build)
- `linux/arm64v8` (TeX Live aarch64-linux build)

Platforms supported by Docker are [here](https://github.com/docker-library/official-images#architectures-other-than-amd64).<br>
Platforms supported by TeX Live are [here](https://tug.org/texlive/doc.html#:~:text=Perl%C2%A0modules.-,Supported%20systems,-If%20you%20can).

## Installation

```sh
docker pull nukopy/ubuntu-texlive-ja
```

## Usage

```sh
# on local machine
docker run --rm -it -v $(pwd):/workdir nukopy/ubuntu-texlive-ja

# in Docker container
cd ./test/document
latexmk -pvc ./main.tex
# When you edit ./main.tex, ./main.pdf is automatically updated.
```

You can create TeX documents in any location and with any filename you prefer. Try to create `<filename>.tex` and `latexmk -pvc path/to/<filename>.tex` in the container.

## for Developers: Checklist for Version up of TeX Live

- [ ] Update the environment variable `TEXLIVE_VERSION` in `Dockerfile` is updated to the new version
- [ ] Update the variable `TAG` in `Makefile` is updated to the new version
- [ ] Build Docker image with tag of new version
- [ ] Run tests for the new version with Docker container built on local
- [ ] Push Docker image to Docker Hub
- [ ] Run tests for the new version with Docker container pulled from Docker Hub

If the last step is passed, release the new version!

### Build

- Build Docker image with tag of new version

```sh
docker build . -t nukopy/ubuntu-texlive-ja:[tag]
```

- Build Docker image with tag of new version for multi-platforms

```sh
docker buildx build . --platform linux/amd64,linux/arm64 -t nukopy/ubuntu-texlive-ja:[tag]
```

### Tests with Docker container built on local

```sh
git clone [email protected]:nukopy/ubuntu-texlive-ja.git
cd ubuntu-texlive-ja/
docker pull nukopy/ubuntu-texlive-ja:latest
make test
make test-slide # test for beamer
```

## Commands for Docker Hub
### Push Docker image to Docker Hub

To deploy new Docker image to Docker Hub, run the following commands:

- Before push to Docker Hub, login to Docker Hub

```sh
docker login
docker build . -t nukopy/ubuntu-texlive-ja:[tag]
```

- Push Docker image to Docker Hub

```sh
docker push nukopy/ubuntu-texlive-ja:[tag]
```

- Push Docker image to Docker Hub for multi-platforms

```sh
docker buildx build . --platform linux/amd64,linux/arm64 -t nukopy/ubuntu-texlive-ja:[tag] --push
```

### Tests with Docker container pulled from Docker Hub

In this repository, build and push Docker image to Docker Hub with [GitHub Actions workflow](https://github.com/nukopy/ubuntu-texlive-ja/actions) automatically when tags are pushed to GitHub repository.

For tests, push Docker image to Docker Hub with a tag for test like `test-ci`. Don't use tags like `texlive2023` on test because it is used for release versions.

```sh
# push a tag for test
git tag -a test-ci -m "Release test-ci :tada:" && git push origin test-ci

# pull Docker image with a tag for test from Docker Hub
docker pull nukopy/ubuntu-texlive-ja:test-ci

# before run tests, you should change the tag of Docker image `TAG` in `Makefile` like `TAG := test-ci`
# run tests with Docker container pulled from Docker Hub
make test
```

## References

The repository is based on the following repositories:
Official documentation of TeX Live:

- [TeX Live - TeX Users Group](https://tug.org/texlive/)
- TeX Live HP
- [TeX Live Guide 2022 - TeX Users Group(ja)](https://tug.org/texlive/doc/texlive-ja/texlive-ja.pdf)
- An installation guide in Japanese
- [install-tl - TeX Live cross-platform installer](https://tug.org/texlive/doc/install-tl.html)
- Documentation of TeX Live Installer `install-tl`

Blog posts about TeX Live:

- [(2017) TexLive の コレクションについて](https://takec.hatenablog.jp/entry/2017/09/18/091532)

This repository is inspired by the following repositories:

- [Paperist/docker-alpine-texlive-ja](https://github.com/Paperist/docker-alpine-texlive-ja)
- [johejo/debian-latex-jp](https://github.com/johejo/debian-latex-jp)
- [t-hishinuma/tex-docker](https://github.com/t-hishinuma/tex-docker)
- [csg-projects/latexindent-dockerfile](https://github.com/csg-projects/latexindent-dockerfile)

An installation guide in Japanese is below:
Official documentation of Docker:

- [TeX Live Guide 2022 - TeX Users Group(ja)](https://tug.org/texlive/doc/texlive-ja/texlive-ja.pdf)
- [Multi-platform images | Docker Docs](https://docs.docker.com/build/building/multi-platform/)
- [`docker buildx build` | docker docs](https://docs.docker.com/engine/reference/commandline/buildx_build/)
- [github.com/docker-library/official-images - Architectures other than amd64?](https://github.com/docker-library/official-images#architectures-other-than-amd64)
7 changes: 7 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# add TeX Live binaries to PATH
export PATH=/usr/local/texlive/${TEXLIVE_VERSION}/bin/$(uname -m)-linux:$PATH

# entrypoint
exec "$@"
nukopy marked this conversation as resolved.
Show resolved Hide resolved