Multiarch docker builds

This commit is contained in:
Tony Garnock-Jones 2023-09-29 13:54:05 +02:00
parent dd69d5caaa
commit 0432f8a04a
6 changed files with 55 additions and 14 deletions

2
docker/.gitignore vendored
View File

@ -1 +1 @@
syndicate-server
syndicate-server.*

View File

@ -1,4 +1,5 @@
FROM busybox
RUN mkdir /data
COPY ./syndicate-server /
CMD ["/syndicate-server", "-c", "/data"]
ARG TARGETARCH
COPY ./syndicate-server.$TARGETARCH /syndicate-server
CMD ["/syndicate-server", "-c", "/data", "-p", "1"]

View File

@ -1,18 +1,37 @@
U=leastfixedpoint
I=syndicate-server
ARCHITECTURES:=amd64 arm arm64
SERVERS:=$(patsubst %,syndicate-server.%,$(ARCHITECTURES))
VERSION=$(shell ./syndicate-server.$(shell ./docker-architecture $$(uname -m)) --version | cut -d' ' -f2)
all:
.PHONY: all clean image push syndicate-server
.PHONY: all clean image push push-only
clean:
rm -f syndicate-server
docker rmi leastfixedpoint/syndicate-server
rm -f syndicate-server.*
-podman images -q $(U)/$(I) | sort -u | xargs podman rmi -f
image: syndicate-server
docker build -t leastfixedpoint/$$(./syndicate-server --version | tr ' ' ':') -t leastfixedpoint/syndicate-server:latest .
image: $(SERVERS)
for A in $(ARCHITECTURES); do set -x; \
podman build --platform=linux/$$A \
-t $(U)/$(I):$(VERSION)-$$A \
-t $(U)/$(I):latest-$$A \
.; \
done
rm -f tmp.image
push: image
docker push leastfixedpoint/$$(./syndicate-server --version | tr ' ' ':')
docker push leastfixedpoint/syndicate-server:latest
push: image push-only
syndicate-server:
make -C .. x86_64-binary-release
cp -a ../target/x86_64-unknown-linux-musl/release/syndicate-server $@
push-only:
$(patsubst %,podman push $(U)/$(I):$(VERSION)-%;,$(ARCHITECTURES))
$(patsubst %,podman push $(U)/$(I):latest-%;,$(ARCHITECTURES))
podman rmi -f $(U)/$(I):$(VERSION) $(U)/$(I):latest
podman manifest create $(U)/$(I):$(VERSION) $(patsubst %,$(U)/$(I):$(VERSION)-%,$(ARCHITECTURES))
podman manifest create $(U)/$(I):latest $(patsubst %,$(U)/$(I):latest-%,$(ARCHITECTURES))
podman manifest push $(U)/$(I):$(VERSION)
podman manifest push $(U)/$(I):latest
syndicate-server.%:
make -C .. $$(./alpine-architecture $*)-binary-release
cp -a ../target/$$(./alpine-architecture $*)-unknown-linux-musl*/release/syndicate-server $@

9
docker/README.md Normal file
View File

@ -0,0 +1,9 @@
# Docker images for syndicate-server
Build using podman:
apt install podman
and at least until the dependencies are fixed (?),
apt install uidmap slirp4netns

6
docker/alpine-architecture Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
case $1 in
amd64) echo x86_64;;
arm) echo armv7;;
arm64) echo aarch64;;
esac

6
docker/docker-architecture Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
case $1 in
x86_64) echo amd64;;
armv7) echo arm;;
aarch64) echo arm64;;
esac