Skip to content
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

Docker Image Configuration + Readme #696

Merged
merged 3 commits into from
Apr 2, 2024
Merged
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
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id 'signing'
id 'idea'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

group = "com.github.tsantalis"
Expand Down Expand Up @@ -134,3 +135,11 @@ signing {
tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}

def jarName = project.hasProperty('jarName') ? project.jarName : 'RM-fat.jar'
shadowJar {
manifest {
attributes 'Main-Class': 'org.refactoringminer.RefactoringMiner'
}
archiveFileName = jarName
}
1 change: 1 addition & 0 deletions Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ ENV LANG C.UTF-8
EXPOSE 6789

WORKDIR /diff
ENTRYPOINT ["refactoringminer"]
47 changes: 47 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# RefactoringMiner docker image

## Installation

You can directly pull a version of latest RefactoringMiner image from Docker Hub via the command `docker pull tsantalis/refactoringminer`.

You can also compile the image on your machine. Go to the root RefactoringMiner's folder and compile the image: `docker build . -f docker/Dockerfile -t tsantalis/refactoringminer`.

In addition to this image which relies on JDK, you can try our native-image which relies on GraalVM to compile the Java bytecode to native code for better performance: `docker build . -f docker/native/Dockerfile-native -t tsantalis/refactoringminer`.

## Usage

To use refactoringminer image, You need to:
* bind the port `6789` of the container to access web interface

The classical way to run the container is the command `docker run -v /my/original-folder:/diff/left -v /my/modified-folder:/diff/right -p 6789:6789 tsantalis/refactoringminer diff --src left/ --dst right/`. You can consult the diff at the URL `http://localhost:6789`.

Of course, all other RefactoringMiner's commands are available.


## Git integration

You can easily integrate RefactoringMiner's container with Git by adding the following configuration into the `$HOME/.gitconfig` file.

### Mac OS

```properties
[difftool "rm-docker"]
cmd = docker run -v /private/$LOCAL:/diff/left/ -v /private/$REMOTE:/diff/right/ -p 6789:6789 tsantalis/refactoringminer diff --src left/ --dst right/
```
### Linux - Windows

```properties
[difftool "rm-docker"]
cmd = docker run -v $LOCAL:/diff/left -v $REMOTE:/diff/right -p 6789:6789 tsantalis/refactoringminer diff --src left/ --dst right/
```

### Usage

You can invoke RefactoringMiner from git by running the command `git difftool -d --no-symlinks -t rm-docker`. We recommend putting an alias in the alias section of `$HOME/.gitconfig` such as:

```properties
[alias]
rmd = difftool -d --no-symlinks -t rm-docker
```

You can then use the command `git rmd`.
52 changes: 52 additions & 0 deletions docker/native/Dockerfile-native
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Stage 1: Build stage
FROM amazoncorretto:17 AS build

RUN yum install -y tar unzip

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=GMT

COPY . /opt/refactoringminer/

RUN /opt/refactoringminer/gradlew -x test -p /opt/refactoringminer build -PbuildVersion=DockerBuild 2>/dev/null
RUN unzip /opt/refactoringminer/build/distributions/RefactoringMiner-DockerBuild.zip -d /opt/refactoringminer/build/distributions


# Stage 2: Build stage for Native RM Image
FROM ghcr.io/graalvm/graalvm-community:21 AS native_build

# Copy necessary files from build stage or elsewhere
COPY --from=build /opt/refactoringminer/dockerMETA-INF /opt/META-INF/
COPY --from=build /opt/refactoringminer/build/libs/RM-fat.jar /opt/RM-fat.jar

WORKDIR /opt

RUN native-image --enable-url-protocols=https \
--allow-incomplete-classpath \
--no-fallback \
--enable-all-security-services \
--no-server \
--initialize-at-build-time=org.eclipse.jetty.util.thread.TryExecutor \
-H:+ReportExceptionStackTraces \
-H:ReflectionConfigurationFiles=docker/native/META-INF/reflect-config.json \
-H:ResourceConfigurationFiles=docker/native/META-INF/resource-config.json \
-H:DynamicProxyConfigurationFiles=docker/native/META-INF/proxy-config.json \
-H:JNIConfigurationFiles=docker/native/META-INF/jni-config.json \
-jar RM-fat.jar RM-native


# Stage 3: Runtime stage for Native RM Image
FROM alpine:latest

RUN mkdir -p /diff/left /diff/right
# Copy necessary files from build stage or elsewhere
COPY --from=native_build /opt/RM-native /opt/refactoringminer

RUN ln -s /opt/refactoringminer /usr/bin/refactoringminer

RUN apk add gcompat
ENV LANG C.UTF-8
EXPOSE 6789

WORKDIR /diff
ENTRYPOINT ["refactoringminer"]
10 changes: 10 additions & 0 deletions docker/native/META-INF/jni-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"name":"java.lang.Boolean",
"methods":[{"name":"getBoolean","parameterTypes":["java.lang.String"] }]
},
{
"name":"sun.management.VMManagementImpl",
"fields":[{"name":"compTimeMonitoringSupport"}, {"name":"currentThreadCpuTimeSupport"}, {"name":"objectMonitorUsageSupport"}, {"name":"otherThreadCpuTimeSupport"}, {"name":"remoteDiagnosticCommandsSupport"}, {"name":"synchronizerUsageSupport"}, {"name":"threadAllocatedMemorySupport"}, {"name":"threadContentionMonitoringSupport"}]
}
]
8 changes: 8 additions & 0 deletions docker/native/META-INF/predefined-classes-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"type":"agent-extracted",
"classes":[
]
}
]

2 changes: 2 additions & 0 deletions docker/native/META-INF/proxy-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
Loading