From b67dbc26cd90c6e1d7a271968b738a092fb0c64b Mon Sep 17 00:00:00 2001 From: anishshobithps Date: Sun, 12 Jan 2025 04:06:36 +0530 Subject: [PATCH] CI: update stuff --- .docker/Dockerfile | 31 ++++++++++++++++++++++--------- .github/workflows/release.yml | 21 ++------------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index a8d676e..89b3f38 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,18 +1,31 @@ -FROM ubuntu:22.04 +# Stage 1: Install TeX Live and dependencies (Cached) +FROM alpine:latest AS builder -# Avoid prompts from apt -ENV DEBIAN_FRONTEND=noninteractive +# Install system dependencies (these rarely change) +RUN apk add --no-cache git bash wget -# Install required packages -RUN apt-get update && apt-get install -y \ - texlive-full \ +# Install texlive and other tex related packages to cache +RUN apk add --no-cache \ + texlive \ + texlive-latex \ + texlive-latex-extra \ + texlive-fonts-extra \ + texlive-xetex \ + texlive-bibtex-extra \ latexmk \ - && rm -rf /var/lib/apt/lists/* + --repository=http://dl-cdn.alpinelinux.org/alpine/v3.18/main + +# Stage 2: Final Image (Smaller and Faster) +FROM alpine:latest -# Create a working directory WORKDIR /latex -# Copy compilation script +# Copy only the necessary parts of TeX Live +COPY --from=builder /usr/share/texmf-dist /usr/share/texmf-dist +COPY --from=builder /usr/bin/latexmk /usr/bin/latexmk +COPY --from=builder /usr/bin/xelatex /usr/bin/xelatex + +# Copy your project files AFTER the TeX Live setup COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9a6d9e..8a4cd89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,21 +22,10 @@ jobs: id: changes run: | CHANGED=0 - # Fetch the latest changes git fetch origin main - - # Check if there are more than one commit to compare against - if [ "$(git rev-list --count HEAD)" -gt 1 ]; then - # Ensure that there is more than 1 commit in the history - if git diff --name-only HEAD^ HEAD | grep -E "^(.docker/|.*\.(tex|sty|cls)$)" > /dev/null; then + if [[ $(git diff --name-only origin/main HEAD) =~ ^(\.docker\/|.*\.tex$|.*\.sty$|.*\.cls$) ]]; then CHANGED=1 - fi - else - # If there's no previous commit (only 1 commit), assume no changes to the relevant files - echo "Only one commit or no previous commit, skipping change check." - CHANGED=0 fi - echo "changed=${CHANGED}" >> $GITHUB_OUTPUT - name: Set up Docker @@ -58,15 +47,9 @@ jobs: context: .docker push: true tags: ghcr.io/${{ github.repository }}/latex-builder:latest - cache-from: | - type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:buildcache - type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:latest + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:(buildcache,latest) cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/latex-builder:buildcache,mode=max - - name: Pull latest Docker image - if: steps.changes.outputs.changed == '1' - run: docker pull ghcr.io/${{ github.repository }}/latex-builder:latest - - name: Build LaTeX document if: steps.changes.outputs.changed == '1' run: |