Skip to content

Commit d5e54f7

Browse files
CI & Docker: Update
1 parent 2a2e2fc commit d5e54f7

File tree

3 files changed

+83
-52
lines changed

3 files changed

+83
-52
lines changed

.docker/Dockerfile

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
# Stage 1: TeX Live Base
2-
FROM alpine:latest AS builder-texlive
3-
4-
RUN apk add --no-cache git bash wget perl # Perl is required by tlmgr
5-
6-
# Install TeX Live and set PATH in one step
7-
RUN apk add --no-cache texlive texlive-full --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/main \
8-
&& echo "/usr/local/texlive/2024/bin/x86_64-linux:$PATH" > /etc/profile.d/texlive.sh
1+
# Stage 1: Builder with all necessary packages
2+
FROM alpine:latest AS builder
3+
4+
# Install build dependencies
5+
RUN apk add --no-cache \
6+
texlive \
7+
texlive-xetex \
8+
texmf-dist \
9+
texmf-dist-latexextra \
10+
texmf-dist-fontsextra \
11+
perl \
12+
fontconfig \
13+
make
14+
15+
# Stage 2: Final image with only runtime dependencies
16+
FROM alpine:latest
917

10-
# Stage 2: Fonts and Packages
11-
FROM builder-texlive AS builder-fonts
18+
# Install only runtime dependencies
19+
RUN apk add --no-cache \
20+
texlive-xetex \
21+
texmf-dist \
22+
fontconfig
1223

13-
RUN tlmgr install xcharter enumitem hyperref titlesec xstring geometry fancyhdr etoolbox
14-
15-
# Stage 3: Final Image
16-
FROM alpine:latest
24+
# Copy necessary files from builder
25+
COPY --from=builder /usr/share/texmf-dist /usr/share/texmf-dist
26+
COPY --from=builder /usr/share/texlive /usr/share/texlive
27+
COPY --from=builder /var/lib/texmf /var/lib/texmf
1728

1829
WORKDIR /latex
1930

20-
# Copy necessary files
21-
COPY --from=builder-fonts /usr/local/texlive/2024/texmf-dist /usr/local/texlive/2024/texmf-dist
22-
COPY --from=builder-fonts /usr/local/texlive/2024/bin/x86_64-linux/xelatex /usr/local/texlive/2024/bin/x86_64-linux/xelatex
23-
COPY --from=builder-fonts /usr/local/texlive/2024/bin/x86_64-linux/latexmk /usr/local/texlive/2024/bin/x86_64-linux/latexmk
24-
25-
# No need to set PATH again, it's already set in Stage 1
31+
# Copy your LaTeX files
2632
COPY entrypoint.sh /entrypoint.sh
27-
COPY *.tex *.bib *.cls /latex/
33+
COPY *.tex *.cls *.sty ./
34+
2835
RUN chmod +x /entrypoint.sh
2936

3037
ENTRYPOINT ["/entrypoint.sh"]

.docker/entrypoint.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
set -e
33

4-
INPUT_FILE="$1"
5-
OUTPUT_NAME="${2:-output.pdf}" # Default to output.pdf if no name specified
4+
# Create output directory
5+
mkdir -p /latex/output
66

7-
# Compile the LaTeX document
8-
latexmk -pdf "$INPUT_FILE"
7+
# Run XeLaTeX with proper output name
8+
xelatex -interaction=nonstopmode \
9+
-output-directory=/latex/output \
10+
-jobname="Anish_Shobith_P_S_Resume" \
11+
"main.tex"
912

10-
# Get the base name of the input file without extension
11-
BASE_NAME=$(basename "$INPUT_FILE" .tex)
13+
# Run again if needed for references
14+
if grep -q "Rerun to get" "/latex/output/Anish_Shobith_P_S_Resume.log"; then
15+
xelatex -interaction=nonstopmode \
16+
-output-directory=/latex/output \
17+
-jobname="Anish_Shobith_P_S_Resume" \
18+
"main.tex"
19+
fi
1220

