From 239e784d51f975ec0c62638aa9cabfaf01f4dd46 Mon Sep 17 00:00:00 2001 From: Hemna Date: Thu, 18 Feb 2021 18:59:08 -0500 Subject: [PATCH] Added Dockerfile-dev and updated build.sh Build.sh is used for multi-architecture building of docker images. --- docker/Dockerfile-dev | 50 ++++++++++++++++++++++++++++++++ docker/build.sh | 66 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 docker/Dockerfile-dev diff --git a/docker/Dockerfile-dev b/docker/Dockerfile-dev new file mode 100644 index 0000000..bbff999 --- /dev/null +++ b/docker/Dockerfile-dev @@ -0,0 +1,50 @@ +FROM python:3.8-slim as aprsd + +# Dockerfile for building a container during aprsd development. +ARG BRANCH +ARG UID +ARG GID + +ENV APRS_USER=aprs +ENV HOME=/home/aprs +ENV APRSD=http://github.com/craigerl/aprsd.git +ENV APRSD_BRANCH=${BRANCH:-master} +ENV VIRTUAL_ENV=$HOME/.venv3 +ENV UID=${UID:-1000} +ENV GID=${GID:-1000} + +ENV INSTALL=$HOME/install +RUN apt update +RUN apt install -y git build-essential +RUN apt install -y libffi-dev python3-dev libssl-dev +RUN apt install -y bash fortune + +RUN addgroup --gid 1001 $APRS_USER +RUN useradd -m -u $UID -g $APRS_USER $APRS_USER + +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +USER $APRS_USER +RUN pip3 install wheel +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" +RUN echo "export PATH=\$PATH:\$HOME/.local/bin" >> $HOME/.bashrc +VOLUME ["/config", "/plugins"] + +WORKDIR $HOME +RUN mkdir $INSTALL +RUN git clone -b $APRSD_BRANCH $APRSD $INSTALL/aprsd +RUN cd $INSTALL/aprsd && pip3 install . +RUN which aprsd +USER root +RUN mkdir -p /config +RUN aprsd sample-config > /config/aprsd.yml +RUN chown -R $APRS_USER:$APRS_USER /config + +# override this to run another configuration +ENV CONF default +USER $APRS_USER + +ADD bin/run.sh $HOME/ +ENTRYPOINT ["/home/aprs/run.sh"] diff --git a/docker/build.sh b/docker/build.sh index a71f1e0..74514b0 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -1,12 +1,64 @@ #!/bin/bash # Official docker image build script. + +usage() { +cat << EOF +usage: $0 options + +OPTIONS: + -t The tag/version (${TAG}) (default = master) + -d Use Dockerfile-dev for a git clone build +EOF +} + + +ALL_PLATFORMS=0 +DEV=0 +TAG="master" + +while getopts “t:da” OPTION +do + case $OPTION in + t) + TAG=$OPTARG + ;; + a) + ALL_PLATFORMS=1 + ;; + d) + DEV=1 + ;; + ?) + usage + exit + ;; + esac +done + VERSION="1.6.0" -# Use this script to locally build the docker image -docker buildx build --push --platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64 \ - -t hemna6969/aprsd:$VERSION \ - -t hemna6969/aprsd:latest \ - -t harbor.hemna.com/hemna6969/aprsd:latest \ - -t harbor.hemna.com/hemna6969/aprsd:$VERSION \ - -f Dockerfile . +if [ $ALL_PLATFORMS -eq 1 ] +then + PLATFORMS="linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64" +else + PLATFORMS="linux/amd64" +fi + +if [ $DEV -eq 1 ] +then + # Use this script to locally build the docker image + docker buildx build --push --platform $PLATFORMS \ + -t harbor.hemna.com/hemna6969/aprsd:$TAG \ + -f Dockerfile-dev --no-cache . +else + # Use this script to locally build the docker image + docker buildx build --push --platform $PLATFORMS \ + -t hemna6969/aprsd:$VERSION \ + -t hemna6969/aprsd:latest \ + -t harbor.hemna.com/hemna6969/aprsd:latest \ + -t harbor.hemna.com/hemna6969/aprsd:$VERSION \ + -f Dockerfile . + + +fi