Files
turborepo-remote-cache/turborepo-remote-cache.spec
Zoran Peričić 146b35f63a Switch to online pnpm build, add --without service bcond
- Source0 now points at the GitHub tag tarball so spectool -g can
  fetch it; drops fetch-sources.sh
- %build runs pnpm install --frozen-lockfile --ignore-scripts, then
  pnpm exec tsc (bypasses upstream lint), then pnpm prune --prod
- Guard all -service bits behind %bcond_without service so offline
  builds can produce base + -container with --without service
- Base and -container subpackages never need network
2026-04-08 13:38:35 +02:00

167 lines
5.3 KiB
RPMSpec

%global npm_name turborepo-remote-cache
%global __brp_mangle_shebangs_exclude_from ^%{nodejs_sitelib}/%{npm_name}/.*$
# Build the native Node.js -service subpackage by default.
# Disable when building in a network-less environment (e.g. stock mock):
# rpmbuild -bb --without service turborepo-remote-cache.spec
# mock --without=service ...
# The base and -container subpackages never need network.
%bcond_without service
Name: turborepo-remote-cache
Version: 2.8.2
Release: 1%{?dist}
Summary: Self-hosted Turborepo remote cache server
License: MIT
Group: Development/Tools
URL: https://github.com/ducktors/turborepo-remote-cache
Source0: %{url}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source10: %{name}.sysusers
Source11: %{name}.service
Source12: %{name}.container
Source13: config.env
BuildArch: noarch
BuildRequires: systemd-rpm-macros
%if %{with service}
BuildRequires: nodejs-devel
BuildRequires: nodejs-npm
BuildRequires: pnpm
%endif
%description
Turborepo Remote Cache is a self-hosted implementation of the Vercel
Remote Cache API used by Turborepo and turbo-compatible build tools.
It lets CI runners share build artifacts without relying on Vercel's
hosted cache.
This base package ships the sysusers.d drop-in, the configuration
directory with a token template, and the cache storage directory.
Install either turborepo-remote-cache-service (native Node.js) or
turborepo-remote-cache-container (Podman quadlet) to actually run
the server.
%if %{with service}
%package service
Summary: Turborepo Remote Cache as a native Node.js systemd service
Requires: %{name} = %{version}-%{release}
Requires: nodejs >= 1:20
Conflicts: %{name}-container
%{?systemd_requires}
%description service
Runs turborepo-remote-cache as a native Node.js process under systemd,
using the pnpm-vendored production dependencies built into this
package. Listens on 127.0.0.1:3128 by default.
%endif
%package container
Summary: Turborepo Remote Cache as a Podman quadlet
Requires: %{name} = %{version}-%{release}
Requires: podman
Requires: containers-common
%if %{with service}
Conflicts: %{name}-service
%endif
%description container
Runs turborepo-remote-cache as a Podman container via quadlet,
pulling docker.io/ducktors/turborepo-remote-cache:%{version}.
Listens on 127.0.0.1:3128 by default; cache storage is bind-mounted
from /var/cache/turborepo-remote-cache on the host.
%prep
%setup -q -n %{name}-%{version}
%build
%if %{with service}
# Pull all deps (dev + prod) so tsc is available. Network required.
pnpm install --frozen-lockfile --ignore-scripts
# Compile TypeScript directly (bypass upstream `pnpm build` which also
# runs lint — lint is a dev-time check we don't care about at package build).
pnpm exec tsc -p ./tsconfig.json
# Drop dev dependencies before shipping.
pnpm prune --prod --ignore-scripts
%endif
%install
%{__rm} -rf %{buildroot}
# Base: sysusers, config dir, cache dir
install -p -D -m 644 %{SOURCE10} %{buildroot}%{_sysusersdir}/%{name}.conf
install -d -m 750 %{buildroot}%{_sysconfdir}/%{name}
install -m 640 %{SOURCE13} %{buildroot}%{_sysconfdir}/%{name}/config.env
install -d -m 750 %{buildroot}%{_localstatedir}/cache/%{name}
%if %{with service}
# -service: install app tree to %{nodejs_sitelib}/turborepo-remote-cache
install -d -m 755 %{buildroot}%{nodejs_sitelib}/%{npm_name}
cp -pr dist node_modules package.json \
%{buildroot}%{nodejs_sitelib}/%{npm_name}/
# CLI symlink + shebang fix
install -d -m 755 %{buildroot}%{_bindir}
ln -s %{nodejs_sitelib}/%{npm_name}/dist/cli.js \
%{buildroot}%{_bindir}/%{name}
sed -i -e '1s|^#!.*node.*|#!/usr/bin/node|' \
%{buildroot}%{nodejs_sitelib}/%{npm_name}/dist/cli.js || :
chmod 755 %{buildroot}%{nodejs_sitelib}/%{npm_name}/dist/cli.js
# -service: systemd unit
install -p -D -m 644 %{SOURCE11} %{buildroot}%{_unitdir}/%{name}.service
%endif
# -container: quadlet
install -p -D -m 644 %{SOURCE12} \
%{buildroot}%{_datadir}/containers/systemd/%{name}.container
%pre
%sysusers_create_package %{name} %{SOURCE10}
%if %{with service}
%post service
%systemd_post %{name}.service
%preun service
%systemd_preun %{name}.service
%postun service
%systemd_postun_with_restart %{name}.service
%endif
%files
%defattr(-,root,root,-)
%{_sysusersdir}/%{name}.conf
%dir %attr(0750,root,turbo-cache) %{_sysconfdir}/%{name}
%config(noreplace) %attr(0640,root,turbo-cache) %{_sysconfdir}/%{name}/config.env
%dir %attr(0750,turbo-cache,turbo-cache) %{_localstatedir}/cache/%{name}
%if %{with service}
%files service
%defattr(-,root,root,-)
%{_unitdir}/%{name}.service
%dir %{nodejs_sitelib}/%{npm_name}
%{nodejs_sitelib}/%{npm_name}/dist
%{nodejs_sitelib}/%{npm_name}/node_modules
%{nodejs_sitelib}/%{npm_name}/package.json
%{_bindir}/%{name}
%endif
%files container
%defattr(-,root,root,-)
%{_datadir}/containers/systemd/%{name}.container
%changelog
* Wed Apr 08 2026 Zoran Pericic <zpericic@netst.org> - 2.8.2-1
- Initial package for ducktors/turborepo-remote-cache 2.8.2
- Split into -service (native Node.js) and -container (Podman quadlet)
- -service build pulls deps online with pnpm; disable with
--without service when network is unavailable
- Dynamic sysusers turbo-cache user
- Listens on 127.0.0.1:3128; storage at /var/cache/turborepo-remote-cache