biliup-biliup
SUCCESS
53m 24s
History Source
SummaryIterations1Transcript11Dockerfile
Dockerfile104 lines · 2235 chars
# Build biliup's web-ui
FROM node:lts AS webui-builder
ARG repo_url=https://github.com/biliup/biliup
ARG branch_name=master

WORKDIR /biliup

# Use repository content if biliup.spec exists, otherwise clone the repo
COPY . /biliup

RUN set -eux; \
	if [ -f /biliup/biliup.spec ]; then \
		true; \
	else \
		rm -rf /biliup; \
		git clone --depth 1 --branch "$branch_name" "$repo_url" /biliup; \
	fi;

RUN set -eux; \
	cd /biliup; \
	npm install; \
	npm run build;


# Build biliup's python wheel
FROM rust:latest AS wheel-builder
ARG repo_url=https://github.com/biliup/biliup
ARG branch_name=master

WORKDIR /biliup

# Copy source; if biliup.spec exists, we reuse as-is, otherwise clone the repo
COPY . /biliup

RUN set -eux; \
	apt-get update; \
	apt-get install -y --no-install-recommends python3-pip build-essential git ca-certificates pkg-config libssl-dev libffi-dev; \
	pip3 install maturin --break-system-packages; \
	if [ -f /biliup/biliup.spec ]; then \
		true; \
	else \
		rm -rf /biliup; \
		git clone --depth 1 --branch "$branch_name" "$repo_url" /biliup; \
	fi;

COPY --from=webui-builder /biliup/out /biliup/out

WORKDIR /biliup

RUN set -eux; \
	maturin build --release;


# Deploy Biliup
FROM python:3.13-slim AS biliup

ENV TZ="Asia/Shanghai"
ENV LANG="C.UTF-8"
ENV LANGUAGE="C.UTF-8"
ENV LC_ALL="C.UTF-8"
EXPOSE 19159/tcp
VOLUME /opt

# 需要遵守 wheel 文件名规范
COPY --from=wheel-builder /biliup/target/wheels/* /tmp/

RUN set -eux; \
	
	whl=$(ls /tmp/biliup*.whl); \
	pip3 install --no-cache-dir "$whl"; \
	# pip3 install --no-cache-dir "$whl[quickjs]"; \
	pip3 cache purge; \
	rm -rf /tmp/*;

RUN set -eux; \
	 savedAptMark="$(apt-mark showmanual)"; \
	apt-get update; \
	apt-get install -y --no-install-recommends \
		ffmpeg \
		wget \
		curl \
		xz-utils \
		g++ \
	; \
	apt-mark auto '.*' > /dev/null; \
	apt-mark manual curl wget; \
	# Install quickjs for Python bindings
	pip3 install --no-cache-dir quickjs; \
	# Clean up \
	[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
	apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
	rm -rf \
		/tmp/* \
		/usr/share/doc/* \
		/var/cache/* \
		/var/lib/apt/lists/* \
		/var/tmp/* \
		/var/log/* \
	;

WORKDIR /opt

ENTRYPOINT ["biliup"]