mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-21 09:01:23 -05:00
Merge pull request #167 from craigerl/docker-rework
Refactor Dockerfile
This commit is contained in:
commit
63962acfe6
3
.github/workflows/manual_build.yml
vendored
3
.github/workflows/manual_build.yml
vendored
@ -43,8 +43,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: "{{defaultContext}}:docker"
|
context: "{{defaultContext}}:docker"
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
file: ./Dockerfile-dev
|
file: ./Dockerfile
|
||||||
build-args: |
|
build-args: |
|
||||||
|
INSTALL_TYPE=github
|
||||||
BRANCH=${{ steps.extract_branch.outputs.branch }}
|
BRANCH=${{ steps.extract_branch.outputs.branch }}
|
||||||
BUILDX_QEMU_ENV=true
|
BUILDX_QEMU_ENV=true
|
||||||
push: true
|
push: true
|
||||||
|
3
.github/workflows/master-build.yml
vendored
3
.github/workflows/master-build.yml
vendored
@ -53,8 +53,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: "{{defaultContext}}:docker"
|
context: "{{defaultContext}}:docker"
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
file: ./Dockerfile-dev
|
file: ./Dockerfile
|
||||||
build-args: |
|
build-args: |
|
||||||
|
INSTALL_TYPE=github
|
||||||
BRANCH=${{ steps.branch-name.outputs.current_branch }}
|
BRANCH=${{ steps.branch-name.outputs.current_branch }}
|
||||||
BUILDX_QEMU_ENV=true
|
BUILDX_QEMU_ENV=true
|
||||||
push: true
|
push: true
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
FROM python:3.11-slim as build
|
FROM python:3.11-slim as build
|
||||||
|
|
||||||
ARG VERSION=3.4.0
|
ARG VERSION=3.4.0
|
||||||
|
# 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}
|
||||||
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}
|
||||||
|
ENV PATH="${PATH}:/app/.local/bin"
|
||||||
|
|
||||||
ENV PIP_DEFAULT_TIMEOUT=100 \
|
ENV PIP_DEFAULT_TIMEOUT=100 \
|
||||||
# Allow statements and log messages to immediately appear
|
# Allow statements and log messages to immediately appear
|
||||||
@ -35,16 +43,22 @@ FROM build as final
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN pip3 install -U pip
|
RUN pip3 install -U pip
|
||||||
RUN pip3 install aprsd==$APRSD_PIP_VERSION
|
|
||||||
RUN pip install gevent uwsgi
|
|
||||||
RUN which aprsd
|
|
||||||
RUN mkdir /config
|
RUN mkdir /config
|
||||||
RUN chown -R appuser:appgroup /app
|
RUN chown -R appuser:appgroup /app
|
||||||
RUN chown -R appuser:appgroup /config
|
RUN chown -R appuser:appgroup /config
|
||||||
USER appuser
|
USER appuser
|
||||||
RUN echo "PATH=\$PATH:/usr/games" >> /app/.bashrc
|
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; \
|
||||||
|
cd /app/aprsd && pip install -e .; \
|
||||||
|
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
|
||||||
RUN which aprsd
|
RUN which aprsd
|
||||||
RUN aprsd sample-config > /config/aprsd.conf
|
RUN aprsd sample-config > /config/aprsd.conf
|
||||||
|
RUN aprsd --version
|
||||||
|
|
||||||
ADD bin/setup.sh /app
|
ADD bin/setup.sh /app
|
||||||
ADD bin/admin.sh /app
|
ADD bin/admin.sh /app
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
FROM python:3.11-slim as build
|
|
||||||
|
|
||||||
ARG BRANCH=master
|
|
||||||
ARG BUILDX_QEMU_ENV
|
|
||||||
ENV APRSD_BRANCH=${BRANCH:-master}
|
|
||||||
|
|
||||||
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 \
|
|
||||||
# Upgrade the package index and install security upgrades
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get upgrade -y \
|
|
||||||
&& apt-get install -y git build-essential curl libffi-dev fortune \
|
|
||||||
python3-dev libssl-dev libxml2-dev libxslt-dev telnet sudo \
|
|
||||||
# Install dependencies
|
|
||||||
# Clean up
|
|
||||||
&& apt-get autoremove -y \
|
|
||||||
&& apt-get clean -y
|
|
||||||
|
|
||||||
|
|
||||||
### Final stage
|
|
||||||
FROM build as final
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
RUN git clone -b $APRSD_BRANCH https://github.com/craigerl/aprsd
|
|
||||||
RUN pip install -U pip
|
|
||||||
RUN cd aprsd && pip install --no-cache-dir .
|
|
||||||
RUN pip install gevent uwsgi==2.0.24
|
|
||||||
RUN which aprsd
|
|
||||||
RUN mkdir /config
|
|
||||||
RUN chown -R appuser:appgroup /app
|
|
||||||
RUN chown -R appuser:appgroup /config
|
|
||||||
USER appuser
|
|
||||||
RUN echo "PATH=\$PATH:/usr/games" >> /app/.bashrc
|
|
||||||
RUN which aprsd
|
|
||||||
RUN aprsd sample-config > /config/aprsd.conf
|
|
||||||
|
|
||||||
ADD bin/setup.sh /app
|
|
||||||
ADD bin/admin.sh /app
|
|
||||||
|
|
||||||
EXPOSE 8000
|
|
||||||
EXPOSE 8001
|
|
||||||
|
|
||||||
VOLUME ["/config"]
|
|
||||||
# CMD ["gunicorn", "aprsd.wsgi:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
||||||
ENTRYPOINT ["/app/setup.sh"]
|
|
||||||
CMD ["server"]
|
|
||||||
|
|
||||||
# Set the user to run the application
|
|
||||||
USER appuser
|
|
@ -90,7 +90,8 @@ then
|
|||||||
# Use this script to locally build the docker image
|
# Use this script to locally build the docker image
|
||||||
docker buildx build --push --platform $PLATFORMS \
|
docker buildx build --push --platform $PLATFORMS \
|
||||||
-t hemna6969/aprsd:$TAG \
|
-t hemna6969/aprsd:$TAG \
|
||||||
-f Dockerfile-dev --build-arg branch=$BRANCH \
|
--build-arg INSTALL_TYPE=github \
|
||||||
|
--build-arg branch=$BRANCH \
|
||||||
--build-arg BUILDX_QEMU_ENV=true \
|
--build-arg BUILDX_QEMU_ENV=true \
|
||||||
--no-cache .
|
--no-cache .
|
||||||
else
|
else
|
||||||
@ -101,6 +102,5 @@ else
|
|||||||
--build-arg BUILDX_QEMU_ENV=true \
|
--build-arg BUILDX_QEMU_ENV=true \
|
||||||
-t hemna6969/aprsd:$VERSION \
|
-t hemna6969/aprsd:$VERSION \
|
||||||
-t hemna6969/aprsd:$TAG \
|
-t hemna6969/aprsd:$TAG \
|
||||||
-t hemna6969/aprsd:latest \
|
-t hemna6969/aprsd:latest .
|
||||||
-f Dockerfile .
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user