Skip to content

Commit

Permalink
Improve build debian package workflow (#527)
Browse files Browse the repository at this point in the history
* Improve deb builder workflow

* Use buildx instead

* Fix

* Update

* Fix permission

* update changelog

* update build params
  • Loading branch information
waybackarchiver authored Jun 22, 2024
1 parent c8cacd7 commit 8991856
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
16 changes: 4 additions & 12 deletions build/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 3 additions & 3 deletions build/debian/builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ 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}"
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/ && \
Expand Down
2 changes: 1 addition & 1 deletion build/debian/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: wayback
Maintainer: Wayback Archiver <[email protected]>
Build-Depends: debhelper (>= 9), dh-systemd
Build-Depends: debhelper (>= 9.20160709) | dh-systemd

Package: wayback
Architecture: __PKG_ARCH__
Expand Down
Empty file modified build/debian/rules
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8991856

Please sign in to comment.