diff --git a/Dockerfile b/Dockerfile index 76ac9e1..f7f1228 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,16 @@ FROM ubuntu:20.04 as aprsd - ENV VERSION=1.0.0 ENV APRS_USER=aprs ENV HOME=/home/aprs -ENV APRSD=http://github.com/craigerl/aprsd.git -ENV APRSD_BRANCH="master" +ENV VIRTUAL_ENV=$HOME/.venv3 ENV INSTALL=$HOME/install ENV DEBIAN_FRONTEND=noninteractive RUN apt-get -y update RUN apt-get install -y wget gnupg git-core -RUN apt-get install -y apt-utils pkg-config sudo -RUN apt-get install -y python3 python3-pip python3-virtualenv +RUN apt-get install -y apt-utils pkg-config sudo vim +RUN apt-get install -y python3 python3-pip python3-virtualenv python3-venv # Setup Timezone ENV TZ=US/Eastern @@ -24,17 +22,21 @@ RUN dpkg-reconfigure --frontend noninteractive tzdata RUN addgroup --gid 1000 $APRS_USER RUN useradd -m -u 1000 -g 1000 -p $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"] +VOLUME ["/config", "/plugins"] WORKDIR $HOME -RUN mkdir $INSTALL -# install librtlsdr from source -RUN git clone -b $APRSD_BRANCH $APRSD $INSTALL/aprsd +RUN pip install aprsd USER root -RUN cd $INSTALL/aprsd && pip3 install . RUN aprsd sample-config > /config/aprsd.yml +RUN chown -R $APRS_USER:$APRS_USER /config # override this to run another configuration ENV CONF default diff --git a/Dockerfile-dev b/Dockerfile-dev new file mode 100644 index 0000000..ca64f44 --- /dev/null +++ b/Dockerfile-dev @@ -0,0 +1,53 @@ +FROM ubuntu:20.04 as aprsd + +# Dockerfile for building a container during aprsd development. + +ENV VERSION=1.0.0 +ENV APRS_USER=aprs +ENV HOME=/home/aprs +ENV APRSD=http://github.com/craigerl/aprsd.git +ENV APRSD_BRANCH="master" +ENV VIRTUAL_ENV=$HOME/.venv3 + +ENV INSTALL=$HOME/install +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get -y update +RUN apt-get install -y wget gnupg git-core +RUN apt-get install -y apt-utils pkg-config sudo vim +RUN apt-get install -y python3 python3-pip python3-virtualenv python3-venv + +# Setup Timezone +ENV TZ=US/Eastern +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apt-get install -y tzdata +RUN dpkg-reconfigure --frontend noninteractive tzdata + + +RUN addgroup --gid 1000 $APRS_USER +RUN useradd -m -u 1000 -g 1000 -p $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 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 build/bin/run.sh $HOME/ +ENTRYPOINT ["/home/aprs/run.sh"] diff --git a/build/bin/run.sh b/build/bin/run.sh index 213d34b..a0d155c 100755 --- a/build/bin/run.sh +++ b/build/bin/run.sh @@ -1,6 +1,21 @@ #!/usr/bin/env bash +set -x export PATH=$PATH:$HOME/.local/bin +export VIRTUAL_ENV=$HOME/.venv3 +source $VIRTUAL_ENV/bin/activate + +if [ ! -z "${APRS_PLUGINS}" ]; then + OLDIFS=$IFS + IFS=',' + echo "Installing pypi plugins '$APRS_PLUGINS'"; + for plugin in ${APRS_PLUGINS}; do + IFS=$OLDIFS + # call your procedure/other scripts here below + echo "Installing '$plugin'" + pip3 install $plugin + done +fi # check to see if there is a config file APRSD_CONFIG="/config/aprsd.yml" @@ -8,5 +23,4 @@ if [ ! -e "$APRSD_CONFIG" ]; then echo "'$APRSD_CONFIG' File does not exist. Creating." aprsd sample-config > $APRSD_CONFIG fi - -aprsd server -c $APRSD_CONFIG +$VIRTUAL_ENV/bin/aprsd server -c $APRSD_CONFIG diff --git a/docker-compose.yml b/docker-compose.yml index 87030e6..54c1397 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: container_name: aprsd volumes: - /opt/docker/aprsd/config:/config + - /opt/docker/aprsd/plugins:/plugins restart: unless-stopped environment: - TZ=America/New_York + - APRS_PLUGINS=aprsd-slack-plugin