Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeakes committed May 31, 2024
1 parent 09029c9 commit decec48
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 9 deletions.
5 changes: 4 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#####################################
#
# Build container
# The most basic build for aqualinkd latest version
# The most basic build for aqualinkd
#
# env AQUALINKD_VERSION must be passed to this
#
#####################################

FROM debian:bookworm AS aqualinkd-build
Expand Down
105 changes: 105 additions & 0 deletions docker/Dockerfile.buildx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#####################################
#
# Create AqualinkD container for release (includes AMD64 and ARM64 for >Pi4 with 64 bit os and Linux PC)
# Build container for buildx
# This should support building on any host platform, but only supports output platform of amd64 & arm64
#
# Enable multi platform
# docker buildx create --use --platform=linux/arm64,linux/amd64 --name multi-platform-builder
# docker buildx inspect --bootstrap
#
# Build
# docker buildx build --platform=linux/amd64,linux/arm64 --output=./crap --file /Dockerfile.test -t aqualinkd-test .
# docker buildx build --platform=linux/amd64,linux/arm64 --file Dockerfile.test --output type=docker -t aqualinkd-test .
# docker build --file Dockerfile.test --progress=plain -t aqualinkd-test .
#
# adding --progress=plain helps with debug
#
# Clean the build env and start again
# docker buildx prune
#
#
# docker build -f ./Dockerfile.buildrelease .
#
#####################################


# Starting with base debian:bookworm and installing build-essential seems to be quicker than starting with gcc:bookworm
#FROM --platform=$BUILDPLATFORM gcc:12-bookworm AS aqualinkd-build
FROM --platform=$BUILDPLATFORM debian:bookworm AS aqualinkd-build

ARG BUILDARCH
ARG TARGETARCH

# Print all buildx variables
RUN echo "Build Arch $BUILDARCH" && \
echo "Tagert OS $TARGETOS"

# Setup build env, using toolchain for all builds, even native, since make this Dockerfile cleaner
# and no need to use bash if statments.
# Need to be careful on install order, so using two commands

RUN apt-get update && \
apt-get install -y \
make \
curl \
gcc-aarch64-linux-gnu \
gcc-x86-64-linux-gnu

RUN dpkg --add-architecture arm64 && \
dpkg --add-architecture amd64 && \
apt-get update && \
apt-get install -y \
libsystemd-dev:arm64 \
libsystemd-dev:amd64


RUN mkdir /home/AqualinkD
WORKDIR /home/AqualinkD


ARG AQUALINKD_VERSION
RUN curl -sL "https://github.com/sfeakes/AqualinkD/archive/refs/tags/$AQUALINKD_VERSION.tar.gz" | tar xz --strip-components=1
# Get latest release
#RUN curl -sL $(curl -s https://api.github.com/repos/sfeakes/AqualinkD/releases/latest | grep "tarball_url" | cut -d'"' -f4) | tar xz --strip-components=1


# Make AqualinkD
RUN make clean && \
make container-$TARGETARCH;

#####################################
#
# Runtime container(s)
#
#####################################

FROM debian:bookworm-slim AS aqualinkd

RUN apt-get update \
&& apt-get install -y cron curl socat

# Set cron to read local.d
RUN sed -i '/EXTRA_OPTS=.-l./s/^#//g' /etc/default/cron

#Add Open Container Initiative (OCI) annotations.
#See: https://github.com/opencontainers/image-spec/blob/main/annotations.md

LABEL org.opencontainers.image.title="AqualinkD"
LABEL org.opencontainers.image.url="https://hub.docker.com/repository/docker/sfeakes/aqualinkd/general"
LABEL org.opencontainers.image.source="https://github.com/sfeakes/AqualinkD"
LABEL org.opencontainers.image.documentation="https://github.com/sfeakes/AqualinkD"
LABEL org.opencontainers.image.version=$AQUALINKD_VERSION

EXPOSE 80/tcp

COPY --from=aqualinkd-build /home/AqualinkD/release/aqualinkd /usr/local/bin/aqualinkd
COPY --from=aqualinkd-build /home/AqualinkD/release/serial_logger /usr/local/bin/serial_logger
COPY --from=aqualinkd-build /home/AqualinkD/web/ /var/www/aqualinkd/
COPY --from=aqualinkd-build /home/AqualinkD/release/aqualinkd.conf /etc/aqualinkd.conf

COPY --from=aqualinkd-build /home/AqualinkD/docker/aqualinkd-docker.cmd /usr/local/bin/aqualinkd-docker

RUN chmod +x /usr/local/bin/aqualinkd-docker

CMD ["sh", "-c", "/usr/local/bin/aqualinkd-docker"]
46 changes: 46 additions & 0 deletions docker/buildx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
#
# Script to build arm64 & amd64 containers that are published to docker.io
#

IMAGE=aqualinkd

if [ $# -eq 0 ]
then
# Below is safer, but not supported on all platforms.
#VERSION=$(curl --silent "https://api.github.com/repos/sfeakes/AqualinkD/releases/latest" | grep -Po '"tag_name": "[^0-9|v|V]*\K.*?(?=")')
VERSION=$(curl --silent "https://api.github.com/repos/sfeakes/AqualinkD/releases/latest" | grep "tag_name" | awk -F'"' '$0=$4')
else
VERSION=$1
fi

URL="https://github.com/sfeakes/AqualinkD/archive/refs/tags/"$VERSION".tar.gz"
URL2="https://github.com/sfeakes/AqualinkD/archive/refs/tags/v"$VERSION".tar.gz"
URL3="https://github.com/sfeakes/AqualinkD/archive/refs/tags/V"$VERSION".tar.gz"
#BURL="https://github.com/sfeakes/AqualinkD/archive/refs/heads/"$VERSION".tar.gz"

# Check version is accurate before running docker build

if ! curl --output /dev/null --silent --location --head --fail "$URL"; then
# Check if version tag has wrong case
if curl --output /dev/null --silent --location --head --fail "$URL2"; then
VERSION=v$VERSION
else
# Check if it's a branch
if curl --output /dev/null --silent --location --head --fail "$URL3"; then
VERSION=V$VERSION
else
echo "ERROR Can't build Docker container for $IMAGE $VERSION"
echo -e "Neither Version or Branch URLs:- \n $URL \n $URL2 \n $URL3"
exit 1
fi
fi
fi

echo "Building Docker container for $IMAGE using branch $VERSION"
docker buildx build --platform=linux/amd64,linux/arm64 \
--file Dockerfile.buildx \
-t docker.io/sfeakes/${IMAGE}:${VERSION} \
-t docker.io/sfeakes/${IMAGE}:latest \
--build-arg AQUALINKD_VERSION=${VERSION} \
--push .
16 changes: 8 additions & 8 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
services:
aqualinkd:
#image: sfeakes/aqualinkd:latest
build:
context: https://github.com/sfeakes/AqualinkD.git#master:docker
args:
AQUALINKD_VERSION: v2.3.6 # Make sure to change to correct version
tags:
- aqualinkd:v2.3.6
container_name: aqualinkd
image: sfeakes/aqualinkd:latest
#build:
# context: https://github.com/sfeakes/AqualinkD.git#master:docker
# args:
# AQUALINKD_VERSION: v2.3.6 # Make sure to change to correct version
# tags:
# - aqualinkd:v2.3.6
container_name: aqualinkd
ports:
- "6171:80"
volumes:
Expand Down

0 comments on commit decec48

Please sign in to comment.