13-
# Rename the output file
14-
mv "${BASE_NAME}.pdf" "$OUTPUT_NAME"
21+
# Copy the final PDF to the mounted volume
22+
cp /latex/output/Anish_Shobith_P_S_Resume.pdf /latex/

.github/workflows/release.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ name: Build and Release Resume
33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- '**.tex'
8+
- '**.cls'
9+
- '**.sty'
10+
- '.docker/**'
611
workflow_dispatch:
712

813
jobs:
914
build:
1015
runs-on: ubuntu-latest
1116
permissions:
1217
contents: write
13-
id-token: write
14-
actions: write
1518
packages: write
1619

1720
steps:
@@ -20,49 +23,62 @@ jobs:
2023

2124
- name: Set up Docker Buildx
2225
uses: docker/setup-buildx-action@v3
26+
with:
27+
platforms: linux/amd64
28+
driver-opts: |
29+
image=moby/buildkit:master
30+
network=host
2331
24-
- name: Login to GitHub Container Registry
32+
- name: Login to GHCR
2533
uses: docker/login-action@v3
2634
with:
2735
registry: ghcr.io
2836
username: ${{ github.actor }}
2937
password: ${{ secrets.GITHUB_TOKEN }}
3038

39+
- name: Cache Docker layers
40+
uses: actions/cache@v3
41+
with:
42+
path: /tmp/.buildx-cache
43+
key: ${{ runner.os }}-buildx-${{ github.sha }}
44+
restore-keys: |
45+
${{ runner.os }}-buildx-
46+
3147
- name: Build and push Docker image
3248
uses: docker/build-push-action@v5
3349
with:
3450
context: .docker
3551
push: true
3652
tags: ghcr.io/${{ github.repository }}/latex-builder:latest
37-
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:latest
38-
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:latest,mode=max
53+
cache-from: |
54+
type=local,src=/tmp/.buildx-cache
55+
type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:latest
56+
cache-to: |
57+
type=local,dest=/tmp/.buildx-cache-new,mode=max
58+
type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:latest,mode=max
59+
build-args: |
60+
BUILDKIT_INLINE_CACHE=1
3961
40-
- name: Build LaTeX document
62+
- name: Move cache
4163
run: |
42-
docker run --rm -v ${{ github.workspace }}:/latex \
43-
ghcr.io/${{ github.repository }}/latex-builder:latest \
44-
/latex/entrypoint.sh "Anish_Shobith_P_S_Resume.pdf"
64+
rm -rf /tmp/.buildx-cache
65+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
4566
46-
- name: Combine Metadata
47-
id: metadata
67+
- name: Build LaTeX document
4868
run: |
49-
echo "date=$(date +'%d-%m-%Y')" >> $GITHUB_OUTPUT
50-
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
69+
mkdir -p output
70+
docker run --rm -v ${{ github.workspace }}:/latex \
71+
ghcr.io/${{ github.repository }}/latex-builder:latest
5172
5273
- name: Create Release
5374
if: github.ref == 'refs/heads/main'
5475
uses: softprops/action-gh-release@v2
5576
with:
56-
draft: false
57-
prerelease: false
58-
tag_name: v${{ steps.metadata.outputs.date }}
59-
name: "Resume Update ${{ steps.metadata.outputs.date }}"
77+
tag_name: v$(date +'%Y.%m.%d')
78+
name: "Resume Update $(date +'%Y.%m.%d')"
6079
body: |
61-
📄 Resume update for ${{ steps.metadata.outputs.date }}
80+
📄 Resume update $(date +'%Y.%m.%d')
6281
63-
**Commit**: ${{ steps.metadata.outputs.sha }}
82+
**Commit**: ${{ github.sha }}
6483
**Branch**: main
65-
66-
[View PDF](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.date }}/Anish_Shobith_P_S_Resume.pdf)
6784
files: Anish_Shobith_P_S_Resume.pdf
68-
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)