mirror of
https://github.com/craigerl/aprsd.git
synced 2025-07-30 20:32:27 -04:00
Replace Dockerfile-dev with python3 slim
This commit is contained in:
parent
35d41582ee
commit
ccd564a52e
@ -1,73 +1,52 @@
|
|||||||
# syntax=docker/dockerfile:1
|
FROM python:3.11-slim as build
|
||||||
FROM ubuntu:22.04
|
|
||||||
|
|
||||||
# Dockerfile for building a container during aprsd development.
|
ENV PIP_DEFAULT_TIMEOUT=100 \
|
||||||
ARG BRANCH=master
|
# Allow statements and log messages to immediately appear
|
||||||
ARG UID
|
PYTHONUNBUFFERED=1 \
|
||||||
ARG GID
|
# disable a pip version check to reduce run-time & log-spam
|
||||||
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||||
|
# cache is useless in docker image, so disable to reduce image size
|
||||||
|
PIP_NO_CACHE_DIR=1
|
||||||
|
|
||||||
ARG BUILDX_QEMU_ENV
|
WORKDIR /app
|
||||||
|
|
||||||
ENV APRS_USER=aprs
|
RUN set -ex \
|
||||||
ENV HOME=/home/aprs
|
# Create a non-root user
|
||||||
ENV APRSD=http://github.com/craigerl/aprsd.git
|
&& addgroup --system --gid 1001 appgroup \
|
||||||
ENV APRSD_BRANCH=${BRANCH:-master}
|
&& adduser --system --uid 1001 --gid 1001 --no-create-home appuser \
|
||||||
ENV VIRTUAL_ENV=$HOME/.venv3
|
# Upgrade the package index and install security upgrades
|
||||||
ENV UID=${UID:-1000}
|
&& apt-get update \
|
||||||
ENV GID=${GID:-1000}
|
&& apt-get upgrade -y \
|
||||||
ENV PATH=$PATH:/home/aprs/.local/bin
|
&& apt-get install -y git build-essential curl vim \
|
||||||
|
# Install dependencies
|
||||||
|
# Clean up
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean -y
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
ENV INSTALL=$HOME/install
|
|
||||||
RUN apt update
|
|
||||||
RUN apt install -y --no-install-recommends git build-essential bash fortune
|
|
||||||
RUN apt install -y libffi-dev python3-dev libssl-dev libxml2-dev libxslt-dev
|
|
||||||
RUN apt install -y telnet vim sudo
|
|
||||||
RUN apt install -y python3 python3-pip python3-dev python3-lxml
|
|
||||||
#RUN apt-get clean
|
|
||||||
RUN apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall netbase
|
|
||||||
|
|
||||||
RUN addgroup --gid 1001 $APRS_USER
|
### Final stage
|
||||||
RUN useradd -m -u $UID -g $APRS_USER $APRS_USER
|
FROM build as final
|
||||||
|
|
||||||
ENV LC_ALL=C.UTF-8
|
RUN git clone https://github.com/craigerl/aprsd
|
||||||
ENV LANG=C.UTF-8
|
RUN cd aprsd && pip install --no-cache-dir .
|
||||||
|
RUN pip install gunicorn
|
||||||
WORKDIR $HOME
|
RUN which aprsd
|
||||||
USER $APRS_USER
|
RUN mkdir /config
|
||||||
RUN pip install wheel
|
RUN chown -R appuser:appgroup /app
|
||||||
#RUN python3 -m venv $VIRTUAL_ENV
|
RUN chown -R appuser:appgroup /config
|
||||||
#ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
USER appuser
|
||||||
RUN echo "export PATH=\$PATH:\$HOME/.local/bin" >> $HOME/.bashrc
|
|
||||||
RUN cat $HOME/.bashrc
|
|
||||||
|
|
||||||
USER root
|
|
||||||
RUN mkdir -p /config
|
|
||||||
RUN chown -R $APRS_USER:$APRS_USER /config
|
|
||||||
WORKDIR $HOME
|
|
||||||
# Handle an extremely specific issue when building the cryptography package for
|
|
||||||
# 32-bit architectures within QEMU running on a 64-bit host (issue #30).
|
|
||||||
RUN if [ "${BUILDX_QEMU_ENV}" = "true" -a "$(getconf LONG_BIT)" = "32" ]; then \
|
|
||||||
pip3 install -U cryptography==3.3.2; \
|
|
||||||
else \
|
|
||||||
pip3 install cryptography ;\
|
|
||||||
fi
|
|
||||||
USER $APRS_USER
|
|
||||||
RUN mkdir $INSTALL
|
|
||||||
RUN git clone -b $BRANCH $APRSD $INSTALL/aprsd
|
|
||||||
RUN cd $INSTALL/aprsd && pip3 install -v --user .
|
|
||||||
RUN ls -al /home/aprs/.local/bin
|
|
||||||
RUN which aprsd
|
RUN which aprsd
|
||||||
RUN aprsd sample-config > /config/aprsd.conf
|
RUN aprsd sample-config > /config/aprsd.conf
|
||||||
|
|
||||||
# override this to run another configuration
|
ADD bin/run.sh /app
|
||||||
ENV CONF default
|
ADD bin/listen.sh /app
|
||||||
USER $APRS_USER
|
ADD bin/admin.sh /app
|
||||||
VOLUME ["/config", "/plugins"]
|
|
||||||
|
|
||||||
ADD bin/run.sh $HOME/
|
EXPOSE 8000
|
||||||
ADD bin/listen.sh $HOME/
|
|
||||||
ENTRYPOINT ["/home/aprs/run.sh"]
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=5m --timeout=12s --start-period=30s \
|
# CMD ["gunicorn", "aprsd.wsgi:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
CMD aprsd healthcheck --config /config/aprsd.conf
|
ENTRYPOINT ["/app/run.sh"]
|
||||||
|
VOLUME ["/config"]
|
||||||
|
|
||||||
|
# Set the user to run the application
|
||||||
|
USER appuser
|
||||||
|
31
docker/bin/admin.sh
Executable file
31
docker/bin/admin.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -x
|
||||||
|
|
||||||
|
if [ ! -z "${APRSD_PLUGINS}" ]; then
|
||||||
|
OLDIFS=$IFS
|
||||||
|
IFS=','
|
||||||
|
echo "Installing pypi plugins '$APRSD_PLUGINS'";
|
||||||
|
for plugin in ${APRSD_PLUGINS}; do
|
||||||
|
IFS=$OLDIFS
|
||||||
|
# call your procedure/other scripts here below
|
||||||
|
echo "Installing '$plugin'"
|
||||||
|
pip3 install $plugin
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${LOG_LEVEL}" ] || [[ ! "${LOG_LEVEL}" =~ ^(CRITICAL|ERROR|WARNING|INFO)$ ]]; then
|
||||||
|
LOG_LEVEL="DEBUG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Log level is set to ${LOG_LEVEL}";
|
||||||
|
|
||||||
|
# check to see if there is a config file
|
||||||
|
APRSD_CONFIG="/config/aprsd.conf"
|
||||||
|
if [ ! -e "$APRSD_CONFIG" ]; then
|
||||||
|
echo "'$APRSD_CONFIG' File does not exist. Creating."
|
||||||
|
aprsd sample-config > $APRSD_CONFIG
|
||||||
|
fi
|
||||||
|
|
||||||
|
export COLUMNS=200
|
||||||
|
exec gunicorn -b :8000 --workers 4 "aprsd.admin_web:create_app(config_file='$APRSD_CONFIG', log_level='$LOG_LEVEL')"
|
||||||
|
#exec aprsd listen -c $APRSD_CONFIG --loglevel ${LOG_LEVEL} ${APRSD_LOAD_PLUGINS} ${APRSD_LISTEN_FILTER}
|
Loading…
x
Reference in New Issue
Block a user