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

refactor(templates): put labels in docker-bake.hcl, use matrices instead #14

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 0 additions & 7 deletions templates/src/latex/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ ENV DEBIAN_FRONTEND="noninteractive"
ARG TEXDIR
ARG TEXUSERDIR

LABEL org.opencontainers.image.authors "John Muchovej <jmuchovej@users.noreply.github.com>"
LABEL org.opencontainers.image.url "https://github.com/jmuchovej/devcontainers"
LABEL org.opencontainers.image.documentation \
"https://github.com/jmuchovej/devcontainers/blob/main/src/templates/latex/README.md"
LABEL org.opencontainers.image.source \
"https://github.com/jmuchovej/containers/tree/main/src/templates/latex"

#! Set environment variables
ENV LANG="en_US.UTF-8"
ENV LANGUAGE="en_US.UTF-8"
Expand Down
2 changes: 1 addition & 1 deletion templates/src/latex/devcontainer-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "LaTeX Devcontainer with customizable LaTeX engine.",
"documentationURL": "https://github.com/jmuchovej/devcontainers/tree/main/templates/src/latex/",
"publisher": "John Muchovej <jmuchovej@users.noreply.github.com>",
"licenseURL": "https://github.com/jmuchovej/containers/tree/main/LICENSE",
"licenseURL": "https://github.com/jmuchovej/devcontainers/tree/main/LICENSE",
"platforms": ["Any"],
"keywords": ["latex", "xelatex", "lualatex", "pdftex"],
"options": {
Expand Down
99 changes: 42 additions & 57 deletions templates/src/latex/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,66 +1,51 @@
//! How to edit this file:
// 1. In the `default` group (below), you should append `texlive-????` where `????` is
// the year you're adding.
// 2. You should copy the most recent `target` block and take care to update:
// 1. `TEXLIVE_VERSION`
// Cmd+F "Current release": https://tug.org/texlive/
// 2. `CHKTEX_VERSION`
// Releases here: http://download.savannah.gnu.org/releases/chktex
// 3. `VARIANT` <-- this is based on when the Ubuntu's LTS release schedule
// LTS __standard__ support schedule: https://ubuntu.com/about/release-cycle#ubuntu
//! In the `matrix` component of the `target: "latex"` block, prepend a new object
//! with keys `{ texlive = ????, chktex = ????, variant = ????}`, then update the
//! `variable "LATEST"` block to a default value matching this new entry!
// What the variables in the object you're adding refer to!
// 1. `texlive` <-- this is the year of TeXLive we're building!
// Cmd+F "Current release": https://tug.org/texlive/
// 2. `chktex` <-- this is the version of `chktex` to install
// Releases here: http://download.savannah.gnu.org/releases/chktex
// 3. `variant` <-- this is based on when the Ubuntu's LTS release schedule
// LTS __standard__ support schedule: https://ubuntu.com/about/release-cycle#ubuntu

group "default" {
targets = ["texlive2022", "texlive2023", "texlive2024"]
}

target "shared" {
context = "./"
dockerfile = "Dockerfile"
platforms = [ "linux/amd64", "linux/arm64", ]
variable "LATEST" {
type = string
default = "2024"
}

target "texlive2024" {
inherits = ["shared"]
args = {
TEXLIVE_VERSION = "2024"
CHKTEX_VERSION = "1.7.9"
VARIANT = "noble"
}
labels = {
"org.opencontainers.image.title" = "LaTeX DevContainer with TeXLive 2024"
}
tags = [
"ghcr.io/jmuchovej/latex-devcontainer:2024",
"ghcr.io/jmuchovej/latex-devcontainer:latest",
]
group "default" {
targets = [ "latex" ]
}

target "texlive2023" {
inherits = ["shared"]
args = {
TEXLIVE_VERSION = "2023"
CHKTEX_VERSION = "1.7.8"
VARIANT = "jammy"
}
labels = {
"org.opencontainers.image.title" = "LaTeX DevContainer with TeXLive 2023"
}
tags = [
"ghcr.io/jmuchovej/latex-devcontainer:2023",
]
}
repo = "https://github.com/jmuchovej/devcontainers"
template = "${repo}/tree/main/src/templates/latex"
image = "ghcr.io/jmuchovej/devcontainers/latex"

target "texlive2022" {
inherits = ["shared"]
args = {
TEXLIVE_VERSION = "2022"
CHKTEX_VERSION = "1.7.6"
VARIANT = "jammy"
}
labels = {
"org.opencontainers.image.title" = "LaTeX DevContainer with TeXLive 2022"
}
tags = [
"ghcr.io/jmuchovej/latex-devcontainer:2022",
target "latex" {
matrix = {
item = [
{texlive = "2024", chktex = "1.7.9", variant = "noble", },
{texlive = "2023", chktex = "1.7.8", variant = "jammy", },
{texlive = "2022", chktex = "1.7.6", variant = "jammy", },
]
}
name = "latex-v${replace(item.texlive, ".", "-")}"
context = "./"
dockerfile = "Dockerfile"
platforms = [ "linux/amd64", "linux/arm64", ]
args = {
VARIANT = item.variant
CHKTEX_VERSION = "${item.chktex}"
TEXLIVE_VERSION = "${item.texlive}"
}
labels = {
"org.opencontainers.image.source" = repo
"org.opencontainers.image.authors" = "John Muchovej <jmuchovej@pm.me>"
"org.opencontainers.image.url" = "${template}"
"org.opencontainers.image.documentation" = "${template}/README.md"
"org.opencontainers.image.title" = "LaTeX Devcontainer with TexLive ${item.texlive}"
}
tags = [ "${image}:${item.texlive}", LATEST == item.texlive ? "${image}:latest" : "", ]
}
7 changes: 0 additions & 7 deletions templates/src/typst/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ RUN cargo build --release
#region Output Stage ####################################################################
FROM mcr.microsoft.com/devcontainers/rust:${VARIANT} as output

LABEL org.opencontainers.image.authors "John Muchovej <jmuchovej@users.noreply.github.com>"
LABEL org.opencontainers.image.url "https://github.com/jmuchovej/devcontainers/tree/main/src/templates/typst"
LABEL org.opencontainers.image.documentation \
"https://github.com/jmuchovej/devcontainers/blob/main/src/templates/typst/README.md"
LABEL org.opencontainers.image.source \
"https://github.com/jmuchovej/devcontainers"

COPY --from=typst-builder /typst/target/release/typst /usr/local/bin/typst
# TODO add support for Typestyle (directly within the container)!
# COPY --from=typstyle-builder /typst/target/release/typstyle /usr/local/bin/typstyle
Expand Down
88 changes: 45 additions & 43 deletions templates/src/typst/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
//! How to edit this file:
// 1. In the `default` group (below), you should append `texlive-????` where `????` is
// the year you're adding.
// 2. You should copy the most recent `target` block and take care to update:
// 1. `TYPST_VERSION`
// https://github.com/typst/typst/releases
// 2. `VARIANT` <-- Use the latest Debian, but prefix with Rust major version!
// Cmd+F "rust-version" in https://github.com/typst/typst/blob/main/Cargo.toml
//! In the `matrix` component of the `target: "typst"` block, prepend a new object
//! with keys `{ typst = ????, typstyle = ????, variant = ????}`, then update the
//! `variable "LATEST"` block to a default value matching this new entry!
// What the variables in the object you're adding refer to!
// 1. `typst` <-- this is the year of TeXLive we're building!
// Releases here: https://github.com/typst/typst/releases/latest
// 2. `typstyle` <-- this is the version of `typstyle` to build
// Releases here: http://github.com/Enter-tainer/typstyle/releases/latest
// 3. `variant` <-- this is based on what `mcr.microsoft.com` publishes as the latest
// variant of Rust! see more:
// https://mcr.microsoft.com/en-us/product/devcontainers/rust/about#using_this_image
//* NOTE: this should be the latest Debian **prefixed with the _major version_**
//* found in typst's `Cargo.toml`!
//* Cmd+F "rust-version" in https://github.com/typst/typst/blob/main/Cargo.toml

group "default" {
targets = [
"typst-v0-11-1",
"typst-v0-11-0",
]
variable "LATEST" {
type = string
default = "0.11.1"
}

target "shared" {
context = "./"
dockerfile = "Dockerfile"
platforms = [ "linux/amd64", "linux/arm64", ]
group "default" {
targets = [ "typst" ]
}

target "typst-v0-11-1" {
inherits = ["shared"]
args = {
TYPST_VERSION = "v0.11.1"
TYPSTYLE_VERSION = "v0.11.32"
VARIANT = "1-bookworm"
}
labels = {
"org.opencontainers.image.title" = "Typst v0.11.1"
}
tags = [
"ghcr.io/jmuchovej/typst-devcontainer:0.11.1",
"ghcr.io/jmuchovej/typst-devcontainer:latest",
]
}
repo = "https://github.com/jmuchovej/devcontainers"
template = "${repo}/tree/main/src/templates/typst"
iamge = "ghcr.io/jmuchovej/devcontainers/typst"

target "typst-v0-11-0" {
inherits = ["shared"]
args = {
TYPST_VERSION = "v0.11.0"
TYPSTYLE_VERSION = "v0.11.20"
VARIANT = "1-bookworm"
}
labels = {
"org.opencontainers.image.title" = "Typst v0.11.0"
}
tags = [
"ghcr.io/jmuchovej/typst-devcontainer:0.11.0",
target "typst" {
matrix = {
item = [
{typst = "0.11.1", typstyle = "0.11.32", variant = "1-bookworm", },
{typst = "0.11.0", typstyle = "0.11.20", variant = "1-bookworm", },
]
}
name = "typst-v${replace(item.typst, ".", "-")}"
context = "./"
dockerfile = "Dockerfile"
platforms = [ "linux/amd64", "linux/arm64", ]
args = {
VARIANT = item.variant
TYPST_VERSION = "v${item.typst}"
TYPSTYLE_VERSION = "v${item.typstyle}"
}
labels = {
"org.opencontainers.image.source" = repo
"org.opencontainers.image.authors" = "John Muchovej <jmuchovej@pm.me>"
"org.opencontainers.image.url" = "${template}"
"org.opencontainers.image.documentation" = "${template}/README.md"
"org.opencontainers.image.title" = "Typst v${item.typst}"
}
tags = [ "${image}:${item.typst}", LATEST == item.typst ? "${image}:latest" : "", ]
}
Loading