Skip to content

Commit 1dc44dd

Browse files
docker: add docker files for splc replication
1 parent e8f7d61 commit 1dc44dd

10 files changed

Lines changed: 169 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM alpine:3.15
4+
# PACKAGE STAGE
5+
6+
# Prepare the compile environment. JDK is automatically installed
7+
RUN apk add maven
8+
9+
# Create and navigate to a working directory
10+
WORKDIR /home/user
11+
12+
COPY local-maven-repo ./local-maven-repo
13+
14+
# Copy the source code
15+
COPY src ./src
16+
# Copy the pom.xml if Maven is used
17+
COPY pom.xml .
18+
# Execute the maven package process
19+
RUN mvn package || exit
20+
21+
FROM alpine:3.15
22+
23+
# Create a user
24+
RUN adduser --disabled-password --home /home/sherlock --gecos '' sherlock
25+
26+
RUN apk add --no-cache --upgrade bash
27+
RUN apk add --update openjdk17
28+
29+
# Change into the home directory
30+
WORKDIR /home/sherlock
31+
32+
# Copy the compiled JAR file from the first stage into the second stage
33+
# Syntax: COPY --from=STAGE_ID SOURCE_PATH TARGET_PATH
34+
WORKDIR /home/sherlock/holmes
35+
COPY --from=0 /home/user/target/diffdetective-1.0.0-jar-with-dependencies.jar ./DiffDetective.jar
36+
WORKDIR /home/sherlock
37+
38+
# Copy the setup
39+
COPY docs holmes/docs
40+
41+
# Copy the docker resources
42+
COPY docker/* ./
43+
COPY replication/splc23-views/docker/* ./
44+
RUN mkdir DiffDetectiveMining
45+
RUN mkdir results
46+
47+
# Adjust permissions
48+
RUN chown sherlock:sherlock /home/sherlock -R
49+
RUN chmod +x execute.sh
50+
RUN chmod +x entrypoint.sh
51+
RUN chmod +x fix-perms.sh
52+
53+
# Set the entrypoint
54+
ENTRYPOINT ["./entrypoint.sh", "./execute.sh"]
55+
56+
# Set the user
57+
USER sherlock

replication/splc23-views/build.bat

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@echo off
2+
setlocal
3+
4+
set "targetSubPath=splc23-views"
5+
6+
rem Get the current directory
7+
for %%A in ("%CD%") do set "currentDir=%%~nxA"
8+
9+
rem Check if the current directory ends with the target sub-path
10+
if "%currentDir:~-9%"=="%targetSubPath%" (
11+
cd ..\..
12+
docker build -t diff-detective-views replication\splc23-views\Dockerfile .
13+
@pause
14+
) else (
15+
echo error: the script must be run from inside the splc23-views directory, i.e., DiffDetective\replication\%targetSubPath%
16+
)
17+
endlocal
18+

replication/splc23-views/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
# Assure that the script is only called from the splc23-views folder
3+
current_dir=$(pwd)
4+
expected_path="/replication/splc23-views"
5+
if [[ ! $current_dir =~ $expected_path ]]; then
6+
echo "error: the script must be run from inside the splc23-views directory, i.e., DiffDetective$expected_path"
7+
exit 1
8+
fi
9+
10+
# We have to switch to the root directory of the project and build the Docker image from there,
11+
# because Docker only allows access to the files in the current file system subtree (i.e., no access to ancestors).
12+
# We have to do this to get access to 'src', 'docker', 'local-maven-repo', etc.
13+
cd ../..
14+
15+
docker build -t diff-detective-views -f replication/splc23-views/Dockerfile .
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Docker Files
2+
3+
This directory contains the files that are required to run the Docker container.
4+
5+
## Execution
6+
The [`execute.sh`](execute.sh) script can be adjusted to run the program that should be executed by the Docker container.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /bin/bash
2+
3+
if [ "$1" == '' ] || [ "$1" == '--help' ] || [ "$1" == '-help' ]; then
4+
echo ">>>>>>>>> USAGE <<<<<<<<<<"
5+
echo "Either fully run DiffDetective as presented in the paper (replication), do quick setup verification (verification),
6+
or run DiffDetective on a custom dataset by providing the path to the dataset file."
7+
echo ""
8+
echo "-- Examples --"
9+
echo "Run replication: './execute.sh replication'"
10+
echo "Validate the setup: './execute.sh verification'"
11+
echo "# See ./docs/datasets/esecfse22-verification.md for format details"
12+
echo "Custom dataset: './execute.sh path/to/my_dataset.md'"
13+
exit
14+
fi
15+
cd /home/sherlock || exit
16+
cd holmes || exit
17+
18+
if [ "$1" == 'replication' ]; then
19+
echo "Running full replication. Depending on your system, this will require several hours or even a few days."
20+
java -cp DiffDetective.jar org.variantsync.diffdetective.experiments.views.Main docs/datasets/esecfse22-replication.md
21+
elif [ "$1" == 'verification' ]; then
22+
echo "Running a short verification."
23+
java -cp DiffDetective.jar org.variantsync.diffdetective.experiments.views.Main docs/datasets/esecfse22-verification.md
24+
else
25+
echo ""
26+
echo "Running detection on a custom dataset with the input file $1"
27+
echo ""
28+
java -cp DiffDetective.jar org.variantsync.diffdetective.experiments.views.Main "$1"
29+
fi
30+
echo "Collecting results."
31+
cp -r results/* ../results/
32+
python analyze_data.py ../results/validation/current
33+
echo "The results are located in the 'results' directory."
34+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@echo off
2+
setlocal
3+
4+
set "targetSubPath=splc23-views"
5+
6+
rem Get the current directory
7+
for %%A in ("%CD%") do set "currentDir=%%~nxA"
8+
9+
rem Check if the current directory ends with the target sub-path
10+
if "%currentDir:~-9%"=="%targetSubPath%" (
11+
docker run --rm -v "%cd%\results":"/home/sherlock/results" diff-detective %*
12+
) else (
13+
echo error: the script must be run from inside the splc23-views directory, i.e., DiffDetective\replication\%targetSubPath%
14+
)
15+
endlocal
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
# Assure that the script is only called from the splc23-views folder
3+
current_dir=$(pwd)
4+
expected_path="/replication/splc23-views"
5+
if [[ ! $current_dir =~ $expected_path ]]; then
6+
echo "error: the script must be run from inside the splc23-views directory, i.e., DiffDetective$expected_path"
7+
exit 1
8+
fi
9+
10+
if [[ $# -gt 0 ]]; then
11+
echo "Executing $1"
12+
fi
13+
docker run --rm -v "$(pwd)/results":"/home/sherlock/results" diff-detective "$@"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo "Stopping all running simulations. This will take a moment..."
2+
@FOR /f "tokens=*" %%i IN ('docker ps -a -q --filter "ancestor=diff-detective-views"') DO docker stop %%i
3+
@echo "...done."
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /bin/bash
2+
echo "Stopping Docker container. This will take a moment..."
3+
docker stop "$(docker ps -a -q --filter "ancestor=diff-detective-views")"
4+
echo "...done."

0 commit comments

Comments
 (0)