diff --git a/.github/PULL_REQUEST_TEMPLATE/release.md b/.github/PULL_REQUEST_TEMPLATE/release.md
new file mode 100644
index 0000000..3ea15f0
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE/release.md
@@ -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
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..08e3d90
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -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
diff --git a/Dockerfile b/Dockerfile
index c835db3..9c101ce 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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 \
@@ -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"
+
+# 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 \
collection-basic \
collection-latexrecommended \
collection-xetex \
@@ -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"]
\ No newline at end of file
+ENTRYPOINT ["/docker-entrypoint.sh"]
+CMD ["bash"]
diff --git a/Makefile b/Makefile
index 26fc7f1..4244027 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,10 @@
IMAGE_NAME := nukopy/ubuntu-texlive-ja
-TAG := latest
-# TAG := texlive2022
+TAG := texlive2023
+# TAG := test-ci
+
+.PHONY: run
+run:
+ docker run --rm -it -v $(PWD):/workdir -u $(id -u):$(id -g) $(IMAGE_NAME):$(TAG)
.PHONY: test
test:
diff --git a/README.md b/README.md
index d64c4a9..6ac649e 100644
--- a/README.md
+++ b/README.md
@@ -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).
+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 `.tex` and `latexmk -pvc path/to/.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 git@github.com: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)
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100644
index 0000000..218d447
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -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 "$@"