Skip to content

Commit

Permalink
Support different Docker images for normal builds and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sethfowler committed Apr 10, 2017
1 parent 8fbbbdf commit 61e090b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
- docker

install:
- docker build -t p4c .
- docker build -t p4c --build-arg IMAGE_TYPE=test .

script:
- docker run -w /p4c/build p4c make check VERBOSE=1
Expand Down
23 changes: 20 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
FROM p4lang/behavioral-model:latest
MAINTAINER Seth Fowler <seth.fowler@barefootnetworks.com>

# Select the type of image we're building. Use `build` for a normal build, which
# is optimized for image size. Use `test` if this image will be used for
# testing; in this case, the source code and build-only dependencies will not be
# removed from the image.
ARG IMAGE_TYPE=build

ENV P4C_DEPS automake \
bison \
build-essential \
Expand All @@ -11,15 +17,26 @@ ENV P4C_DEPS automake \
libgmp-dev \
libtool \
pkg-config \
python \
python-ipaddr \
python-scapy \
tcpdump
ENV P4C_RUNTIME_DEPS cpp \
libgc1c2 \
libgmp10 \
libgmpxx4ldbl \
python
COPY . /p4c/
WORKDIR /p4c/
RUN apt-get update && \
apt-get install -y --no-install-recommends $P4C_DEPS && \
apt-get install -y --no-install-recommends $P4C_DEPS $P4C_RUNTIME_DEPS && \
./bootstrap.sh && \
cd build && \
make && \
make install
make install && \
(test "$IMAGE_TYPE" = "build" && \
apt-get purge -y $P4C_DEPS && \
apt-get autoremove --purge -y && \
rm -rf /p4c /var/cache/apt/* /var/lib/apt/lists/* && \
echo 'Build image ready') || \
(test "$IMAGE_TYPE" = "test" && \
echo 'Test image ready')

0 comments on commit 61e090b

Please sign in to comment.