Skip to content

Commit b634d96

Browse files
committed
Added decent latex devcontainer image
1 parent d873179 commit b634d96

File tree

2 files changed

+275
-0
lines changed

2 files changed

+275
-0
lines changed
+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: build_push_decent_latex_dev_img
2+
3+
4+
on:
5+
release:
6+
types: [published]
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- LaTexDev/**
12+
- .github/workflows/build-latex-dev.yaml
13+
14+
15+
jobs:
16+
build_decent_latex_dev_amd64:
17+
name: Build and publish Decent LaTex DevContainer 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-dev" | 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: ./LaTexDev
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_dev_arm64:
86+
name: Build and publish Decent LaTex DevContainer 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-dev" | 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: ./LaTexDev
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_dev_amd64, build_decent_latex_dev_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-dev" | 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+

LaTexDev/Dockerfile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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:d873179
7+
8+
9+
################################ Setup Root User ###############################
10+
11+
RUN cp /etc/skel/.bashrc /root/.bashrc && \
12+
cp /etc/skel/.profile /root/.profile && \
13+
cp /etc/skel/.bash_logout /root/.bash_logout
14+
15+
################################ Setup Dev User ################################
16+
17+
RUN deluser --remove-home ubuntu
18+
19+
ARG DEV_USERNAME=vscode
20+
ARG DEV_USERID=1000
21+
ARG DEV_GROUPNAME=${DEV_USERNAME}
22+
ARG DEV_GROUPID=${DEV_USERID}
23+
24+
RUN mkdir -p /home/${DEV_USERNAME}/workspace && \
25+
cp /etc/skel/.bashrc /home/${DEV_USERNAME}/.bashrc && \
26+
cp /etc/skel/.profile /home/${DEV_USERNAME}/.profile && \
27+
cp /etc/skel/.bash_logout /home/${DEV_USERNAME}/.bash_logout
28+
29+
# backup the original /etc/passwd, /etc/group, and /etc/shadow
30+
RUN cp /etc/passwd /etc/passwd.decent.bak && \
31+
cp /etc/group /etc/group.decent.bak && \
32+
cp /etc/shadow /etc/shadow.decent.bak
33+
34+
# Create the user
35+
RUN groupadd --gid $DEV_GROUPID $DEV_GROUPNAME \
36+
&& useradd \
37+
--shell /bin/bash \
38+
--home-dir /home/${DEV_USERNAME} \
39+
--no-create-home \
40+
--uid $DEV_USERID \
41+
--gid $DEV_GROUPID \
42+
$DEV_USERNAME \
43+
&& echo $DEV_USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$DEV_USERNAME \
44+
&& chmod 0440 /etc/sudoers.d/$DEV_USERNAME \
45+
&& chown -R $DEV_USERNAME:$DEV_GROUPNAME /home/${DEV_USERNAME}
46+
47+
48+
USER $DEV_USERNAME

0 commit comments

Comments
 (0)