From 06b0211305eed3138f433fcc8a1a783e743f261b Mon Sep 17 00:00:00 2001 From: Dominic Ricottone Date: Tue, 6 Jun 2023 18:44:59 -0500 Subject: [PATCH] Added apkbuilder --- README.md | 1 + apkbuilder/.gitignore | 1 + apkbuilder/Dockerfile | 27 +++++++++++++++ apkbuilder/Makefile | 13 ++++++++ apkbuilder/README.md | 77 +++++++++++++++++++++++++++++++++++++++++++ apkbuilder/build.sh | 8 +++++ 6 files changed, 127 insertions(+) create mode 100644 apkbuilder/.gitignore create mode 100644 apkbuilder/Dockerfile create mode 100644 apkbuilder/Makefile create mode 100644 apkbuilder/README.md create mode 100755 apkbuilder/build.sh diff --git a/README.md b/README.md index d53d318..16c903a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ It should be easy to get things working on another build system. |Images |Tags |Fully qualified name of the default image| |:------|:----|:----------------------------------------| +|[apkbuilder](/~dricottone/container-images/tree/dev/item/apkbuilder/README.md)|latest|`registry.intra.dominic-ricottone.com/apkbuilder:latest`| |[dnsmasq](/~dricottone/container-images/tree/dev/item/dnsmasq/README.md)|latest|`registry.intra.dominic-ricottone.com/dnsmasq:latest`| |[fcgi](/~dricottone/container-images/tree/dev/item/fcgi/README.md)|latest|`registry.intra.dominic-ricottone.com/fcgi:latest`| |[haproxy](/~dricottone/container-images/tree/dev/item/haproxy/README.md)|latest|`registry.intra.dominic-ricottone.com/haproxy:latest`| diff --git a/apkbuilder/.gitignore b/apkbuilder/.gitignore new file mode 100644 index 0000000..5b26e2d --- /dev/null +++ b/apkbuilder/.gitignore @@ -0,0 +1 @@ +abuild diff --git a/apkbuilder/Dockerfile b/apkbuilder/Dockerfile new file mode 100644 index 0000000..f24f6f5 --- /dev/null +++ b/apkbuilder/Dockerfile @@ -0,0 +1,27 @@ +FROM docker.io/library/alpine:3.17 + +RUN adduser -D builder && addgroup builder abuild + +# packaging script +COPY --chown=builder:builder build.sh /home/builder/build.sh +RUN chmod 755 /home/builder/build.sh + +# packaging configuration +COPY --chown=builder:builder abuild /home/builder/.abuild +RUN chmod 600 /home/builder/.abuild/* + +RUN apk add --no-cache abuild sudo +RUN echo "builder ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers +COPY abuild/*.rsa.pub /etc/apk/keys/ +RUN chmod 644 /etc/apk/keys/*.rsa.pub +RUN mv /etc/apk/repositories /etc/apk/repositories.bak +RUN echo "https://pkg.intra.dominic-ricottone.com/alpine/v3.17" | cat - /etc/apk/repositories.bak >/etc/apk/repositories + +USER builder +WORKDIR /home/builder +RUN mkdir -p /home/builder/packages +VOLUME /home/builder/packages/src +VOLUME /home/builder/src +ENTRYPOINT ["/home/builder/build.sh"] +CMD ["non_existant_package_name"] + diff --git a/apkbuilder/Makefile b/apkbuilder/Makefile new file mode 100644 index 0000000..3d1500d --- /dev/null +++ b/apkbuilder/Makefile @@ -0,0 +1,13 @@ +CONMAN=sudo docker + +REGISTRY=registry.intra.dominic-ricottone.com +IMAGE=apkbuilder +TAG=latest + +image: + $(CONMAN) buildx build --push \ + --platform linux/arm64,linux/amd64 \ + --tag $(REGISTRY)/$(IMAGE):$(TAG) \ + . + +.PHONY: image diff --git a/apkbuilder/README.md b/apkbuilder/README.md new file mode 100644 index 0000000..d934915 --- /dev/null +++ b/apkbuilder/README.md @@ -0,0 +1,77 @@ +# apkbuilder + + +## Build and Deploy + +``` +make image +``` + + +### Tags + + + `latest` + +---- + +## Use + +Builds APK packages. +Not meant for humans. +See https://git.dominic-ricottone.com/~dricottone/simple-builder . + +Create an abuild folder containing: + + * an `abuild.conf` file + * packaging keys + +For the former, try a configuration like: + +``` +export CFLAGS="-Os -fomit-frame-pointer" +export CXXFLAGS="$CFLAGS" +export CPPFLAGS="$CFLAGS" +export LDFLAGS="-Wl,--as-needed,-O1,--sort-common" +export GOFLAGS="-buildmode=pie -modcacherw -trimpath -buildvcs=false" +# Do note that these should work with at least GDC and LDC +export DFLAGS="-Os" + +export JOBS=$(nproc) +export MAKEFLAGS=-j$JOBS +export SAMUFLAGS=-j$JOBS +export CARGO_BUILD_JOBS=$JOBS + +export CARGO_PROFILE_RELEASE_OPT_LEVEL="s" +export CARGO_PROFILE_RELEASE_PANIC="abort" +export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 +export CARGO_PROFILE_RELEASE_LTO="true" + +#USE_COLORS=1 + +#USE_CCACHE=1 + +SRCDEST=/var/cache/distfiles + +# uncomment line below to store built packages in other location +# The package will be stored as $REPODEST/$repo/$pkgname-$pkgver-r$pkgrel.apk +# where $repo is the name of the parent directory of $startdir. +REPODEST=$HOME/packages + +PACKAGER="Dominic Ricottone " +PACKAGER_PRIVKEY="/home/builder/.abuild/me@dominic-ricottone.com.rsa" +MAINTAINER="$PACKAGER" + +# what to clean up after a successful build +CLEANUP="srcdir bldroot pkgdir deps" + +# what to cleanup after a failed build +ERROR_CLEANUP="bldroot deps" +``` + +For the latter, try: + +``` +openssl genrsa -out abuild/me@dominic-ricottone.com.rsa 2048 +openssl rsa -in abuild/me@dominic-ricottone.com.rsa -pubout -out abuild/me@dominic-ricottone.com.rsa.pub +``` + diff --git a/apkbuilder/build.sh b/apkbuilder/build.sh new file mode 100755 index 0000000..bde3489 --- /dev/null +++ b/apkbuilder/build.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd src/$1 || exit 1 +sudo apk update +. APKBUILD +abuild checksum || exit 1 +ulimit -n 1024 +abuild -r || exit 1 + -- 2.45.2