1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-07-13 22:25:16 -04:00

Updated Docker for using alpine and uv

This commit is contained in:
Hemna 2025-01-15 18:00:12 -05:00
parent 1cba31f0ac
commit 24db814c82
3 changed files with 47 additions and 34 deletions

View File

@ -1,6 +1,6 @@
FROM python:3.11-slim AS build FROM ghcr.io/astral-sh/uv:python3.11-alpine AS build
ARG VERSION=3.4.0 ARG VERSION=3.5.0
# pass this in as 'dev' if you want to install from github repo vs pypi # pass this in as 'dev' if you want to install from github repo vs pypi
ARG INSTALL_TYPE=pypi ARG INSTALL_TYPE=pypi
@ -8,7 +8,7 @@ ARG BRANCH=master
ARG BUILDX_QEMU_ENV ARG BUILDX_QEMU_ENV
ENV APRSD_BRANCH=${BRANCH:-master} ENV APRSD_BRANCH=${BRANCH:-master}
ENV TZ=${TZ:-US/Eastern} #ENV TZ=${TZ:-US/Eastern}
ENV LC_ALL=C.UTF-8 ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8
ENV APRSD_PIP_VERSION=${VERSION} ENV APRSD_PIP_VERSION=${VERSION}
@ -23,49 +23,58 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_NO_CACHE_DIR=1 PIP_NO_CACHE_DIR=1
RUN set -ex \ #RUN set -ex \
# Create a non-root user # # Create a non-root user
&& addgroup --system --gid 1001 appgroup \ # && addgroup --system --gid 1001 appgroup \
&& useradd --uid 1001 --gid 1001 -s /usr/bin/bash -m -d /app appuser \ # && useradd --uid 1001 --gid 1001 -s /usr/bin/bash -m -d /app appuser \
&& usermod -aG sudo appuser \ # && usermod -aG sudo appuser
RUN apk add git
#RUN set -ex \
# Upgrade the package index and install security upgrades # Upgrade the package index and install security upgrades
&& apt-get update \ # && apt-get update \
&& apt-get upgrade -y \ # && apt-get upgrade -y \
&& apt-get install -y git build-essential curl libffi-dev \ # && apt-get install -y git build-essential curl libffi-dev \
python3-dev libssl-dev libxml2-dev libxslt-dev telnet sudo fortune \ # python3-dev libssl-dev libxml2-dev libxslt-dev telnet sudo fortune \
# Install dependencies # Install dependencies
# Clean up # Clean up
&& apt-get autoremove -y \ # && apt-get autoremove -y \
&& apt-get clean -y # && apt-get clean -y
### Final stage ### Final stage
FROM build AS install FROM build AS install
WORKDIR /app WORKDIR /app
RUN pip3 install -U pip
RUN mkdir /config RUN mkdir /config
RUN chown -R appuser:appgroup /app RUN uv venv
RUN chown -R appuser:appgroup /config RUN uv pip install -U pip
USER appuser
RUN if [ "$INSTALL_TYPE" = "pypi" ]; then \ RUN if [ "$INSTALL_TYPE" = "pypi" ]; then \
pip3 install aprsd==$APRSD_PIP_VERSION; \ uv pip install aprsd==$APRSD_PIP_VERSION; \
elif [ "$INSTALL_TYPE" = "github" ]; then \ elif [ "$INSTALL_TYPE" = "github" ]; then \
git clone -b $APRSD_BRANCH https://github.com/craigerl/aprsd; \ git clone -b $APRSD_BRANCH https://github.com/craigerl/aprsd; \
cd /app/aprsd && pip install .; \ cd /app/aprsd && uv pip install .; \
ls -al /app/.local/lib/python3.11/site-packages/aprsd*; \ ls -al /app/.venv/lib/python3.11/site-packages/aprsd*; \
fi fi
RUN pip install gevent uwsgi # RUN uv pip install gevent uwsgi
RUN echo "PATH=\$PATH:/usr/games:/app/.local/bin" >> /app/.bashrc RUN echo "PATH=\$PATH:/usr/games:/app/.local/bin" >> /app/.bashrc
RUN which aprsd #RUN which aprsd
RUN aprsd sample-config > /config/aprsd.conf RUN uv run aprsd sample-config > /config/aprsd.conf
RUN aprsd --version RUN uv run aprsd --version
FROM ghcr.io/astral-sh/uv:python3.11-alpine
RUN apk add fortune bash git
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY --from=install /app /app
COPY --from=install /config config
ADD bin/setup.sh /app ADD bin/setup.sh /app
ADD bin/admin.sh /app ADD bin/admin.sh /app
ADD bin/listen.sh /app
RUN ls -al /app
FROM install AS final
# For the web admin interface # For the web admin interface
EXPOSE 8001 EXPOSE 8001
@ -74,7 +83,7 @@ ENTRYPOINT ["/app/setup.sh"]
CMD ["server"] CMD ["server"]
# Set the user to run the application # Set the user to run the application
USER appuser # USER appuser
HEALTHCHECK --interval=1m --timeout=12s --start-period=30s \ HEALTHCHECK --interval=1m --timeout=12s --start-period=30s \
CMD aprsd healthcheck --config /config/aprsd.conf --loglevel DEBUG CMD aprsd healthcheck --config /config/aprsd.conf --loglevel DEBUG

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x set -x
source /app/.venv/bin/activate
if [ ! -z "${APRSD_PLUGINS}" ]; then if [ ! -z "${APRSD_PLUGINS}" ]; then
OLDIFS=$IFS OLDIFS=$IFS
IFS=',' IFS=','
@ -9,7 +11,7 @@ if [ ! -z "${APRSD_PLUGINS}" ]; then
IFS=$OLDIFS IFS=$OLDIFS
# call your procedure/other scripts here below # call your procedure/other scripts here below
echo "Installing '$plugin'" echo "Installing '$plugin'"
pip3 install --user $plugin uv pip install --user $plugin
done done
fi fi
@ -21,7 +23,7 @@ if [ ! -z "${APRSD_EXTENSIONS}" ]; then
IFS=$OLDIFS IFS=$OLDIFS
# call your procedure/other scripts here below # call your procedure/other scripts here below
echo "Installing '$extension'" echo "Installing '$extension'"
pip3 install --user $extension uv pip install --user $extension
done done
fi fi
@ -35,7 +37,7 @@ echo "Log level is set to ${LOG_LEVEL}";
APRSD_CONFIG="/config/aprsd.conf" APRSD_CONFIG="/config/aprsd.conf"
if [ ! -e "$APRSD_CONFIG" ]; then 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 uv run aprsd sample-config > $APRSD_CONFIG
fi fi
export COLUMNS=200 export COLUMNS=200

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x set -x
source /app/.venv/bin/activate
# The default command # The default command
# Override the command in docker-compose.yml to change # Override the command in docker-compose.yml to change
# what command you want to run in the container # what command you want to run in the container
@ -18,7 +20,7 @@ if [ ! -z "${APRSD_PLUGINS}" ]; then
IFS=$OLDIFS IFS=$OLDIFS
# call your procedure/other scripts here below # call your procedure/other scripts here below
echo "Installing '$plugin'" echo "Installing '$plugin'"
pip3 install --user $plugin uv pip install --user $plugin
done done
fi fi
@ -30,7 +32,7 @@ if [ ! -z "${APRSD_EXTENSIONS}" ]; then
IFS=$OLDIFS IFS=$OLDIFS
# call your procedure/other scripts here below # call your procedure/other scripts here below
echo "Installing '$extension'" echo "Installing '$extension'"
pip3 install --user $extension uv pip install --user $extension
done done
fi fi