Commit 3f50064e by Peter Eacmen

implement multi-stage build and test stage, include Docker build in Travis integration testing

parent afe921fc
...@@ -3,3 +3,9 @@ dist ...@@ -3,3 +3,9 @@ dist
.coverage .coverage
*.extracted *.extracted
*.pyc *.pyc
.editorconfig
.gitignore
images
Dockerfile
.dockerignore
.git
...@@ -13,19 +13,31 @@ script: ./setup.py test ...@@ -13,19 +13,31 @@ script: ./setup.py test
cache: pip cache: pip
jobs: jobs:
include: include:
- dist: bionic - stage: test
dist: bionic
python: 3.6 python: 3.6
- dist: bionic - stage: test
dist: bionic
python: 3.7 python: 3.7
- dist: bionic - stage: test
dist: bionic
python: 3.8 python: 3.8
- dist: bionic - stage: test
dist: bionic
python: 3.9 python: 3.9
- dist: focal - stage: test
dist: focal
python: 3.6 python: 3.6
- dist: focal - stage: test
dist: focal
python: 3.7 python: 3.7
- dist: focal - stage: test
dist: focal
python: 3.8 python: 3.8
- dist: focal - stage: test
dist: focal
python: 3.9 python: 3.9
- stage: test
services: docker
install:
- docker build .
FROM python:3-buster FROM python:3-buster AS build-and-install
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/src/app/bin ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/src/app/bin \
DEBIAN_FRONTEND=noninteractive \
# Make stdout/stderr unbuffered. This prevents delay between output and cloud. SASQUATCH_COMMIT=3e0cc40fc6dbe32bd3a5e6c553b3320d5d91ceed \
# Might not be needed by all apps, but slow ALL of them. test per app/container UBIREADER_COMMIT=0955e6b95f07d849a182125919a1f2b6790d5b51 \
#ENV PYTHONUNBUFFERED "1" BINWALK_COMMIT=3154b0012e7dbaf2b20edd5c0a2350ec64009869
### To prevent the Debian installer from freaking out on configuration of packages
ENV DEBIAN_FRONTEND noninteractive
# Pinned versions of few oddball dependencies
ENV SASQUATCH_COMMIT 3e0cc40fc6dbe32bd3a5e6c553b3320d5d91ceed
ENV UBIREADER_COMMIT 0955e6b95f07d849a182125919a1f2b6790d5b51
ENV BINWALK_COMMIT 3154b0012e7dbaf2b20edd5c0a2350ec64009869
COPY . /tmp COPY . /tmp
WORKDIR /tmp WORKDIR /tmp
### Took out the deps.sh from binwalk's installation script, baked in the dependencies into the main prereqs installation ### Took out the deps.sh from binwalk's installation script, baked in the dependencies into the main prereqs installation
...@@ -25,36 +16,36 @@ RUN set -xue \ ...@@ -25,36 +16,36 @@ RUN set -xue \
&& apt-get -t buster dist-upgrade -yq --no-install-recommends -o Dpkg::Options::="--force-confold" \ && apt-get -t buster dist-upgrade -yq --no-install-recommends -o Dpkg::Options::="--force-confold" \
&& ./deps.sh --yes \ && ./deps.sh --yes \
&& python3 setup.py install && binwalk -h > /dev/null \ && python3 setup.py install && binwalk -h > /dev/null \
&& apt-get -yq purge *-dev git build-essential gcc g++ \
&& apt-get -y autoremove \
&& apt-get -y autoclean \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& echo "LANG=en_US.UTF-8" >> /etc/default/locale \ && echo "LANG=en_US.UTF-8" >> /etc/default/locale \
&& echo "LANGUAGE=en_US:en" >> /etc/default/locale \ && echo "LANGUAGE=en_US:en" >> /etc/default/locale \
&& echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale \ && echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale \
&& locale-gen \ && locale-gen
&& apt-get -y autoremove \
&& apt-get -y autoclean \ FROM build-and-install AS unit-tests
&& useradd -m -u 1000 -s /sbin/nologin appuser \ RUN pip install coverage nose \
&& python3 setup.py test \
&& dd if=/dev/urandom of=/tmp/random.bin bs=1M count=1 && binwalk -J -E /tmp/random.bin
FROM build-and-install AS cleanup-and-release
RUN useradd -m -u 1000 -s /sbin/nologin appuser \
&& rm -rf -- \ && rm -rf -- \
/var/lib/apt/lists/* \ /var/lib/apt/lists/* \
/tmp/* /var/tmp/* \ /tmp/* /var/tmp/* \
/usr/src/app/*.whl /usr/src/app/*.tar.gz \ /root/.cache/pip
/root/.cache/pip \
/usr/src/app/repos \
/usr/src/app/.git \
/usr/src/app/src
ENV DEBIAN_FRONTEND teletype
# Setup locale. This prevents Python 3 IO encoding issues. # Setup locale. This prevents Python 3 IO encoding issues.
ENV LANG en_US.UTF-8 ENV DEBIAN_FRONTEND=teletype \
ENV LANGUAGE en_US:en LANG=en_US.UTF-8 \
ENV LC_ALL en_US.UTF-8 LANGUAGE=en_US:en \
ENV PYTHONUTF8 "1" LC_ALL=en_US.UTF-8 \
ENV PYTHONHASHSEED "random" PYTHONUTF8="1" \
PYTHONHASHSEED="random"
WORKDIR /home/appuser WORKDIR /home/appuser
USER appuser USER appuser
# dummy run because it creates some files on first run in home dir
RUN binwalk -h > /dev/null
ENTRYPOINT ["binwalk"] ENTRYPOINT ["binwalk"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment