Skip to content

Commit

Permalink
Merge pull request #95 from yodamad/dev
Browse files Browse the repository at this point in the history
🐳  Dockerize application
  • Loading branch information
yodamad authored Jun 2, 2020
2 parents 2a5fd78 + 4f96b22 commit 49171d7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM openjdk:11-jre-slim

ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
JHIPSTER_SLEEP=0 \
JAVA_OPTS=""

RUN apt update && \
apt install -y git git-svn subversion

COPY target/svn-2-git-1.18.2.jar /usr/svn2git/

WORKDIR /usr/svn2git

EXPOSE 8080

CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "svn-2-git-1.18.2.jar"]
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>fr.yodamad.svn2git</groupId>
<artifactId>svn-2-git</artifactId>
<version>1.18.1</version>
<version>1.18.2</version>
<packaging>jar</packaging>
<name>Svn 2 GitLab</name>

Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:8-jre-alpine
FROM openjdk:11-jre-alpine

ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
JHIPSTER_SLEEP=0 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public enum StepEnum {
GIT_CLONE, GITLAB_PROJECT_CREATION, SVN_CHECKOUT, GIT_CLEANING, GIT_PUSH, CLEANING, GIT_MV, INIT, BRANCH_CLEAN,
TAG_CLEAN, README_MD, GIT_CONFIG_GC_AUTO_OFF, GIT_CONFIG_GLOBAL_GC_AUTO_OFF, GIT_GC_EXPLICIT,
GIT_DYNAMIC_LOCAL_CONFIG, GIT_SHOW_CONFIG, LIST_REMOVED_FILES, UPLOAD_TO_ARTIFACTORY, ARTIFACTORY_FOLDER_CLEANING,
SVN_COPY_ROOT_FOLDER, ULIMIT
SVN_COPY_ROOT_FOLDER, ULIMIT, GIT_SET_CONFIG
}
2 changes: 1 addition & 1 deletion src/main/java/fr/yodamad/svn2git/service/GitManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ public void removeHistory(WorkUnit workUnit, String branch, boolean isTag, Migra
}
}

// move/rename a branch and the corresponing reflog
// move/rename a branch and the corresponding reflog
// (i.e. rename the orphan branch - without history - to the passed in branch name)
// Note : This fails with exit code 128 (git branch -m tmp_tag) when only folders in the subversion tag.
// git commit -am above fails because no files
Expand Down
30 changes: 27 additions & 3 deletions src/main/java/fr/yodamad/svn2git/service/MigrationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public void startMigration(final long migrationId, final boolean retry) {

// 2.2. SVN checkout
gitManager.gitSvnClone(workUnit);
checkGitConfig(workUnit);

copyRootDirectory(workUnit);
// Migration is now reexecutable in cases where there is a failure
Expand Down Expand Up @@ -491,14 +492,37 @@ private void logGitConfig(WorkUnit workUnit) throws IOException, InterruptedExce
historyMgr.endStep(history, StatusEnum.DONE, null);
}

private void checkGitConfig(WorkUnit workUnit) throws IOException, InterruptedException {

MigrationHistory history = historyMgr.startStep(workUnit.migration, StepEnum.GIT_SET_CONFIG, "Log Git Config and origin of config.");
String gitCommand = "git config user.name";
//String workDir = format("%s/%s", workUnit.directory, workUnit.migration.getSvnProject());
try {
execCommand(workUnit.commandManager, workUnit.directory, gitCommand);
} catch (RuntimeException rEx) {
LOG.info("Git user.email and user.name not set, use default values based on gitlab user set in UI");
gitCommand = format("git config user.email %[email protected]", workUnit.migration.getUser());
execCommand(workUnit.commandManager, workUnit.directory, gitCommand);
gitCommand = format("git config user.name %s", workUnit.migration.getUser());
execCommand(workUnit.commandManager, workUnit.directory, gitCommand);
} finally {
historyMgr.endStep(history, StatusEnum.DONE, null);
}
}

private void logUlimit(WorkUnit workUnit) throws IOException, InterruptedException {

// On linux servers trace what ulimit value is
if (!isWindows) {
MigrationHistory history = historyMgr.startStep(workUnit.migration, StepEnum.ULIMIT, "Show Ulimit -u value.");
String command = "ulimit -u";
execCommand(workUnit.commandManager, workUnit.directory, command);
historyMgr.endStep(history, StatusEnum.DONE, null);
try {
String command = "ulimit -u";
execCommand(workUnit.commandManager, workUnit.directory, command);
} catch (Exception exc) {
// Ignore exception as it's just info displayed
} finally {
historyMgr.endStep(history, StatusEnum.DONE, null);
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/yodamad/svn2git/service/util/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static int execCommand(CommandManager commandManager, String directory, S
LOG.debug(format("Exit : %d", exitCode));

if (exitCode != 0) {
// trace successful commands
// trace failed commands
commandManager.addFailedCommand(directory, securedCommandToPrint, stderr);

throw new RuntimeException(stderr);
Expand Down

0 comments on commit 49171d7

Please sign in to comment.