Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: use alpine for web app#50

Open
sghng wants to merge 9 commits intomain from
refactor/alpine
Open

refactor: use alpine for web app #50
sghng wants to merge 9 commits intomain from
refactor/alpine

Conversation

@sghng
Copy link
Owner

@sghng sghng commented Dec 7, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 7, 2025 22:07
@sghng sghng temporarily deployed to refactor/alpine - typ2docx PR #50 December 7, 2025 22:08 — with Render Destroyed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Dockerfile to use Alpine Linux-based images instead of Debian/slim variants, aiming to reduce image size and simplify the build process. The changes migrate all base images (rust, typst, pandoc, and bun) to Alpine variants and update package management from apt to apk.

Key Changes:

  • Migrated from Debian-based images (rust:slim, rust:slim-bookworm) to Alpine-based images (rust:alpine, alpine:edge, oven/bun:alpine)
  • Simplified build stages by using pre-built Alpine packages for typst instead of building from source
  • Replaced custom pandoc download logic with the official pandoc/minimal image
  • Updated all package installations from apt to apk with corresponding Alpine package names

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Dockerfile Outdated
curl pkg-config libssl-dev
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
FROM rust:alpine AS typ2docx
RUN apk add pkgconfig openssl-dev uv gcompat
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Alpine package name should be pkgconf instead of pkgconfig. In Alpine Linux, the pkg-config implementation is provided by the pkgconf package. Using pkgconfig may cause the build to fail.

Suggested change
RUN apk add pkgconfig openssl-dev uv gcompat
RUN apk add pkgconf openssl-dev uv gcompat

Copilot uses AI. Check for mistakes.
Dockerfile Outdated
curl pkg-config libssl-dev
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
FROM rust:alpine AS typ2docx
RUN apk add pkgconfig openssl-dev uv gcompat
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing uv via apk requires adding the community or testing repository, as it's not available in the main Alpine repository. Consider either adding the repository explicitly (e.g., RUN apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing uv) or reverting to the curl installation method from the original version to ensure the build succeeds reliably.

Suggested change
RUN apk add pkgconfig openssl-dev uv gcompat
RUN apk add pkgconfig openssl-dev gcompat && \
apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing uv

Copilot uses AI. Check for mistakes.
Comment on lines 6 to 8
FROM alpine:edge AS typst
RUN apk add typst

Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using alpine:edge provides the latest rolling release packages but can introduce instability and breaking changes. Consider using a stable Alpine version (e.g., alpine:3.20) with an explicit typst version for better reproducibility and reliability in production environments.

Suggested change
FROM alpine:edge AS typst
RUN apk add typst
FROM alpine:3.20 AS typst
RUN apk add --no-cache ca-certificates wget tar
# Install specific typst version (e.g., v0.10.0)
ENV TYPST_VERSION=0.10.0
RUN wget -O typst.tar.xz https://github.com/typst/typst/releases/download/v${TYPST_VERSION}/typst-x86_64-unknown-linux-musl.tar.xz \
&& tar -xf typst.tar.xz \
&& mv typst-x86_64-unknown-linux-musl/typst /usr/bin/typst \
&& rm -rf typst-x86_64-unknown-linux-musl typst.tar.xz

Copilot uses AI. Check for mistakes.
RUN apt update && apt install -y --no-install-recommends \
curl pkg-config libssl-dev
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
FROM rust:alpine AS typ2docx
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gcompat package provides GNU libc compatibility for musl-based Alpine, which is needed for Python packages like saxonche (listed in pyproject.toml) that have glibc dependencies. However, gcompat may not fully support all glibc features. Consider testing thoroughly to ensure all Python dependencies (especially saxonche, pdfservices-sdk, and pdf2docx) work correctly with musl/gcompat, or document any known limitations.

Suggested change
FROM rust:alpine AS typ2docx
FROM rust:alpine AS typ2docx
# NOTE: gcompat provides partial GNU libc compatibility for musl-based Alpine.
# Some Python packages (e.g., saxonche, pdfservices-sdk, pdf2docx) may require full glibc support.
# gcompat may not fully support all glibc features; test these packages thoroughly and document any known limitations.

Copilot uses AI. Check for mistakes.
Dockerfile Outdated
Comment on lines 2 to 12
RUN apk add pkgconfig openssl-dev uv gcompat
COPY pyproject.toml /
RUN /root/.local/bin/uv tool install typ2docx --verbose
RUN uv tool install typ2docx --verbose

# align with oven/bun:slim
FROM rust:slim-bookworm AS typst
RUN apt update && apt install -y --no-install-recommends pkg-config libssl-dev
COPY Cargo.toml /
RUN cargo install typst-cli
FROM alpine:edge AS typst
RUN apk add typst

FROM alpine/curl AS pandoc
ARG PLATFORM=linux-amd64
ARG REPO=https://github.com/jgm/pandoc
ARG VERSION=3.8.3
ARG FILE=pandoc-${VERSION}-${PLATFORM}.tar.gz
RUN curl -L "${REPO}/releases/download/${VERSION}/${FILE}" | tar -xz
FROM pandoc/minimal AS pandoc

FROM oven/bun:slim
RUN apt update && \
apt install -y --no-install-recommends ca-certificates unzip rsync zip && \
rm -rf /var/lib/apt/lists/
COPY --from=pandoc /pandoc-*/bin/pandoc /usr/local/bin/
COPY --from=typst /usr/local/cargo/bin/typst /usr/local/bin/
FROM oven/bun:alpine
RUN apk add ca-certificates unzip rsync zip
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the --no-cache flag for apk add commands. Adding this flag (e.g., RUN apk add --no-cache ...) prevents caching the package index and reduces the final image size, which is a best practice for Alpine-based Docker images.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /