1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-12-18 07:36:34 -05:00

Updates for building containers

This patch updates the Dockerfile for building the official container
image and includes the ability to load external pypi modules as plugins
at container startup.
This commit is contained in:
Hemna 2020-12-15 10:27:53 -05:00
parent ba61178b14
commit 861fde6f83
4 changed files with 83 additions and 12 deletions

View File

@ -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

53
Dockerfile-dev Normal file
View File

@ -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"]

View File

@ -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

View File

@ -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