# Gitea Action Runner Electron Image
# 用于 Electron Linux AppImage、Windows NSIS、macOS zip 打包

FROM electronuserland/builder:wine

LABEL maintainer="www.imyeyu.com"
LABEL description="Gitea Action Runner for Electron Linux AppImage, Windows NSIS and macOS zip packaging"

ENV CI=true
ENV ELECTRON_CACHE=/root/.cache/electron
ENV ELECTRON_BUILDER_CACHE=/root/.cache/electron-builder
ENV PNPM_HOME=/usr/local/share/pnpm
ENV PATH="${PNPM_HOME}:${PATH}"

ARG PNPM_VERSION=10

RUN set -eux; \
	apt-get update; \
	apt-get install -y --no-install-recommends \
		bash \
		ca-certificates \
		curl \
		g++ \
		git \
		jq \
		make \
		openssh-client \
		p7zip-full \
		python3 \
		rsync \
		unzip \
		xz-utils \
		zip; \
	npm install -g "pnpm@${PNPM_VERSION}" yarn; \
	pnpm config set store-dir /pnpm/store; \
	mkdir -p \
		/pnpm/store \
		"${ELECTRON_CACHE}" \
		"${ELECTRON_BUILDER_CACHE}" \
		/workspace; \
	apt-get clean; \
	rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY build-electron-release.sh /usr/local/bin/build-electron-release

RUN chmod +x /usr/local/bin/build-electron-release \
	&& node --version \
	&& npm --version \
	&& pnpm --version \
	&& wine --version

WORKDIR /workspace
