diff --git a/Makefile b/Makefile index b6783c35..5735cf50 100644 --- a/Makefile +++ b/Makefile @@ -171,23 +171,22 @@ rpm: ## Build RPM package debian: ## Build Debian packages @echo "-> Building deb package..." - @$(DOCKER) build \ - --build-arg IMAGE_ARCH=$(DEB_IMG_ARCH) \ + @$(DOCKER) buildx build --load \ + --platform linux/$(DOCKER_PLATFORM) \ --build-arg PKG_VERSION=$(VERSION) \ - --build-arg PKG_ARCH=$(PKG_ARCH) \ --build-arg WAYBACK_IPFS_APIKEY=$(shell echo ${WAYBACK_IPFS_APIKEY}) \ - -t $(DEB_IMG_ARCH)/wayback-deb-builder \ - -f build/debian/Dockerfile . - @$(DOCKER) run --rm \ - -v ${PWD}/build/package:/pkg \ - $(DEB_IMG_ARCH)/wayback-deb-builder + -t wayback-deb-builder \ + -f build/debian/Dockerfile \ + . + @$(DOCKER) run --rm --platform linux/$(DOCKER_PLATFORM) \ + -v ${PWD}/build/package:/pkg wayback-deb-builder @echo "-> DEB package below:" @ls -h ${PWD}/build/package/*.deb debian-packages: ## Build Debian packages, including amd64, arm32v7, arm64v8 - $(MAKE) debian DEB_IMG_ARCH=amd64 - $(MAKE) debian DEB_IMG_ARCH=arm32v7 PKG_ARCH=armv7 - $(MAKE) debian DEB_IMG_ARCH=arm64v8 PKG_ARCH=arm64 + $(MAKE) debian DOCKER_PLATFORM=amd64 + $(MAKE) debian DOCKER_PLATFORM=arm64 + $(MAKE) debian DOCKER_PLATFORM=arm/v7 submodule: ## Update Git submodule @echo "-> Updating Git submodule..." diff --git a/build/debian/Dockerfile b/build/debian/Dockerfile index 8607c683..05df7ab8 100644 --- a/build/debian/Dockerfile +++ b/build/debian/Dockerfile @@ -1,24 +1,16 @@ -ARG IMAGE_ARCH="amd64" -ARG PKG_VERSION="0.0.1" -ARG PKG_ARCH="amd64" +FROM docker.io/golang:1.22-bookworm AS build -FROM ${IMAGE_ARCH}/golang:buster AS build - -ARG PKG_ARCH -ARG PKG_VERSION ARG WAYBACK_IPFS_APIKEY + ENV DEBIAN_FRONTEND noninteractive RUN apt-get update -q && \ - apt-get install -y -qq --no-install-recommends build-essential devscripts dh-make dh-systemd && \ + apt-get install -y -qq build-essential devscripts dh-make debhelper && \ + mkdir -p /build/debian /pkg && \ rm -rf /var/lib/apt/lists/* -RUN mkdir -p /build/debian /pkg COPY . /src -WORKDIR /src/build/debian ENV WAYBACK_IPFS_APIKEY ${WAYBACK_IPFS_APIKEY} -ENV PKG_VERSION ${PKG_VERSION} -ENV PKG_ARCH ${PKG_ARCH} CMD ["/src/build/debian/builder"] diff --git a/build/debian/builder b/build/debian/builder index b2c807f1..94b6a2ae 100755 --- a/build/debian/builder +++ b/build/debian/builder @@ -5,7 +5,7 @@ set -eu pipefail WORKSPACE="/src" PKG_ARCH="${PKG_ARCH:-$(dpkg --print-architecture)}" PKG_DATE=$(date -R) -PKG_VERSION="${PKG_VERSION:-0.0.1}" +PKG_VERSION="${PKG_VERSION:-$(cd /src && git describe --tags --abbrev=0 | sed 's/^v//')}" echo "WORKSPACE=${WORKSPACE}" echo "PKG_VERSION=${PKG_VERSION}" @@ -13,10 +13,10 @@ echo "PKG_ARCH=${PKG_ARCH}" echo "PKG_DATE=${PKG_DATE}" cd "${WORKSPACE}" && \ - sh "${WORKSPACE}/build/binary.sh" "${PKG_ARCH}" && \ + make build && \ mkdir -p /build/debian /pkg && \ cd /build && \ - cp "${WORKSPACE}/build/binary/wayback-linux-${PKG_ARCH}" /build/wayback && \ + cp "${WORKSPACE}/build/binary/wayback" /build/wayback && \ cp "${WORKSPACE}/wayback.1" /build/ && \ cp "${WORKSPACE}/LICENSE" /build/ && \ cp "${WORKSPACE}/build/systemd/wayback.service" /build/debian/ && \ diff --git a/build/debian/control b/build/debian/control index 7f9bc6bd..c2fbc6ef 100644 --- a/build/debian/control +++ b/build/debian/control @@ -1,6 +1,6 @@ Source: wayback Maintainer: Wayback Archiver -Build-Depends: debhelper (>= 9), dh-systemd +Build-Depends: debhelper (>= 9.20160709) | dh-systemd Package: wayback Architecture: __PKG_ARCH__ diff --git a/build/debian/rules b/build/debian/rules old mode 100644 new mode 100755 diff --git a/docs/changelog.md b/docs/changelog.md index b0b413f2..d70bd628 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add support for place IRC name - Fallback to non-TLS server - Styling IRC message +- Improve build debian package workflow ([#527](https://github.com/wabarc/wayback/pull/527)) ### Fixed - Load the config file always ([#498](https://github.com/wabarc/wayback/pull/498))