Updated build.sh

This patch forces the rebuild of the docker buildx build container.
Also makes the tag, version available from cmdln
This commit is contained in:
Hemna 2021-10-07 10:56:09 -04:00
parent 5b17228811
commit db9cbf51df
2 changed files with 21 additions and 9 deletions

View File

@ -1,14 +1,14 @@
FROM python:3.8-slim as aprsd FROM python:3.8-slim as aprsd
# Dockerfile for building a container during aprsd development. # Dockerfile for building a container during aprsd development.
ARG BRANCH ARG branch
ARG UID ARG UID
ARG GID ARG GID
ENV APRS_USER=aprs ENV APRS_USER=aprs
ENV HOME=/home/aprs ENV HOME=/home/aprs
ENV APRSD=http://github.com/craigerl/aprsd.git ENV APRSD=http://github.com/craigerl/aprsd.git
ENV APRSD_BRANCH=${BRANCH:-master} ENV APRSD_BRANCH=${branch:-master}
ENV VIRTUAL_ENV=$HOME/.venv3 ENV VIRTUAL_ENV=$HOME/.venv3
ENV UID=${UID:-1000} ENV UID=${UID:-1000}
ENV GID=${GID:-1000} ENV GID=${GID:-1000}

View File

@ -15,14 +15,18 @@ EOF
ALL_PLATFORMS=0 ALL_PLATFORMS=0
DEV=0 DEV=0
TAG="master" TAG="latest"
BRANCH="master"
while getopts “t:da” OPTION while getopts “t:dab:” OPTION
do do
case $OPTION in case $OPTION in
t) t)
TAG=$OPTARG TAG=$OPTARG
;; ;;
b)
BRANCH=$OPTARG
;;
a) a)
ALL_PLATFORMS=1 ALL_PLATFORMS=1
;; ;;
@ -45,20 +49,28 @@ else
PLATFORMS="linux/amd64" PLATFORMS="linux/amd64"
fi fi
echo "Build with tag=${TAG} BRANCH=${BRANCH} dev?=${DEV} platforms?=${PLATFORMS}"
echo "Destroying old multiarch build container"
docker buildx rm multiarch
echo "Creating new buildx container"
docker buildx create --name multiarch --platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64 --config ./buildkit.toml --use --driver-opt image=moby/buildkit:master
if [ $DEV -eq 1 ] if [ $DEV -eq 1 ]
then then
echo "Build -DEV- with tag=${TAG} BRANCH=${BRANCH} platforms?=${PLATFORMS}"
# Use this script to locally build the docker image # Use this script to locally build the docker image
docker buildx build --push --platform $PLATFORMS \ docker buildx build --push --platform $PLATFORMS \
-t harbor.hemna.com/hemna6969/aprsd:$TAG \ -t harbor.hemna.com/hemna6969/aprsd:$TAG \
-f Dockerfile-dev --no-cache . -f Dockerfile-dev --build-arg branch=$BRANCH --no-cache .
else else
# Use this script to locally build the docker image # Use this script to locally build the docker image
echo "Build with tag=${TAG} BRANCH=${BRANCH} platforms?=${PLATFORMS}"
docker buildx build --push --platform $PLATFORMS \ docker buildx build --push --platform $PLATFORMS \
-t hemna6969/aprsd:$VERSION \ -t hemna6969/aprsd:$VERSION \
-t hemna6969/aprsd:latest \ -t hemna6969/aprsd:$TAG \
-t harbor.hemna.com/hemna6969/aprsd:latest \ -t harbor.hemna.com/hemna6969/aprsd:$TAG \
-t harbor.hemna.com/hemna6969/aprsd:$VERSION \ -t harbor.hemna.com/hemna6969/aprsd:$VERSION \
-f Dockerfile . -f Dockerfile .
fi fi