mirror of
https://codeberg.org/readeck/readeck.git
synced 2025-12-22 13:17:10 +00:00
Multi arch containers.
This removes the Containerfile and uses buildah directly in order to build one image per architecture. Closes #76
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
# SPDX-FileCopyrightText: © 2023 Olivier Meunier <olivier@neokraft.net>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
# This is the Container build file for Readeck
|
||||
# It uses the release files in the dist folder
|
||||
|
||||
# First stage, only to get the ca-certificates
|
||||
FROM alpine:edge as build
|
||||
|
||||
RUN apk add --no-cache ca-certificates
|
||||
|
||||
# Second stage
|
||||
# The binary is statically linked so we can just copy it in a small image
|
||||
# and call it a day.
|
||||
# You're welcome for the tiny image :)
|
||||
|
||||
FROM scratch
|
||||
ARG VERSION
|
||||
ARG DIST
|
||||
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY ${DIST}/readeck-${VERSION}-linux-amd64 /bin/readeck
|
||||
|
||||
LABEL org.opencontainers.image.authors="olivier@readeck.com" \
|
||||
version="${VERSION}"
|
||||
|
||||
ENV READECK_SERVER_HOST=0.0.0.0
|
||||
ENV READECK_SERVER_PORT=8000
|
||||
EXPOSE 8000/tcp
|
||||
VOLUME /readeck
|
||||
WORKDIR /readeck
|
||||
CMD ["/bin/readeck", "serve", "-config", "config.toml"]
|
||||
6
Makefile
6
Makefile
@@ -280,8 +280,4 @@ release-checksums:
|
||||
.PHONY: release-container
|
||||
release-container: TAG?=readeck-release:$(VERSION)
|
||||
release-container: | $(DIST)/.release-linux
|
||||
docker build \
|
||||
-f Containerfile \
|
||||
--build-arg VERSION=$(VERSION) \
|
||||
--build-arg DIST=$(DIST) \
|
||||
-t $(TAG)
|
||||
VERSION=$(VERSION) ./tools/build-container
|
||||
|
||||
62
tools/build-container
Executable file
62
tools/build-container
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SPDX-FileCopyrightText: © 2023 Olivier Meunier <olivier@neokraft.net>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
# This script builds the container image for Readeck.
|
||||
# It uses the release files in the dist folder.
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
work_container=""
|
||||
|
||||
cleanup() {
|
||||
if [[ "$work_container" != "" ]]; then
|
||||
buildah rm $work_container > /dev/null
|
||||
echo "> ${work_container} removed"
|
||||
fi
|
||||
}
|
||||
|
||||
build_image() {
|
||||
local arch=$1
|
||||
trap cleanup ERR RETURN
|
||||
|
||||
# Prepare a scratch image
|
||||
work_container=$(buildah from --arch=${arch} scratch)
|
||||
|
||||
# Copy CA certificates from alpine
|
||||
buildah copy --from alpine:edge \
|
||||
$work_container \
|
||||
/etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
# Copy Readeck binary
|
||||
buildah copy $work_container dist/readeck-${VERSION}-linux-${arch} /bin/readeck
|
||||
|
||||
# Set image configuration
|
||||
buildah config \
|
||||
--workingdir /readeck \
|
||||
--volume /readeck \
|
||||
--cmd "/bin/readeck serve -config config.toml" \
|
||||
--port 8000/tcp \
|
||||
--env READECK_SERVER_HOST=0.0.0.0 \
|
||||
--env READECK_SERVER_PORT=8000 \
|
||||
--label org.opencontainers.image.authors="olivier@readeck.com" \
|
||||
--label version=${VERSION} \
|
||||
$work_container
|
||||
|
||||
# Create image
|
||||
buildah commit $work_container readeck/release/${arch}:${VERSION}
|
||||
echo "> Image created: readeck/release/${arch}:${VERSION}"
|
||||
}
|
||||
|
||||
echo "> Version: ${VERSION}"
|
||||
echo "> Image: readeck/release/{arch}:${VERSION}"
|
||||
|
||||
buildah pull --policy=always alpine:edge
|
||||
|
||||
for arch in amd64 arm64; do
|
||||
build_image ${arch}
|
||||
echo
|
||||
done
|
||||
Reference in New Issue
Block a user