-
Notifications
You must be signed in to change notification settings - Fork 206
Add docker image, devcontainer, and editorconfig support #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
a6a085c
add basic editor config to root dir
bpkroth b08fdd1
improve editor config
bpkroth b9547f2
ignore vim swap files
bpkroth ae683ca
Add devcontainer support
bpkroth 386c4ee
instruction comments
bpkroth 5f5c2ad
refactor the docker containers
bpkroth a79f923
adding some short readme text on how to build and use the docker images
bpkroth 7c1d26b
Merge branch 'main' into bpkroth/devcontainer
apavlo 109a44f
Add basic CI jobs for docker image as well
bpkroth 46447dd
reorg docker layers to save space and make testing a build arg
bpkroth 1461881
fixup
bpkroth d0630bf
more fixups
bpkroth 04abd03
try again
bpkroth 22d4b5b
split docker build and run into two dependent jobs
bpkroth f41160f
fix copy/paste error
bpkroth ff74053
fixups to allow setting the UID/GID of the container user to match gi…
bpkroth f0c0e30
override the base image's user env for MAVEN_CONFIG path
bpkroth ada13ac
fixups for non-buildkit based docker builds
bpkroth 53f931d
more dev container image size reduction
bpkroth 0ebb3ff
enable docker buildkit
bpkroth 434f454
attempt to build and run the docker image in the same job
bpkroth d99eb29
fixup
bpkroth 7b94308
quoting fixup and additional comments
bpkroth 59f78fb
quoting
bpkroth cbbbfbb
docker run can't be interactive in CI pipeline
bpkroth bddf639
Merge branch 'main' into bpkroth/devcontainer
bpkroth b7d7b2c
fix a permissions issue
bpkroth e3ad4eb
spelling
bpkroth c59ef1a
Merge branch 'main' into bpkroth/devcontainer
apavlo df4a56b
Merge branch 'main' into bpkroth/devcontainer
bpkroth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
| // https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/docker-existing-dockerfile | ||
| { | ||
| "name": "Workspace Dockerfile", | ||
|
|
||
| // Sets the run context to one level up instead of the .devcontainer folder. | ||
| "context": "..", | ||
|
|
||
| // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. | ||
| "dockerFile": "../docker/benchbase/Dockerfile", | ||
| "build": { | ||
| "target": "devcontainer", | ||
| "args": { | ||
| "--tag": "benchbase-dev:latest" | ||
| } | ||
| }, | ||
|
|
||
| // Set *default* container specific settings.json values on container create. | ||
| "settings": {}, | ||
|
|
||
| // Add the IDs of extensions you want installed when the container is created. | ||
| "extensions": [ | ||
| "vscjava.vscode-java-pack", | ||
| "EditorConfig.EditorConfig" | ||
| ], | ||
|
|
||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
| // "forwardPorts": [], | ||
|
|
||
| // Uncomment the next line to run commands after the container is created - for example installing curl. | ||
| // "postCreateCommand": "apt-get update && apt-get install -y curl", | ||
|
|
||
| // Uncomment when using a ptrace-based debugger like C++, Go, and Rust | ||
| // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], | ||
|
|
||
| // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. | ||
| // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], | ||
|
|
||
| // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. | ||
| "remoteUser": "containeruser" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| .dockerignore | ||
| docker/ | ||
| !docker/benchbase/entrypoint.sh | ||
| #.git/ | ||
| .github/ | ||
| .mvn/ | ||
| mvnw.cmd | ||
| mvnw | ||
| target/ | ||
| results/ | ||
| profiles/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| indent_style = space | ||
| indent_size = 4 | ||
| trim_trailing_whitespace = true | ||
|
|
||
| # Makefiles need tab indentation | ||
| [{Makefile,*.mk}] | ||
| indent_style = tab | ||
| tab_width = 8 | ||
| end_of_line = lf | ||
|
|
||
| [{*.ps1,*.cmd,*.bat}] | ||
| end_of_line = crlf | ||
|
|
||
| [*.sh] | ||
| end_of_line = lf | ||
|
|
||
| [*.yml] | ||
| indent_size = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,3 +49,6 @@ build/ | |
| ### VS Code ### | ||
| .vscode/ | ||
| *.log | ||
|
|
||
| # vim swap files | ||
| .*.swp | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # A simple dev environment container for benchbase. | ||
| # | ||
| # - Build: | ||
| # | ||
| # - Full image: | ||
| # | ||
| # docker build -t benchbase -f Dockerfile ../.. | ||
| # | ||
| # - Dev only: | ||
| # | ||
| # # Skip copying and building the source into the devcontainer image since we will map it in later. | ||
| # docker build -t benchbase-dev -f Dockerfile --target devcontainer ../.. | ||
| # | ||
| # - Run: | ||
| # | ||
| # - Full image: | ||
| # | ||
| # # Map the config to read in and a place for the results to be written out. | ||
| # docker run -it --rm --name benchbase -v $PWD/config:/benchbase/config -v $PWD/results:/benchbase/results --env BENCHBASE_PROFILE=postgres benchbase -- <benchbase args> | ||
| # | ||
| # - Dev image: | ||
| # | ||
| # # Map the whole source directory into the container. | ||
| # # Optionally build the source as the container launch executable. | ||
| # docker run -it --rm --name benchbase-dev -v $PWD:/benchbase benchbase-dev mvn clean package -P postgres | ||
|
|
||
| FROM --platform=linux maven:3.8.5-eclipse-temurin-17 AS devcontainer | ||
|
|
||
| # Add a containeruser that allows vscode/codespaces to map the local host user | ||
| # (often uid 1000) to some non-root user inside the container. | ||
| ARG UID=1000 | ||
| ARG GID=1000 | ||
| RUN addgroup --gid ${GID} containergroup \ | ||
| && adduser --disabled-password --gecos 'Container User' --uid ${UID} --gid ${GID} containeruser | ||
| RUN mkdir -p /benchbase/results && chown -R containeruser:containergroup /benchbase/ | ||
| USER containeruser | ||
| ENV MAVEN_CONFIG=/home/containeruser/.m2 | ||
| WORKDIR /benchbase | ||
|
|
||
| # When running the devcontainer, just launch an interactive shell by default. | ||
| ENTRYPOINT ["/bin/bash", "-l"] | ||
|
|
||
| # Copy the full source into the container image. | ||
| # Assumes the context is given as the root of the repo. | ||
|
|
||
| # Preload some dependencies. | ||
| COPY --chown=containeruser:containergroup pom.xml /benchbase/pom.xml | ||
| COPY --chown=containeruser:containergroup .git/ /benchbase/.git/ | ||
| ARG MAVEN_OPTS | ||
| RUN mvn -B --file pom.xml initialize \ | ||
| && rm -rf /benchbase/.git /benchbase/target /benchbase/pom.xml | ||
|
|
||
| # Add an additional layer that also includes a built copy of the source. | ||
| FROM devcontainer AS fullimage | ||
|
|
||
| USER containeruser | ||
|
|
||
| VOLUME /benchbase/results | ||
|
|
||
| COPY --chown=containeruser:containergroup ./ /benchbase/ | ||
| # Uncomment for slightly faster incremental testing (since intermediate layers can be cached) | ||
| # at the expense of additional docker image layers. | ||
| ARG TEST_TARGET= | ||
| RUN mvn -B --file pom.xml process-resources compile ${TEST_TARGET} | ||
| # Build all of the profiles into the image. | ||
| ARG BENCHBASE_PROFILES="cockroachdb mariadb mysql postgres spanner phoenix sqlserver" | ||
| RUN for profile in ${BENCHBASE_PROFILES}; do \ | ||
| mvn -B --file pom.xml package -P $profile -D skipTests || exit 1; \ | ||
| mkdir -p profiles/$profile; \ | ||
| tar -C profiles/$profile/ --strip-components=1 -xvzf target/benchbase-$profile.tgz || exit 1; \ | ||
| rm -rf profiles/$profile/data/ && ln -s ../../data profiles/$profile/data; \ | ||
| done \ | ||
| && test -d data \ | ||
| && test "`readlink -f profiles/postgres/data`" = "/benchbase/data" \ | ||
| && mvn -B --file pom.xml clean \ | ||
| && rm -rf ~/.m2/repository/* \ | ||
| && rm -rf .git/ | ||
|
|
||
| ENV BENCHBASE_PROFILE=postgres | ||
| ENTRYPOINT ["/benchbase/docker/benchbase/entrypoint.sh"] | ||
| CMD ["--help"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| build-full-image.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eu | ||
|
|
||
| BENCHBASE_PROFILES="${BENCHBASE_PROFILES:-cockroachdb mariadb mysql postgres spanner phoenix sqlserver}" | ||
|
|
||
| scriptdir=$(dirname "$(readlink -f "$0")") | ||
| rootdir=$(readlink -f "$scriptdir/../../") | ||
| cd "$rootdir" | ||
|
|
||
| http_proxy_host='' | ||
| http_proxy_port='' | ||
| https_proxy_host='' | ||
| https_proxy_port='' | ||
|
|
||
| if echo "$http_proxy" | egrep -q 'http[s]?://[^:]+:[0-9]+[/]?$'; then | ||
| http_proxy_host=$(echo "$http_proxy" | sed -r -e 's|^http[s]?://([^:]+):([0-9]+)[/]?$|\1|') | ||
| http_proxy_port=$(echo "$http_proxy" | sed -r -e 's|^http[s]?://([^:]+):([0-9]+)[/]?$|\2|') | ||
| fi | ||
|
|
||
| if echo "$https_proxy" | egrep -q 'http[s]?://[^:]+:[0-9]+[/]?$'; then | ||
| https_proxy_host=$(echo "$https_proxy" | sed -r -e 's|^http[s]?://([^:]+):([0-9]+)[/]?$|\1|') | ||
| https_proxy_port=$(echo "$https_proxy" | sed -r -e 's|^http[s]?://([^:]+):([0-9]+)[/]?$|\2|') | ||
| fi | ||
|
|
||
| target= | ||
| tag= | ||
| basename=$(basename "$0") | ||
| if [ "$basename" == "build-full-image.sh" ]; then | ||
| target='fullimage' | ||
| tag='benchbase' | ||
| elif [ "$basename" == "build-dev-image.sh" ]; then | ||
| target='devcontainer' | ||
| tag='benchbase-dev' | ||
| else | ||
| echo "ERROR: Unhandled mode: $basename" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| GID=$(getent passwd $UID | cut -d: -f4) | ||
|
|
||
| set -x | ||
| docker build --build-arg=http_proxy=${http_proxy:-} --build-arg=https_proxy=${https_proxy:-} \ | ||
| --build-arg MAVEN_OPTS="-Dhttp.proxyHost=${http_proxy_host} -Dhttp.proxyPort=${http_proxy_port} -Dhttps.proxyHost=${https_proxy_host} -Dhttps.proxyPort=${https_proxy_port}" \ | ||
| --build-arg BENCHBASE_PROFILES="${BENCHBASE_PROFILES}" \ | ||
| --build-arg UID=$UID --build-arg GID=$GID \ | ||
| -t $tag -f ./docker/benchbase/Dockerfile --target $target . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
|
|
||
| # fullimage docker entrypoint script | ||
|
|
||
| BENCHBASE_PROFILE="${BENCHBASE_PROFILE:-postgres}" | ||
| cd /benchbase | ||
| echo "INFO: Using environment variable BENCHBASE_PROFILE=${BENCHBASE_PROFILE} with args: $*" >&2 | ||
| java -jar "./profiles/${BENCHBASE_PROFILE}/benchbase.jar" $* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eu | ||
|
|
||
| scriptdir=$(dirname "$(readlink -f "$0")") | ||
| rootdir=$(readlink -f "$scriptdir/../../") | ||
|
|
||
| cd "$scriptdir" | ||
| ./build-dev-image.sh | ||
|
|
||
| cd "$rootdir" | ||
| docker run -it --rm -v "$PWD:/benchbase" benchbase-dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eu | ||
|
|
||
| BENCHBASE_PROFILE="${BENCHBASE_PROFILE:-postgres}" | ||
|
|
||
| scriptdir=$(dirname "$(readlink -f "$0")") | ||
| rootdir=$(readlink -f "$scriptdir/../../") | ||
|
|
||
| cd "$scriptdir" | ||
| ./build-full-image.sh | ||
|
|
||
| cd "$rootdir" | ||
| mkdir -p results/ | ||
| docker run -it --rm -v "$PWD/results:/benchbase/results" --env "BENCHBASE_PROFILE=$BENCHBASE_PROFILE" benchbase $* |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, this is useful for deploying the image as benchmarking agent in k8s, Azure Batch, etc.
However, it probably doesn't need a full JDK at that point.
One can save a little bit of space by removing the
/benchbase/srctree and theopenssh-client(andapt autoremoveing to get rid of the dependencies), but the real wins are in having the fullimage use the JRE instead of the JDK.I'm gonna call that future improvements for now though.