From aae90ed9bd9b93da747b4654e794d7c6cbc8dec1 Mon Sep 17 00:00:00 2001
From: Emmanuel Bruno <emmanuel.bruno@univ-tln.fr>
Date: Thu, 18 Nov 2021 09:25:28 +0100
Subject: [PATCH] initial release.

---
 .env                                        |   2 +
 .gitignore                                  |  42 ++++++++
 Dockerfile                                  |  17 +++
 dependency-reduced-pom.xml                  |  91 +++++++++++++++++
 docker-compose.yml                          |  25 +++++
 docker_build.sh                             |   2 +
 docker_env.sh                               |   3 +
 docker_push.sh                              |   2 +
 docker_run.sh                               |   2 +
 pom.xml                                     | 108 ++++++++++++++++++++
 src/main/java/fr/univtln/bruno/App.java     |  13 +++
 src/test/java/fr/univtln/bruno/AppTest.java |  20 ++++
 12 files changed, 327 insertions(+)
 create mode 100644 .env
 create mode 100644 .gitignore
 create mode 100644 Dockerfile
 create mode 100644 dependency-reduced-pom.xml
 create mode 100644 docker-compose.yml
 create mode 100755 docker_build.sh
 create mode 100755 docker_env.sh
 create mode 100755 docker_push.sh
 create mode 100755 docker_run.sh
 create mode 100644 pom.xml
 create mode 100644 src/main/java/fr/univtln/bruno/App.java
 create mode 100644 src/test/java/fr/univtln/bruno/AppTest.java

