Skip to content

Commit

Permalink
Add build hook for dockerhub
Browse files Browse the repository at this point in the history
Thanks to this hook, behavioral-model:latest will be built from
pi:latest and behavioral-model:stable will be built from pi:stable.
  • Loading branch information
antoninbas committed May 30, 2018
1 parent d5ddf82 commit 44f83ca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM p4lang/pi:latest
LABEL maintainer="Seth Fowler <[email protected]>"
ARG PARENT_VERSION=latest
FROM p4lang/pi:${PARENT_VERSION}
LABEL maintainer="Antonin Bas <[email protected]>"

# Default to using 2 make jobs, which is a good default for CI. If you're
# building locally or you know there are more cores available, you may want to
Expand Down
3 changes: 3 additions & 0 deletions hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hooks for dockerhub build.
See [docker
documentation](https://docs.docker.com/docker-cloud/builds/advanced/#override-build-test-or-push-commands).
20 changes: 20 additions & 0 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Overrides the default build command with one that sets PARENT_VERSION arg to
# the appropriate value. behavioral-model:latest will be built from pi:latest,
# while behavioral-model:stable will be built from pi:stable. Thanks to this we
# don't have to duplicate the Dockerfile for the sake of dockerhub.

# dockerhub uses DOCKER_TAG and not CACHE_TAG
echo "DOCKER_TAG: $DOCKER_TAG"
# echo "CACHE_TAG: $CACHE_TAG"
# dockerhub seems to be using BUILD_PATH and not DOCKERFILE_PATH (which is
# empty)
echo "BUILD_PATH: $BUILD_PATH"
# echo "DOCKERFILE_PATH: $DOCKERFILE_PATH"
echo "IMAGE_NAME: $IMAGE_NAME"
DOCKERFILE_PATH_OPTION=
if [ "$BUILD_PATH" != "/" ]; then
# remove leading '/'
DOCKERFILE_PATH_OPTION="-f ${BUILD_PATH:1}"
fi
docker build --build-arg PARENT_VERSION=$DOCKER_TAG $DOCKERFILE_PATH_OPTION -t $IMAGE_NAME .

0 comments on commit 44f83ca

Please sign in to comment.