diff --git a/.docker/Dockerfile b/.docker/Dockerfile index f26a0fc..bfc2f9b 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,7 +1,7 @@ # Stage 1: Builder with all necessary packages FROM alpine:latest AS builder -# Install build dependencies +# Install build dependencies in a single layer to optimize caching RUN apk add --no-cache \ texlive \ texlive-xetex \ @@ -10,21 +10,20 @@ RUN apk add --no-cache \ texmf-dist-fontsextra \ perl \ fontconfig \ - make + make \ + && texhash # Stage 2: Final image with only runtime dependencies FROM alpine:latest -# Install only runtime dependencies +# Install minimal runtime dependencies RUN apk add --no-cache \ texlive-xetex \ texmf-dist \ fontconfig -# Copy necessary files from builder +# Copy texmf files from builder COPY --from=builder /usr/share/texmf-dist /usr/share/texmf-dist -COPY --from=builder /usr/share/texlive /usr/share/texlive -COPY --from=builder /var/lib/texmf /var/lib/texmf WORKDIR /latex @@ -32,6 +31,8 @@ WORKDIR /latex COPY entrypoint.sh /entrypoint.sh COPY *.tex *.cls *.sty ./ -RUN chmod +x /entrypoint.sh +# Make entrypoint executable and refresh TeX file database +RUN chmod +x /entrypoint.sh && \ + texhash ENTRYPOINT ["/entrypoint.sh"] diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh index 737fbb9..028fccb 100644 --- a/.docker/entrypoint.sh +++ b/.docker/entrypoint.sh @@ -4,13 +4,16 @@ set -e # Create output directory mkdir -p /latex/output +# Ensure TeX can find the files +texhash + # Run XeLaTeX with proper output name xelatex -interaction=nonstopmode \ -output-directory=/latex/output \ -jobname="Anish_Shobith_P_S_Resume" \ "main.tex" -# Run again if needed for references +# Run again for references if needed if grep -q "Rerun to get" "/latex/output/Anish_Shobith_P_S_Resume.log"; then xelatex -interaction=nonstopmode \ -output-directory=/latex/output \ @@ -20,3 +23,10 @@ fi # Copy the final PDF to the mounted volume cp /latex/output/Anish_Shobith_P_S_Resume.pdf /latex/ + +# Show compilation log in case of errors +if [ ! -f "/latex/Anish_Shobith_P_S_Resume.pdf" ]; then + echo "Compilation failed. Log output:" + cat /latex/output/Anish_Shobith_P_S_Resume.log + exit 1 +fi