1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-05-24 02:22:25 -04:00

Updated Dockerfile for multiplatform builds

This patch updates the main Dockerfile container build to use
the python:3.8-slim base image and installs aprsd from pypi.
This also results in a much smaller image.

Also added support for multiarchitecture builds so the same Dockerfile
builds for raspberry pi and linux/amd64
This commit is contained in:
Hemna 2021-02-16 10:05:11 -05:00
parent 2d5bb85071
commit f0034fc517
3 changed files with 36 additions and 40 deletions

View File

@ -1,43 +1,34 @@
FROM alpine:latest 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 UID
ARG GID
ARG TZ
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 TZ=${TZ:-US/Eastern}
ENV APRSD_BRANCH=${BRANCH:-master} ENV UID=${UID:-1000}
ENV VIRTUAL_ENV=$HOME/.venv3 ENV GID=${GID:-1000}
ENV INSTALL=$HOME/install
RUN apk add --update git vim wget py3-pip py3-virtualenv bash fortune
RUN apk add --update gcc python3-dev linux-headers musl-dev libffi-dev libc-dev
RUN apk add --update openssl-dev
# 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 1001 $APRS_USER
RUN adduser -h $HOME -D -u 1001 -G $APRS_USER $APRS_USER
ENV LC_ALL=C.UTF-8 ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8
USER $APRS_USER #RUN apt update
RUN pip3 install wheel #RUN apt-get install -y apt-utils
RUN python3 -m venv $VIRTUAL_ENV #RUN apt-get install -y pkg-config
ENV PATH="$VIRTUAL_ENV/bin:$PATH" #RUN apt upgrade -y
RUN echo "export PATH=\$PATH:\$HOME/.local/bin" >> $HOME/.bashrc #RUN apk add --update git wget bash
VOLUME ["/config", "/plugins"] #RUN apk add --update gcc linux-headers musl-dev libffi-dev libc-dev
#RUN apk add --update openssl-dev
#RUN add cmd:pip3 lsb-release
WORKDIR $HOME RUN addgroup --gid $GID $APRS_USER
RUN mkdir $INSTALL RUN useradd -m -u $UID -g $APRS_USER $APRS_USER
RUN git clone -b $APRSD_BRANCH $APRSD $INSTALL/aprsd
RUN cd $INSTALL/aprsd && pip3 install . # Install aprsd
RUN which aprsd RUN /usr/local/bin/pip3 install aprsd
# Ensure /config is there with a default config file
USER root USER root
RUN mkdir -p /config RUN mkdir -p /config
RUN aprsd sample-config > /config/aprsd.yml RUN aprsd sample-config > /config/aprsd.yml
@ -45,7 +36,8 @@ RUN chown -R $APRS_USER:$APRS_USER /config
# override this to run another configuration # override this to run another configuration
ENV CONF default ENV CONF default
USER $APRS_USER VOLUME ["/config", "/plugins"]
ADD bin/run.sh $HOME/ USER $APRS_USER
ENTRYPOINT ["/home/aprs/run.sh"] ADD bin/run.sh /usr/local/bin
ENTRYPOINT ["/usr/local/bin/run.sh"]

View File

@ -1,10 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x set -x
export PATH=$PATH:$HOME/.local/bin
export VIRTUAL_ENV=$HOME/.venv3
source $VIRTUAL_ENV/bin/activate
if [ ! -z "${APRSD_PLUGINS}" ]; then if [ ! -z "${APRSD_PLUGINS}" ]; then
OLDIFS=$IFS OLDIFS=$IFS
IFS=',' IFS=','
@ -23,4 +19,5 @@ if [ ! -e "$APRSD_CONFIG" ]; then
echo "'$APRSD_CONFIG' File does not exist. Creating." echo "'$APRSD_CONFIG' File does not exist. Creating."
aprsd sample-config > $APRSD_CONFIG aprsd sample-config > $APRSD_CONFIG
fi fi
$VIRTUAL_ENV/bin/aprsd server -c $APRSD_CONFIG --loglevel DEBUG
/usr/local/bin/aprsd server -c $APRSD_CONFIG --loglevel DEBUG

View File

@ -1,4 +1,11 @@
#!/bin/bash #!/bin/bash
VERSION="1.6.0"
# Use this script to locally build the docker image # Use this script to locally build the docker image
docker build --no-cache -t hemna6969/aprsd:latest -f ./Dockerfile . docker buildx build --push --platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64 \
-t hemna6969/aprsd:$VERSION \
-t hemna6969/aprsd:latest \
-t 192.168.1.3:5000/hemna6969/aprsd:latest \
-t 192.168.1.3:5000/hemna669/aprsd:$VERSION \
-f Dockerfile .