Skip to content

Commit

Permalink
#419 Build instructions for Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
developster committed Feb 8, 2022
1 parent ec7cb52 commit 41e891e
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 32 deletions.
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**/.git*

target
*/target
ui/build
ui/node
ui/node_modules

.idea
**/*.iml

**/LOG_DIR_IS_UNDEFINED
**/derby.log

Dockerfile
Jenkinsfile
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM maven:3.8.4-openjdk-17 as base
WORKDIR /tmp/app
COPY checkstyle checkstyle
RUN --mount=type=cache,target=/root/.m2 \
cd checkstyle && mvn -B package \
&& mvn -B install:install-file -DlocalRepositoryPath=/tmp/app/.m2 -Dfile=target/checkstyle.jar -DpomFile=pom.xml \
&& rm -rf target
COPY . .

FROM base as build
ARG BRANCH_NAME
RUN --mount=type=cache,target=/root/.m2 \
--mount=type=cache,target=/root/.npm \
mvn -B -U package -DextraLocalRepositoryPath=/tmp/app/.m2 -DnpmInstallArg=ci -Dgit.branch=$BRANCH_NAME \
&& cp forms/target/forms.jar forms \
&& rm -rf ui/node ui/node_modules ui/build target */target

FROM openjdk:17
RUN mkdir /var/log/app /var/derby
ENV LOG_DIR=/var/log/app
WORKDIR /opt/app
COPY --from=build /tmp/app/forms/forms.jar .
CMD ["java", "-Dwicket.ioc.useByteBuddy=true", "-Dderby.system.home=/var/derby", "-jar", "/opt/app/forms.jar"]
21 changes: 21 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env groovy
pipeline {
agent {
label 'docker'
}
environment {
appTag = env.BRANCH_NAME.replaceAll('[^\\p{Alnum}-]', '_').toLowerCase()
registry = 'registry.developmentgateway.org'
image = "${env.registry}/dgtkitapp:${env.appTag}"
}
stages {
stage('Build') {
steps {
withEnv(["DOCKER_BUILDKIT=1"]) {
sh "docker build --build-arg BRANCH_NAME=${env.appTag} -t ${env.image} ."
}
sh "docker push ${env.image}"
}
}
}
}
4 changes: 4 additions & 0 deletions checkstyle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
</properties>

<build>
<finalName>checkstyle</finalName>
</build>

<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
24 changes: 2 additions & 22 deletions forms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.devgateway.toolkit</groupId>
<artifactId>persistence-mongodb</artifactId>
Expand Down Expand Up @@ -277,6 +271,8 @@
</dependencies>

<build>
<finalName>forms</finalName>

<resources>
<resource>
<filtering>true</filtering>
Expand All @@ -299,22 +295,6 @@

<plugins>

<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>
</configuration>
</plugin>

<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
Expand Down
15 changes: 6 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<maven-release-plugin.version>3.0.0-M4</maven-release-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<javassist.version>3.27.0-GA</javassist.version>
<extraLocalRepositoryPath>${project.basedir}/.m2</extraLocalRepositoryPath>
</properties>

<modules>
Expand Down Expand Up @@ -99,6 +100,11 @@
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>checkstyle</id>
<name>checkstyle</name>
<url>file:${extraLocalRepositoryPath}</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
Expand All @@ -112,14 +118,6 @@
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<!-- run checkstyle `mvn clean install` once during project setup -->
<groupId>org.devgateway.toolkit</groupId>
<artifactId>checkstyle</artifactId>
<version>1.1</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
Expand Down Expand Up @@ -159,7 +157,6 @@
<groupId>org.devgateway.toolkit</groupId>
<artifactId>checkstyle</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<executions>
Expand Down
3 changes: 2 additions & 1 deletion ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<java.version>17</java.version>
<start-class>org.devgateway.toolkit.ui.UIWebApplication</start-class>
<checkstyle.skip>true</checkstyle.skip>
<npmInstallArg>install</npmInstallArg>
</properties>

<parent>
Expand Down Expand Up @@ -90,7 +91,7 @@
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
<arguments>${npmInstallArg}</arguments>
</configuration>
</execution>

Expand Down

0 comments on commit 41e891e

Please sign in to comment.