diff --git a/.env b/.env new file mode 100644 index 0000000000000000000000000000000000000000..56ebe4f4056af0239d7c3cae56a89cf07d2a16a5 --- /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 0000000000000000000000000000000000000000..e7330e1e96e88f9b6d70c28fd50dc8fd09419cee --- /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 0000000000000000000000000000000000000000..8bbcb682b1f572e2922529b5b873a311f9cd838a --- /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 0000000000000000000000000000000000000000..d4aed2d1145d7ac375b85a0d3889aaa3b3d2c66e --- /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 0000000000000000000000000000000000000000..495e505b69390c307f2901b8539f3e88a4a1843a --- /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 0000000000000000000000000000000000000000..ccab3b220be7248a5734f78018bd3c371ee47fd2 --- /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 0000000000000000000000000000000000000000..ac6f550b11a2d753ee4003a02e58a0fc4fda17df --- /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 0000000000000000000000000000000000000000..4acd476e13440c23822342fd560386c836648ff5 --- /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 0000000000000000000000000000000000000000..adf1426d153fedf1c7daeb64683d3f252fb4db85 --- /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 0000000000000000000000000000000000000000..872556c5b9ed1378e809b6dcda3ff66205c2d29e --- /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 0000000000000000000000000000000000000000..a27217a7d633bce9317a8b234a446054b8d83657 --- /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 0000000000000000000000000000000000000000..4475a9d8db7a9801144750318e0af1fa982454f5 --- /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 ); + } +}