2024-10-17 17:10:59 -04:00
|
|
|
FROM python:3.11-slim AS build
|
2023-07-24 11:36:28 -04:00
|
|
|
|
2024-04-14 14:08:46 -04:00
|
|
|
ARG VERSION=3.4.0
|
2024-05-23 09:59:41 -04:00
|
|
|
# pass this in as 'dev' if you want to install from github repo vs pypi
|
|
|
|
ARG INSTALL_TYPE=pypi
|
|
|
|
|
|
|
|
ARG BRANCH=master
|
|
|
|
ARG BUILDX_QEMU_ENV
|
|
|
|
|
|
|
|
ENV APRSD_BRANCH=${BRANCH:-master}
|
2021-02-16 10:05:11 -05:00
|
|
|
ENV TZ=${TZ:-US/Eastern}
|
2020-12-15 10:27:53 -05:00
|
|
|
ENV LC_ALL=C.UTF-8
|
|
|
|
ENV LANG=C.UTF-8
|
2022-12-12 19:29:45 -05:00
|
|
|
ENV APRSD_PIP_VERSION=${VERSION}
|
2024-05-23 09:59:41 -04:00
|
|
|
ENV PATH="${PATH}:/app/.local/bin"
|
2022-11-26 18:23:07 -05:00
|
|
|
|
2023-07-24 11:36:28 -04:00
|
|
|
ENV PIP_DEFAULT_TIMEOUT=100 \
|
|
|
|
# Allow statements and log messages to immediately appear
|
|
|
|
PYTHONUNBUFFERED=1 \
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
RUN set -ex \
|
|
|
|
# Create a non-root user
|
|
|
|
&& addgroup --system --gid 1001 appgroup \
|
|
|
|
&& useradd --uid 1001 --gid 1001 -s /usr/bin/bash -m -d /app appuser \
|
2024-07-25 10:41:21 -04:00
|
|
|
&& usermod -aG sudo appuser \
|
2023-07-24 11:36:28 -04:00
|
|
|
# Upgrade the package index and install security upgrades
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get upgrade -y \
|
2023-09-05 08:01:42 -04:00
|
|
|
&& apt-get install -y git build-essential curl libffi-dev \
|
2024-01-08 13:00:26 -05:00
|
|
|
python3-dev libssl-dev libxml2-dev libxslt-dev telnet sudo fortune \
|
2023-07-24 11:36:28 -04:00
|
|
|
# Install dependencies
|
|
|
|
# Clean up
|
|
|
|
&& apt-get autoremove -y \
|
|
|
|
&& apt-get clean -y
|
|
|
|
|
|
|
|
|
|
|
|
### Final stage
|
2024-10-17 17:10:59 -04:00
|
|
|
FROM build AS install
|
2023-07-24 11:36:28 -04:00
|
|
|
WORKDIR /app
|
2020-12-15 10:27:53 -05:00
|
|
|
|
2024-04-08 17:00:42 -04:00
|
|
|
RUN pip3 install -U pip
|
2023-07-24 11:36:28 -04:00
|
|
|
RUN mkdir /config
|
|
|
|
RUN chown -R appuser:appgroup /app
|
|
|
|
RUN chown -R appuser:appgroup /config
|
|
|
|
USER appuser
|
2024-05-23 09:59:41 -04:00
|
|
|
RUN if [ "$INSTALL_TYPE" = "pypi" ]; then \
|
|
|
|
pip3 install aprsd==$APRSD_PIP_VERSION; \
|
|
|
|
elif [ "$INSTALL_TYPE" = "github" ]; then \
|
|
|
|
git clone -b $APRSD_BRANCH https://github.com/craigerl/aprsd; \
|
2024-07-25 10:41:21 -04:00
|
|
|
cd /app/aprsd && pip install .; \
|
2024-05-23 09:59:41 -04:00
|
|
|
ls -al /app/.local/lib/python3.11/site-packages/aprsd*; \
|
|
|
|
fi
|
|
|
|
RUN pip install gevent uwsgi
|
|
|
|
RUN echo "PATH=\$PATH:/usr/games:/app/.local/bin" >> /app/.bashrc
|
2023-07-24 11:36:28 -04:00
|
|
|
RUN which aprsd
|
2022-12-27 15:44:32 -05:00
|
|
|
RUN aprsd sample-config > /config/aprsd.conf
|
2024-05-23 09:59:41 -04:00
|
|
|
RUN aprsd --version
|
2020-12-15 10:27:53 -05:00
|
|
|
|
2024-04-24 19:11:59 -04:00
|
|
|
ADD bin/setup.sh /app
|
2023-07-24 11:36:28 -04:00
|
|
|
ADD bin/admin.sh /app
|
|
|
|
|
2024-10-17 17:10:59 -04:00
|
|
|
|
|
|
|
FROM install AS final
|
2023-07-24 11:36:28 -04:00
|
|
|
# For the web admin interface
|
|
|
|
EXPOSE 8001
|
|
|
|
|
|
|
|
VOLUME ["/config"]
|
2024-04-23 09:38:37 -04:00
|
|
|
ENTRYPOINT ["/app/setup.sh"]
|
|
|
|
CMD ["server"]
|
2020-12-15 10:27:53 -05:00
|
|
|
|
2023-07-24 11:36:28 -04:00
|
|
|
# Set the user to run the application
|
|
|
|
USER appuser
|
2021-11-09 08:15:16 -05:00
|
|
|
|
2023-09-26 15:27:51 -04:00
|
|
|
HEALTHCHECK --interval=1m --timeout=12s --start-period=30s \
|
|
|
|
CMD aprsd healthcheck --config /config/aprsd.conf --loglevel DEBUG
|