define-alpine-the-sequel/services/forgejo/build.ts

40 lines
1 KiB
TypeScript

import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { buildRepro, reproRun } from "../../helpers/repro-run.js";
const FORGEJO_VERSION = "v1.18.3-0";
// returns path to statically compiled binary
export async function buildForgejo(): Promise<string> {
return await buildRepro(
"forgejo",
FORGEJO_VERSION,
`#!/bin/sh -e
runprint() {
echo "==> $@"
"$@"
}
runprint apk add --quiet git nodejs npm go make
# TODO: cachear clon de repo
runprint git clone https://codeberg.org/forgejo/forgejo --branch '${FORGEJO_VERSION}' --depth 1 --single-branch
cd forgejo
runprint env GOOS=linux GOARCH=amd64 LDFLAGS="-linkmode external -extldflags '-static' $LDFLAGS" TAGS="bindata sqlite sqlite_unlock_notify" make build
mv gitea /forgejo
`,
(dir) =>
reproRun({
cwd: dir,
command: "/src/build",
cache: [
"/home/repro/.cache/go-build",
"/home/repro/go",
"/home/repro/.npm",
],
}),
(dir) => join(dir, "rootfs/forgejo")
);
}