Skip to content

Commit d873179

Browse files
committed
Added decent latex image
1 parent b48d9ba commit d873179

File tree

4 files changed

+311
-0
lines changed

4 files changed

+311
-0
lines changed

.github/workflows/build-latex.yaml

+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: build_push_decent_latex_img
2+
3+
4+
on:
5+
release:
6+
types: [published]
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- LaTex/**
12+
- .github/workflows/build-latex.yaml
13+
14+
15+
jobs:
16+
build_decent_latex_amd64:
17+
name: Build and publish Decent LaTex image (amd64)
18+
runs-on: ubuntu-24.04
19+
permissions:
20+
packages: write
21+
contents: read
22+
23+
steps:
24+
- name: Check out the repo
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
30+
- name: Log in to the Container registry
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Generate package repo name
38+
id: ghcr_repo
39+
run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-latex" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT
40+
41+
- name: Extract metadata (tags, labels) for Docker
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: |
46+
${{ steps.ghcr_repo.outputs.path }}
47+
48+
- name: Get current commit SHA short
49+
id: commit_sha
50+
run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT
51+
52+
- name: Manually generate sha tag
53+
id: tag_sha
54+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT
55+
56+
- name: Manually generate head tag
57+
id: tag_head
58+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:head" >> $GITHUB_OUTPUT
59+
60+
- name: Manually generate ver tag
61+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
62+
id: tag_ver
63+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
64+
65+
- name: Build and push Docker images for each commit
66+
uses: docker/build-push-action@v5
67+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
68+
with:
69+
context: ./LaTex
70+
platforms: linux/amd64
71+
push: true
72+
tags: |
73+
${{ steps.tag_sha.outputs.tag }}-amd64
74+
${{ steps.tag_head.outputs.tag }}-amd64
75+
labels: ${{ steps.meta.outputs.labels }}
76+
77+
- name: Create and push a manifest with ver referencing version
78+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
79+
run: |
80+
docker buildx imagetools create \
81+
-t ${{ steps.tag_ver.outputs.tag }}-amd64 \
82+
${{ steps.tag_head.outputs.tag }}-amd64
83+
84+
85+
build_decent_latex_arm64:
86+
name: Build and publish Decent LaTex image (arm64)
87+
runs-on: ubuntu-24.04-arm
88+
permissions:
89+
packages: write
90+
contents: read
91+
92+
steps:
93+
- name: Check out the repo
94+
uses: actions/checkout@v4
95+
96+
- name: Set up Docker Buildx
97+
uses: docker/setup-buildx-action@v2
98+
99+
- name: Log in to the Container registry
100+
uses: docker/login-action@v3
101+
with:
102+
registry: ghcr.io
103+
username: ${{ github.actor }}
104+
password: ${{ secrets.GITHUB_TOKEN }}
105+
106+
- name: Generate package repo name
107+
id: ghcr_repo
108+
run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-latex" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT
109+
110+
- name: Extract metadata (tags, labels) for Docker
111+
id: meta
112+
uses: docker/metadata-action@v5
113+
with:
114+
images: |
115+
${{ steps.ghcr_repo.outputs.path }}
116+
117+
- name: Get current commit SHA short
118+
id: commit_sha
119+
run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT
120+
121+
- name: Manually generate sha tag
122+
id: tag_sha
123+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT
124+
125+
- name: Manually generate head tag
126+
id: tag_head
127+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:head" >> $GITHUB_OUTPUT
128+
129+
- name: Manually generate ver tag
130+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
131+
id: tag_ver
132+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
133+
134+
- name: Build and push Docker images for each commit
135+
uses: docker/build-push-action@v5
136+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
137+
with:
138+
context: ./LaTex
139+
platforms: linux/arm64
140+
push: true
141+
tags: |
142+
${{ steps.tag_sha.outputs.tag }}-arm64
143+
${{ steps.tag_head.outputs.tag }}-arm64
144+
labels: ${{ steps.meta.outputs.labels }}
145+
146+
- name: Create and push a manifest with ver referencing version
147+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
148+
run: |
149+
docker buildx imagetools create \
150+
-t ${{ steps.tag_ver.outputs.tag }}-arm64 \
151+
${{ steps.tag_head.outputs.tag }}-arm64
152+
153+
154+
push_multi_arch_manifest:
155+
name: Push Docker multi-arch manifest to Container registry
156+
needs: [build_decent_latex_amd64, build_decent_latex_arm64]
157+
runs-on: ubuntu-24.04
158+
permissions:
159+
packages: write
160+
contents: read
161+
162+
steps:
163+
- name: Check out the repo
164+
uses: actions/checkout@v4
165+
166+
- name: Set up Docker Buildx
167+
uses: docker/setup-buildx-action@v2
168+
169+
- name: Log in to the Container registry
170+
uses: docker/login-action@v3
171+
with:
172+
registry: ghcr.io
173+
username: ${{ github.actor }}
174+
password: ${{ secrets.GITHUB_TOKEN }}
175+
176+
- name: Generate package repo name
177+
id: ghcr_repo
178+
run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-latex" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT
179+
180+
- name: Extract metadata (tags, labels) for Docker
181+
id: meta
182+
uses: docker/metadata-action@v5
183+
with:
184+
images: |
185+
${{ steps.ghcr_repo.outputs.path }}
186+
187+
- name: Get current commit SHA short
188+
id: commit_sha
189+
run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT
190+
191+
- name: Manually generate sha tag
192+
id: tag_sha
193+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT
194+
195+
- name: Manually generate head tag
196+
id: tag_head
197+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:head" >> $GITHUB_OUTPUT
198+
199+
- name: Manually generate ver tag
200+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
201+
id: tag_ver
202+
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
203+
204+
- name: Create and push a manifest referencing git sha
205+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
206+
run: |
207+
docker buildx imagetools create \
208+
-t ${{ steps.tag_sha.outputs.tag }} \
209+
${{ steps.tag_sha.outputs.tag }}-arm64 \
210+
${{ steps.tag_sha.outputs.tag }}-amd64
211+
212+
- name: Create and push a manifest referencing git head
213+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
214+
run: |
215+
docker buildx imagetools create \
216+
-t ${{ steps.tag_head.outputs.tag }} \
217+
${{ steps.tag_head.outputs.tag }}-arm64 \
218+
${{ steps.tag_head.outputs.tag }}-amd64
219+
220+
- name: Create and push a manifest with ver referencing version
221+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
222+
run: |
223+
docker buildx imagetools create \
224+
-t ${{ steps.tag_ver.outputs.tag }} \
225+
${{ steps.tag_ver.outputs.tag }}-arm64 \
226+
${{ steps.tag_ver.outputs.tag }}-amd64
227+

LaTex/Dockerfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (c) 2024 Haofan Zheng
2+
# Use of this source code is governed by an MIT-style
3+
# license that can be found in the LICENSE file or at
4+
# https://opensource.org/licenses/MIT.
5+
6+
FROM ghcr.io/lsd-ucsc/decent-latex-base:c2c70fc
7+
8+
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
12+
############################### Install packages ###############################
13+
14+
RUN apt-get update -y && \
15+
apt-get install -y \
16+
libgtk-3-0t64 \
17+
libnotify4 \
18+
libnss3 \
19+
libxss1 \
20+
libxtst6 \
21+
xdg-utils \
22+
libatspi2.0-0t64 \
23+
libsecret-1-0 \
24+
libasound2t64 \
25+
xvfb \
26+
git \
27+
sudo
28+
29+
# clean up
30+
RUN apt-get clean && \
31+
apt-get autoremove -y && \
32+
apt-get autoclean -y
33+
34+
35+
################################ Install DrawIO ################################
36+
37+
COPY install-drawio.sh install-drawio.sh
38+
RUN chmod 755 install-drawio.sh
39+
RUN ./install-drawio.sh
40+
RUN rm install-drawio.sh
41+
42+
COPY drawio-cli /usr/bin/drawio-cli
43+
RUN chmod 755 /usr/bin/drawio-cli
44+
45+
################################ Install LaTex #################################
46+

LaTex/drawio-cli

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DRAWIO_BIN=/usr/bin/drawio
6+
XVFB_RUN_BIN=/usr/bin/xvfb-run
7+
8+
if [ -z $DRAWIO_BIN ]; then
9+
echo "Failed to run Drawio - drawio is not installed."
10+
exit -1
11+
fi
12+
if [ -z $XVFB_RUN_BIN ]; then
13+
echo "Failed to run Drawio - xvfb is not installed."
14+
exit -1
15+
fi
16+
17+
$XVFB_RUN_BIN -a $DRAWIO_BIN "$@"
18+

LaTex/install-drawio.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DRAWIO_VERSION="26.0.4"
6+
ARCH_NAME=$(uname -m)
7+
if [ "$ARCH_NAME" == "x86_64" ]; then
8+
ARCH_NAME="amd64"
9+
elif [ "$ARCH_NAME" == "aarch64" ]; then
10+
ARCH_NAME="arm64"
11+
fi
12+
13+
14+
# Download and install draw.io
15+
curl -o drawio-${ARCH_NAME}-${DRAWIO_VERSION}.deb \
16+
-fSL \
17+
https://github.com/jgraph/drawio-desktop/releases/download/v${DRAWIO_VERSION}/drawio-${ARCH_NAME}-${DRAWIO_VERSION}.deb
18+
dpkg -i ./drawio-${ARCH_NAME}-${DRAWIO_VERSION}.deb
19+
rm drawio-${ARCH_NAME}-${DRAWIO_VERSION}.deb
20+

0 commit comments

Comments
 (0)