Skip to content

Commit

Permalink
Merge pull request #192 from cticenhour/improve-docker-build
Browse files Browse the repository at this point in the history
Improvements to the docker build script
  • Loading branch information
csdechant authored Apr 14, 2023
2 parents 709f636 + 12ee59c commit ed6b617
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ updates:
day: "saturday"
time: "01:00"
directory: "/"
allow:
# Allow updates for crane and squirrel....moose is updated through CIVET
- dependency-name: "crane"
- dependency-name: "squirrel"
# Maintain dependencies for GitHub Actions once a month
- package-ecosystem: "github-actions"
schedule:
Expand Down
15 changes: 4 additions & 11 deletions doc/content/development/zapdos_developer_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ is desired, please refer to the [moose_developer_info.md] page.
## Update and Build a New Docker Container

!style halign=left
The Zapdos docker container image should be updated whenever Zapdos source code or submodules (CRANE,
Squirrel, or MOOSE) are updated and those changes are merged into the master branch. Whenever the
MOOSE submodule is updated, in particular, the submodule git commit hash must be copied and entered
into the `Dockerfile` so that the proper MOOSE docker image can be used with the Zapdos image.

To build a new docker container, first fetch the most up-to-date version of the Zapdos master branch.
Assuming that Zapdos is stored in `~/projects/` and that your `upstream` remote is referencing
The Zapdos docker container image should be updated whenever Zapdos source code or that of submodules
(CRANE, Squirrel, or MOOSE) are updated and those changes are merged into the master branch. To build
a new docker container, first fetch the most up-to-date version of the Zapdos master branch. Assuming
that Zapdos is stored in `~/projects/` and that your `upstream` remote is referencing
[shannon-lab/zapdos](https://github.com/shannon-lab/zapdos.git):

```bash
Expand Down Expand Up @@ -68,7 +65,3 @@ INFO: Push to Docker Hub disabled. If desired in the future, run this script
docker push shannonlab/zapdos:2c4a214d4d55106ac6c8c9058e3b224a46ba416d
docker push shannonlab/zapdos:latest
```




4 changes: 2 additions & 2 deletions Dockerfile → scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DON'T FORGET: Modify this hash to be consistent with the MOOSE submodule!
FROM idaholab/moose:5e60aeb38c948f5db9e98b2080724b87188f5ee2
# Template variable is replaced with hash when build_docker.sh is run!
FROM idaholab/moose:{{MOOSE_HASH}}

WORKDIR /opt

Expand Down
14 changes: 6 additions & 8 deletions scripts/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,27 @@ fi
# Enter Zapdos source location, checkout master branch, and save latest git commit hash
cd $ZAPDOS_DIR
git checkout master
DOCKERFILE_HASH=$(cat Dockerfile | grep "FROM idaholab/moose:" | cut -d: -f2)
ZAPDOS_MASTER_HASH=$(git rev-parse master)

# Get MOOSE submodule hash and compare to Dockerfile to make sure it has been updated
git submodule update --init moose
cd moose
MOOSE_HASH=$(git rev-parse HEAD)

if [[ ! $DOCKERFILE_HASH == $MOOSE_HASH ]]; then
echo ""
echo "ERROR: Dockerfile has not been updated to be consistent with the MOOSE submodule!"
echo " Aborting docker build!"
exit 1
fi
cd $ZAPDOS_DIR/scripts

cd $ZAPDOS_DIR
# Use sed to find and replace MOOSE submodule hash into Dockerfile
sed -i '' "s/{{MOOSE_HASH}}/$MOOSE_HASH/g" Dockerfile

# Build docker container and tag it with master git hash
docker build -t shannonlab/zapdos:"$ZAPDOS_MASTER_HASH" . || exit $?

# Retag newly built container to make a second one with the tag "latest"
docker tag shannonlab/zapdos:"$ZAPDOS_MASTER_HASH" shannonlab/zapdos:latest

# Restore Dockerfile to un-modified state so that branch is clean
git restore Dockerfile

# Push both containers to Docker Hub, if enabled. If not, display a notice to the screen with more info
if [[ $PUSH == 1 ]]; then
docker push shannonlab/zapdos:$ZAPDOS_MASTER_HASH
Expand Down

0 comments on commit ed6b617

Please sign in to comment.