diff --git a/.env b/.env
new file mode 100644
index 0000000..56ebe4f
--- /dev/null
+++ b/.env
@@ -0,0 +1,2 @@
+POSTGRES_USER=myappdba 
+POSTGRES_PASSWORD=ndfndsf13sff
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e7330e1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,42 @@
+target/
+.classpath
+.project
+.settings/
+Thumbs.db
+
+# built application files
+*.apk
+*.ap_
+
+# files for the dex VM
+*.dex
+
+# Java class files
+*.class
+
+# generated files
+bin/
+gen/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Eclipse project files
+.classpath
+.project
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Intellij project files
+*.iml
+*.ipr
+*.iws
+.idea/
+
+# Package Files #
+*.jar
+*.war
+*.ear%
+
+.DS_Storedependency-reduced-pom.xml
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..8bbcb68
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,17 @@
+# syntax=docker/dockerfile:1
+FROM maven:3.8.3-eclipse-temurin-17 AS build
+
+WORKDIR /myproject
+
+COPY pom.xml . 
+COPY src src
+
+RUN --mount=type=cache,id=mvncache,target=/root/.m2/repository,rw \ 
+	mvn -B package
+
+FROM eclipse-temurin:11.0.13_8-jre-alpine
+COPY --from=build /myproject/target/*-with-dependencies.jar \
+		  /myapp.jar
+
+ENTRYPOINT ["java", "-jar"]
+CMD ["/myapp.jar"]
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
new file mode 100644
index 0000000..d4aed2d
--- /dev/null
+++ b/dependency-reduced-pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>fr.univtln.bruno</groupId>
+  <artifactId>MyApp3</artifactId>
+  <name>MyApp3</name>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://www.example.com</url>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-clean-plugin</artifactId>
+          <version>3.1.0</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>3.0.2</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.8.0</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.22.1</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-jar-plugin</artifactId>
+          <version>3.0.2</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-install-plugin</artifactId>
+          <version>2.5.2</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-deploy-plugin</artifactId>
+          <version>2.8.2</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-site-plugin</artifactId>
+          <version>3.7.1</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-project-info-reports-plugin</artifactId>
+          <version>3.0.0</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>3.2.4</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers>
+                <transformer>
+                  <mainClass>fr.univtln.bruno.App</mainClass>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>hamcrest-core</artifactId>
+          <groupId>org.hamcrest</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  <properties>
+    <maven.compiler.target>1.7</maven.compiler.target>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..495e505
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,25 @@
+services:
+  app:
+    build: .
+    image: bruno/democi
+    depends_on:
+      - postgres
+    networks:
+      - datanet
+    environment:
+      POSTGRES_USER: ${PG_USER:-demodba}
+      POSTGRES_PASSWORD: ${PG_PASSWORD:-secret}
+
+  postgres:
+    restart: always
+    image: postgres:14
+    environment:
+      POSTGRES_USER: ${PG_USER:-demodba}
+      POSTGRES_PASSWORD: ${PG_PASSWORD:-secret}
+    volumes:
+      - pg_data:/var/lib/postgresql/data
+#    ports:
+#      - "5432:5432"
+    networks:
+      - datanet
+
diff --git a/docker_build.sh b/docker_build.sh
new file mode 100755
index 0000000..ccab3b2
--- /dev/null
+++ b/docker_build.sh
@@ -0,0 +1,2 @@
+source ./docker_env.sh
+DOCKER_BUILDKIT=1 docker build -t ${DOCKER_REPO_NAME}/${IMAGE_NAME} .
diff --git a/docker_env.sh b/docker_env.sh
new file mode 100755
index 0000000..ac6f550
--- /dev/null
+++ b/docker_env.sh
@@ -0,0 +1,3 @@
+DOCKER_REPO_NAME=brunoe
+IMAGE_NAME=`echo ${PWD##*/}| tr '[:upper:]' '[:lower:]'`
+
diff --git a/docker_push.sh b/docker_push.sh
new file mode 100755
index 0000000..4acd476
--- /dev/null
+++ b/docker_push.sh
@@ -0,0 +1,2 @@
+source ./docker_env.sh
+docker push ${DOCKER_REPO_NAME}/${IMAGE_NAME}
diff --git a/docker_run.sh b/docker_run.sh
new file mode 100755
index 0000000..adf1426
--- /dev/null
+++ b/docker_run.sh
@@ -0,0 +1,2 @@
+source ./docker_env.sh
+docker run --rm -it ${DOCKER_REPO_NAME}/${IMAGE_NAME}
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..872556c
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>fr.univtln.bruno</groupId>
+    <artifactId>DemoCI</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <name>MyApp3</name>
+    <!-- FIXME change it to the project's website -->
+    <url>http://www.example.com</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.13</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <version>1.4.200</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>3.2.4</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <transformers>
+                                <transformer
+                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                    <mainClass>fr.univtln.bruno.App</mainClass>
+                                </transformer>
+                            </transformers>
+                            <shadedArtifactAttached>true</shadedArtifactAttached>
+                            <shadedClassifierName>with-dependencies</shadedClassifierName> <!-- Any name that makes sense -->
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+
+        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
+            <plugins>
+                <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
+                <plugin>
+                    <artifactId>maven-clean-plugin</artifactId>
+                    <version>3.1.0</version>
+                </plugin>
+                <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
+                <plugin>
+                    <artifactId>maven-resources-plugin</artifactId>
+                    <version>3.0.2</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>3.8.0</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>2.22.1</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>3.0.2</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-install-plugin</artifactId>
+                    <version>2.5.2</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-deploy-plugin</artifactId>
+                    <version>2.8.2</version>
+                </plugin>
+                <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
+                <plugin>
+                    <artifactId>maven-site-plugin</artifactId>
+                    <version>3.7.1</version>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-project-info-reports-plugin</artifactId>
+                    <version>3.0.0</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>
diff --git a/src/main/java/fr/univtln/bruno/App.java b/src/main/java/fr/univtln/bruno/App.java
new file mode 100644
index 0000000..a27217a
--- /dev/null
+++ b/src/main/java/fr/univtln/bruno/App.java
@@ -0,0 +1,13 @@
+package fr.univtln.bruno;
+
+/**
+ * Hello world!
+ *
+ */
+public class App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/src/test/java/fr/univtln/bruno/AppTest.java b/src/test/java/fr/univtln/bruno/AppTest.java
new file mode 100644
index 0000000..4475a9d
--- /dev/null
+++ b/src/test/java/fr/univtln/bruno/AppTest.java
@@ -0,0 +1,20 @@
+package fr.univtln.bruno;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+{
+    /**
+     * Rigorous Test :-)
+     */
+    @Test
+    public void shouldAnswerWithTrue()
+    {
+        assertTrue( true );
+    }
+}
-- 
GitLab