forked from cmu-db/benchbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker image, devcontainer, and editorconfig support (cmu-db#151)
Co-authored-by: Andy Pavlo <[email protected]>
- Loading branch information
Showing
12 changed files
with
312 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 $* |