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
.coverage
*.extracted
*.pyc
.editorconfig
.gitignore
images
Dockerfile
.dockerignore
.git
......@@ -13,19 +13,31 @@ script: ./setup.py test
cache: pip
jobs:
include:
- dist: bionic
- stage: test
dist: bionic
python: 3.6
- dist: bionic
- stage: test
dist: bionic
python: 3.7
- dist: bionic
- stage: test
dist: bionic
python: 3.8
- dist: bionic
- stage: test
dist: bionic
python: 3.9
- dist: focal
- stage: test
dist: focal
python: 3.6
- dist: focal
- stage: test
dist: focal
python: 3.7
- dist: focal
- stage: test
dist: focal
python: 3.8
- dist: focal
- stage: test
dist: focal
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
# Make stdout/stderr unbuffered. This prevents delay between output and cloud.
# Might not be needed by all apps, but slow ALL of them. test per app/container
#ENV PYTHONUNBUFFERED "1"
### 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
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/src/app/bin \
DEBIAN_FRONTEND=noninteractive \
SASQUATCH_COMMIT=3e0cc40fc6dbe32bd3a5e6c553b3320d5d91ceed \
UBIREADER_COMMIT=0955e6b95f07d849a182125919a1f2b6790d5b51 \
BINWALK_COMMIT=3154b0012e7dbaf2b20edd5c0a2350ec64009869
COPY . /tmp
WORKDIR /tmp
### 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 \
&& apt-get -t buster dist-upgrade -yq --no-install-recommends -o Dpkg::Options::="--force-confold" \
&& ./deps.sh --yes \
&& 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 "LANG=en_US.UTF-8" >> /etc/default/locale \
&& echo "LANGUAGE=en_US:en" >> /etc/default/locale \
&& echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale \
&& locale-gen \
&& apt-get -y autoremove \
&& apt-get -y autoclean \
&& useradd -m -u 1000 -s /sbin/nologin appuser \
&& locale-gen
FROM build-and-install AS unit-tests
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 -- \
/var/lib/apt/lists/* \
/tmp/* /var/tmp/* \
/usr/src/app/*.whl /usr/src/app/*.tar.gz \
/root/.cache/pip \
/usr/src/app/repos \
/usr/src/app/.git \
/usr/src/app/src
/root/.cache/pip
ENV DEBIAN_FRONTEND teletype
# Setup locale. This prevents Python 3 IO encoding issues.
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV PYTHONUTF8 "1"
ENV PYTHONHASHSEED "random"
ENV DEBIAN_FRONTEND=teletype \
LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
PYTHONUTF8="1" \
PYTHONHASHSEED="random"
WORKDIR /home/appuser
USER appuser
# dummy run because it creates some files on first run in home dir
RUN binwalk -h > /dev/null
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