diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..a0cabb7fb05 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +**/.git +**/.gitmodules +**/.travis.yml +**/Dockerfile +**/*.md + +docs diff --git a/.travis.yml b/.travis.yml index 0b2b8af7b76..da55335e47f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index bd846529851..1a083517b45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,12 @@ FROM p4lang/behavioral-model:latest MAINTAINER Seth Fowler +# 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 \ @@ -11,14 +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 && \ + 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')