Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ out
local.properties
.idea
.DS_Store
build
build

/.gradle-docker-cache
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To contribute code to ODK Validate, you will need to open a [pull request](https

1. Keep your pull request focused on one narrow goal. This could mean addressing an issue with multiple, smaller pull requests. Small pull requests are easier to review and less likely to introduce bugs. If you would like to make stylistic changes to the code, create a separate pull request.

1. Run `./gradlew lint` and `./gradlew check` and fix any errors.
1. Run `./gradlew lint && ./gradlew check`, or `./gradle-docker lint && ./gradle-docker check`, and fix any errors.

1. Write clear code. Use descriptive names and create meaningful abstractions (methods, classes).

Expand Down
32 changes: 32 additions & 0 deletions gradle-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail

imageTag="gradlew-jdk-8"

log() { echo >&2 "[gradle-docker] $*"; }

rebuildImage=false
if [[ -n "${REBUILD_GRADLE_DOCKER_IMAGE-}" ]]; then
rebuildImage=true
fi

log "Checking for existing image..."
if [[ "$rebuildImage" = false ]] && docker image inspect "$imageTag" >/dev/null 2>&1; then
log "Existing image found."
else
log "Building docker image..."
docker build --tag "$imageTag" --file - . <<EOF
FROM eclipse-temurin:8-jdk
WORKDIR /app
ENV GRADLE_USER_HOME=/app/.gradle-docker-cache
ENTRYPOINT ["/app/gradlew"]
EOF
log "Docker image built."
fi

currentUser="$(id -u):$(id -g)" # ensure ownership of docker-created files
exec docker run --rm \
--user "$currentUser" \
--volume "$PWD":/app \
"$imageTag" \
"$@"
Loading