-
Notifications
You must be signed in to change notification settings - Fork 134
feat(templates): add docker-texlive template with code-server #828
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
Open
joergklein
wants to merge
24
commits into
coder:main
Choose a base branch
from
joergklein:feat/docker-texlive-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b6ce198
feat(templates): add docker-texlive template with code-server
joergklein 3ff24f1
refactor: move template to registry/joergklein/templates/docker-texlive
blink-so[bot] d398760
Update README.md
joergklein d0de2f7
Merge branch 'coder:main' into feat/docker-texlive-template
joergklein d44aec5
Add an avatar
joergklein c416ee4
chore: replace texlive.svg with PNG icon from TeX Live GitHub avatar
blink-so[bot] bae66fb
Apply suggestion from @matifali
DevelopmentCats 5c2ea35
Merge branch 'coder:main' into feat/docker-texlive-template
joergklein 1ddea10
- Multiple workspaces on the same host
joergklein 6b00883
Update main.tf
joergklein 1c0048a
Update README.md
joergklein 8ae183d
Merge branch 'coder:main' into feat/docker-texlive-template
joergklein 26c8168
Update Dockerfile
joergklein b38d2d9
format the files
joergklein 0b5df32
Merge branch 'coder:main' into feat/docker-texlive-template
joergklein ea3c48a
Extensions, the "settings.json" file, and the TeX Live projects are n…
joergklein dd646d7
Merge branch 'coder:main' into feat/docker-texlive-template
joergklein 6a87711
Update Dockerfile
joergklein 16db072
Update main.tf
joergklein ade2024
Update Dockerfile
joergklein 4555692
fix: formatting, avatar path, image name, and remove timestamp from i…
DevelopmentCats 2658d3d
fix: restore section comments removed in previous commit
DevelopmentCats 16e2169
fix: move texlive icon to .icons/ and update README to reference it
DevelopmentCats 0bd2ca6
fix: replace texlive.png with SVG icon and update README reference
DevelopmentCats File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| display_name: "Jörg Klein" | ||
| bio: "Data Scientists" | ||
| github: "joergklein" | ||
| avatar: "./.images/avatar.jpg" | ||
| status: "community" | ||
| --- | ||
|
|
||
| # Jörg Klein | ||
|
|
||
| Data Scientists |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| --- | ||
| display_name: Docker TeX Live | ||
| description: Provision Docker containers with TeX Live, code-server | ||
| icon: ../../../../.icons/texlive.svg | ||
| tags: [docker, texlive] | ||
| --- | ||
|
|
||
| # TeX Live Development on Docker Containers | ||
|
|
||
| Provision Docker containers pre-configured for TeX development as [Coder workspaces](https://coder.com/docs/workspaces) with this template. | ||
|
|
||
| Each workspace comes with: | ||
|
|
||
| - **TeX Live** — TeX Live is a comprehensive, cross-platform distribution for TeX and LaTeX systems that provides all necessary programs, macro packages, and fonts for professional typesetting. | ||
| - **code-server** — VS Code in the browser for general editing. | ||
|
|
||
| The workspace is based on the [TeX Live](https://www.tug.org/texlive) image. It provides nearly all packages from the [Comprehensive TeX Archive Network (CTAN)](https://www.ctan.org), although some non-free packages may be restricted. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Infrastructure | ||
|
|
||
| #### Running Coder inside Docker | ||
|
|
||
| If you installed Coder as a container within Docker, you will have to do the following things: | ||
|
|
||
| - Make the Docker socket available to the container | ||
| - **(recommended) Mount `/var/run/docker.sock` via `--mount`/`volume`** | ||
| - _(advanced) Restrict the Docker socket via https://github.com/Tecnativa/docker-socket-proxy_ | ||
| - Set `--group-add`/`group_add` to the GID of the Docker group on the **host** machine | ||
| - You can get the GID by running `getent group docker` on the **host** machine | ||
|
|
||
| #### Running Coder outside of Docker | ||
|
|
||
| If you installed Coder as a system package, the VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group: | ||
|
|
||
| ```bash | ||
| # Add coder user to Docker group | ||
| sudo adduser coder docker | ||
|
|
||
| # Restart Coder server | ||
| sudo systemctl restart coder | ||
|
|
||
| # Test Docker | ||
| sudo -u coder docker ps | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| This template provisions the following resources: | ||
|
|
||
| - Docker image (built from `build/Dockerfile`, extending `registry.gitlab.com/islandoftex/images/texlive` with system dependencies) | ||
| - Docker container (ephemeral — destroyed on workspace stop) | ||
| - Docker volume (persistent on `/home/texlive`) | ||
|
|
||
| When the workspace restarts, tools and files outside `/home/texlive` are not persisted. | ||
|
|
||
| > [!NOTE] | ||
| > This template is designed to be a starting point! Edit the Terraform to extend it for your use case. | ||
|
|
||
| ## Customization | ||
|
|
||
| The continuous integration is scheduled to rebuild all Docker images weekly. Hence, pulling the latest image will provide you with an at most one week old snapshot of TeX Live including all packages. You can manually update within the container by running `tlmgr update --self --all`. | ||
|
|
||
| Each of the weekly builds is tagged with `TL{RELEASE}-{YEAR}-{MONTH}-{DAY}-{HOUR}-{MINUTE}` apart from being latest for one week. If you want to have reproducible builds or happen to find a regression in a later image you can still revert to a date that worked, e.g. `TL2019-2019-08-01-08-14 or latest`. | ||
|
|
||
| - [Container Registry TeX Live](https://gitlab.com/islandoftex/images/texlive/container_registry) | ||
| - [Dockerhub TeX Live](https://hub.docker.com/r/texlive/texlive) | ||
|
|
||
| ### Installing additional TeX packages | ||
|
|
||
| If you want to update packages from CTAN after installation, see these [examples of using tlmgr](https://tug.org/texlive/doc/tlmgr.html#EXAMPLES). This is not required, or even necessarily recommended; it's up to you to decide if it makes sense to get continuing updates in your particular situation. | ||
|
|
||
| Typically the main binaries are not updated in TeX Live between major releases. If you want to get updates for LuaTeX and other packages and programs that aren't officially released yet, they may be available in the [TLContrib repository](http://contrib.texlive.info), or you may need to [compile the sources](https://tug.org/texlive/svn) yourself. | ||
|
|
||
| ### Adding system dependencies | ||
|
|
||
| The `build/Dockerfile` extends the `registry.gitlab.com/islandoftex/images/texlive` base image with system packages required by modules (e.g. `curl` for code-server). If you add modules that need additional system-level tools, add them to the `Dockerfile`: | ||
|
|
||
| ```dockerfile | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| curl \ | ||
| inkscape \ | ||
| unzip \ | ||
| vim \ | ||
| wget \ | ||
| your-package-here \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| ``` |
29 changes: 29 additions & 0 deletions
29
registry/joergklein/templates/docker-texlive/build/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| ARG TEXLIVE_VERSION=latest | ||
| FROM registry.gitlab.com/islandoftex/images/texlive:${TEXLIVE_VERSION} | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| curl \ | ||
| inkscape \ | ||
| unzip \ | ||
| vim \ | ||
| wget \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| ENV LANG=C.UTF-8 | ||
| ENV LC_ALL=C.UTF-8 | ||
|
|
||
| RUN useradd -m -s /bin/bash texlive || true | ||
|
|
||
| ENV HOME=/home/texlive | ||
|
|
||
| ENV TEXMFCNF=/home/texlive/texmf/web2c:/usr/local/texlive/2026/texmf-dist/web2c | ||
|
|
||
| RUN mkdir -p /home/texlive/texmf/web2c \ | ||
| && echo "save_size = 300000" >/home/texlive/texmf/web2c/texmf.cnf \ | ||
| && chown -R texlive:texlive /home/texlive | ||
|
|
||
| USER texlive | ||
| WORKDIR /home/texlive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| terraform { | ||
| required_providers { | ||
| coder = { | ||
| source = "coder/coder" | ||
| } | ||
| docker = { | ||
| source = "kreuzwerker/docker" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # ------------------------- | ||
| # Variables | ||
| # ------------------------- | ||
| variable "docker_socket" { | ||
| type = string | ||
| default = "" | ||
| } | ||
|
|
||
| variable "texlive_version" { | ||
| type = string | ||
| default = "latest" | ||
| } | ||
|
|
||
| # ------------------------- | ||
| # Provider | ||
| # ------------------------- | ||
| provider "docker" { | ||
| host = var.docker_socket != "" ? var.docker_socket : null | ||
| } | ||
|
|
||
| # ------------------------- | ||
| # Coder data | ||
| # ------------------------- | ||
| data "coder_provisioner" "me" {} | ||
| data "coder_workspace" "me" {} | ||
| data "coder_workspace_owner" "me" {} | ||
|
|
||
| # ------------------------- | ||
| # Locals | ||
| # ------------------------- | ||
| locals { | ||
| username = try(data.coder_workspace_owner.me.name, "unknown") | ||
| start_count = try(data.coder_workspace.me.start_count, 0) | ||
|
|
||
| build_context_hash = sha1(join("", [ | ||
| for f in fileset("${path.module}/build", "**") : | ||
| try(filesha1("${path.module}/build/${f}"), "") | ||
| ])) | ||
| } | ||
|
|
||
| # ------------------------- | ||
| # Coder Agent | ||
| # ------------------------- | ||
| resource "coder_agent" "main" { | ||
| arch = try(data.coder_provisioner.me.arch, "x86_64") | ||
| os = "linux" | ||
|
|
||
| startup_script = <<-EOT | ||
| set -e | ||
| touch ~/.init_done | ||
| EOT | ||
|
|
||
| env = { | ||
| HOME = "/home/texlive" | ||
| USER = "texlive" | ||
| LANG = "C.UTF-8" | ||
| LC_ALL = "C.UTF-8" | ||
|
|
||
| GIT_AUTHOR_NAME = coalesce(try(data.coder_workspace_owner.me.full_name, ""), local.username) | ||
| GIT_AUTHOR_EMAIL = try(data.coder_workspace_owner.me.email, "unknown@example.com") | ||
| } | ||
|
|
||
| metadata { | ||
| display_name = "CPU" | ||
| key = "cpu" | ||
| script = "coder stat cpu" | ||
| interval = 10 | ||
| timeout = 1 | ||
| } | ||
|
|
||
| metadata { | ||
| display_name = "RAM" | ||
| key = "ram" | ||
| script = "coder stat mem" | ||
| interval = 10 | ||
| timeout = 1 | ||
| } | ||
|
|
||
| metadata { | ||
| display_name = "Disk" | ||
| key = "disk" | ||
| script = "coder stat disk --path $${HOME}" | ||
| interval = 60 | ||
| timeout = 1 | ||
| } | ||
| } | ||
|
|
||
| # ------------------------- | ||
| # Code Server | ||
| # ------------------------- | ||
| module "code-server" { | ||
| count = local.start_count | ||
| source = "registry.coder.com/coder/code-server/coder" | ||
| version = "~> 1.0" | ||
|
|
||
| agent_id = coder_agent.main.id | ||
| folder = "/home/texlive" | ||
| } | ||
|
|
||
| # ------------------------- | ||
| # Docker Image | ||
| # ------------------------- | ||
| resource "docker_image" "texlive" { | ||
| name = "coder-${data.coder_workspace.me.id}-texlive" | ||
|
|
||
| build { | ||
| context = "${path.module}/build" | ||
| dockerfile = "Dockerfile" | ||
|
|
||
| build_args = { | ||
| TEXLIVE_VERSION = var.texlive_version | ||
| } | ||
| } | ||
|
|
||
| keep_locally = false | ||
|
|
||
| triggers = { | ||
| dir_hash = local.build_context_hash | ||
| texlive_version = var.texlive_version | ||
| } | ||
| } | ||
joergklein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # ------------------------- | ||
| # Volume (correct docker provider syntax) | ||
| # ------------------------- | ||
| resource "docker_volume" "home_volume" { | ||
| name = "coder-${try(data.coder_workspace.me.id, 0)}-home" | ||
|
|
||
| labels { | ||
| label = "coder.owner" | ||
| value = local.username | ||
| } | ||
|
|
||
| labels { | ||
| label = "coder.workspace_id" | ||
| value = try(data.coder_workspace.me.id, "0") | ||
| } | ||
|
|
||
| labels { | ||
| label = "coder.workspace_name" | ||
| value = try(data.coder_workspace.me.name, "workspace") | ||
| } | ||
|
|
||
| lifecycle { | ||
| ignore_changes = all | ||
| } | ||
| } | ||
|
|
||
| # ------------------------- | ||
| # Container | ||
| # ------------------------- | ||
| resource "docker_container" "workspace" { | ||
| count = local.start_count | ||
|
|
||
| image = docker_image.texlive.image_id | ||
| name = "coder-${local.username}-${lower(try(data.coder_workspace.me.name, "workspace"))}" | ||
| hostname = try(data.coder_workspace.me.name, "workspace") | ||
|
|
||
| entrypoint = [ | ||
| "sh", | ||
| "-c", | ||
| coder_agent.main.init_script | ||
| ] | ||
|
|
||
| env = [ | ||
| "CODER_AGENT_TOKEN=${coder_agent.main.token}" | ||
| ] | ||
|
|
||
| host { | ||
| host = "host.docker.internal" | ||
| ip = "host-gateway" | ||
| } | ||
|
|
||
| volumes { | ||
| container_path = "/home/texlive" | ||
| volume_name = docker_volume.home_volume.name | ||
| read_only = false | ||
| } | ||
|
|
||
| labels { | ||
| label = "coder.owner" | ||
| value = local.username | ||
| } | ||
|
|
||
| labels { | ||
| label = "coder.workspace_id" | ||
| value = try(data.coder_workspace.me.id, "0") | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.