Skip to content

Commit ded15c9

Browse files
committed
feat: initial commit
0 parents  commit ded15c9

17 files changed

Lines changed: 596 additions & 0 deletions

File tree

.build/dockerfiles/Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#
2+
# STAGE 1 - Dev
3+
#
4+
# Dev image used for local development
5+
#
6+
FROM zcscompany/java:17-dev AS dev
7+
8+
ARG FIX_UID
9+
ARG FIX_GID
10+
ARG DOCKER_USER=bob
11+
ARG DOCKER_GROUP=bob
12+
13+
USER 0
14+
15+
#RUN apt-get update && \
16+
# apt-get install --no-install-recommends -y \
17+
# YOUR_PKGS_HERE && \
18+
# apt-get clean && \
19+
# rm -rf /var/lib/apt/lists/*
20+
21+
RUN /fix-perm.sh
22+
23+
# Run as normal user
24+
USER ${DOCKER_USER}
25+
26+
#
27+
# Stage 2 - Package
28+
#
29+
# This stage prepares a "package" image used to generate application package.
30+
#
31+
FROM dev AS package
32+
33+
COPY --chown=${DOCKER_USER}:${DOCKER_GROUP} app/ .
34+
RUN mvn --no-transfer-progress clean package
35+
36+
#
37+
# Stage 3 - Dist
38+
#
39+
# This stage prepares a dist image used to run the application.
40+
#
41+
FROM zcscompany/java:17-dist AS dist
42+
43+
ARG DOCKER_USER=bob
44+
ARG DOCKER_GROUP=bob
45+
46+
#USER 0
47+
48+
#RUN apt-get update && \
49+
# apt-get install --no-install-recommends -y \
50+
# YOUR_PKGS_HERE && \
51+
# apt-get clean && \
52+
# rm -rf /var/lib/apt/lists/*
53+
54+
# Run as normal user
55+
#USER ${DOCKER_USER}
56+
57+
COPY --from=package --chown=${DOCKER_USER}:${DOCKER_GROUP} /app/target/app.jar /app/app.jar
58+
59+
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

.build/environments/ci/app.env

Whitespace-only changes.

.build/environments/local/app.env

Whitespace-only changes.

.data/bob-s-home/.bashrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
PS1='\[\033[01;32m\][\[\033[01;32;4m\]${APP_NAME}\[\033[00m\]\[\033[01;32m\]]\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ \[\033[00m\]'
3+
4+
alias ls="ls --color"

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
app/target
2+
.data/
3+
.vscode/
4+
*.md
5+
run.sh

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Ignore vscode files
2+
/.vscode/
3+
4+
/app/target/
5+
6+
# Ignore .data directory but exclude .bashrc file
7+
.data/*
8+
!.data/bob-s-home
9+
.data/bob-s-home/*
10+
!.data/bob-s-home/.bashrc

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
# Madness Lab's Template Project Java
3+
4+
You can use this project as a template to start the development of your new Java application.
5+
6+
## Run the application
7+
8+
You can start the application by running the following command:
9+
10+
```bash
11+
./run.sh
12+
```
13+
14+
## Debug with VsCode
15+
16+
Create a file `.vscode/launch.json` with the following content:
17+
18+
```json
19+
{
20+
"version": "0.2.0",
21+
"configurations": [
22+
{
23+
"type": "java",
24+
"name": "Attach debug",
25+
"request": "attach",
26+
"hostName": "localhost",
27+
"port": "5005"
28+
}
29+
]
30+
}
31+
```
32+
33+
Run with `./run.sh -d`
34+
35+
## Notes
36+
37+
Here are some example commands:
38+
39+
```bash
40+
mvn clean test
41+
mvn versions:display-dependency-updates
42+
mvn versions:display-plugin-updates
43+
mvn clean package
44+
mvn exec:java
45+
```
46+
47+
## Support
48+
49+
[Claudio Cavina](mailto:c.cavina@zcscompany.com)
50+
[Michele Mondelli](mailto:m.mondelli@zcscompany.com)

app/pom-update-rules.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<ruleset comparisonMethod="maven"
2+
xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
5+
<ignoreVersions>
6+
<ignoreVersion type="regex">.*-alpha.*</ignoreVersion>
7+
<ignoreVersion type="regex">.*-beta.*</ignoreVersion>
8+
<ignoreVersion type="regex">.*-rc.*</ignoreVersion>
9+
</ignoreVersions>
10+
</ruleset>

app/pom.xml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>dev.zcscloud.ml</groupId>
9+
<artifactId>template-project-java</artifactId>
10+
<version>0.0.0</version>
11+
12+
<name>TemplateProjectJava@MadnessLab</name>
13+
<description>Use this template to start your new Java application</description>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.source>17</maven.compiler.source>
18+
<maven.compiler.target>17</maven.compiler.target>
19+
20+
<!-- Application dependency versions -->
21+
<slf4j.version>2.0.16</slf4j.version>
22+
<logback.version>1.5.8</logback.version>
23+
<lombok.version>1.18.34</lombok.version>
24+
<junit.version>5.11.0</junit.version>
25+
26+
<!-- Maven plugin versions -->
27+
<maven.enforcer.version>3.5.0</maven.enforcer.version>
28+
<versions.maven.plugin>2.17.1</versions.maven.plugin>
29+
<exec.maven.version>3.4.1</exec.maven.version>
30+
<maven.assembly.version>3.7.1</maven.assembly.version>
31+
</properties>
32+
33+
<dependencies>
34+
35+
<!-- Logging libraries -->
36+
<dependency>
37+
<groupId>org.slf4j</groupId>
38+
<artifactId>slf4j-api</artifactId>
39+
<version>${slf4j.version}</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>ch.qos.logback</groupId>
43+
<artifactId>logback-classic</artifactId>
44+
<version>${logback.version}</version>
45+
</dependency>
46+
47+
<!-- Other libraries -->
48+
<dependency>
49+
<groupId>org.projectlombok</groupId>
50+
<artifactId>lombok</artifactId>
51+
<version>${lombok.version}</version>
52+
<scope>provided</scope>
53+
</dependency>
54+
55+
<!-- Test related libraries -->
56+
<dependency>
57+
<groupId>org.junit.jupiter</groupId>
58+
<artifactId>junit-jupiter-api</artifactId>
59+
<version>${junit.version}</version>
60+
<scope>test</scope>
61+
</dependency>
62+
</dependencies>
63+
64+
<build>
65+
<plugins>
66+
<plugin>
67+
<groupId>org.apache.maven.plugins</groupId>
68+
<artifactId>maven-enforcer-plugin</artifactId>
69+
<version>${maven.enforcer.version}</version>
70+
<executions>
71+
<execution>
72+
<id>enforce-maven</id>
73+
<goals>
74+
<goal>enforce</goal>
75+
</goals>
76+
<configuration>
77+
<rules>
78+
<requireMavenVersion>
79+
<version>3.6.3</version>
80+
</requireMavenVersion>
81+
</rules>
82+
</configuration>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
<plugin>
87+
<groupId>org.codehaus.mojo</groupId>
88+
<artifactId>versions-maven-plugin</artifactId>
89+
<version>${versions.maven.plugin}</version>
90+
<configuration>
91+
<rulesUri>file:///${project.basedir}/pom-update-rules.xml</rulesUri>
92+
</configuration>
93+
</plugin>
94+
<plugin>
95+
<groupId>org.codehaus.mojo</groupId>
96+
<artifactId>exec-maven-plugin</artifactId>
97+
<version>${exec.maven.version}</version>
98+
<configuration>
99+
<mainClass>dev.zcscloud.ml.tpj.app.App</mainClass>
100+
</configuration>
101+
</plugin>
102+
<!--
103+
<plugin>
104+
<artifactId>maven-assembly-plugin</artifactId>
105+
<version>${maven.assembly.version}</version>
106+
<configuration>
107+
<archive>
108+
<manifest>
109+
<mainClass>dev.zcscloud.ml.tpj.app.App</mainClass>
110+
</manifest>
111+
</archive>
112+
<descriptorRefs>
113+
<descriptorRef>jar-with-dependencies</descriptorRef>
114+
</descriptorRefs>
115+
<finalName>app</finalName>
116+
<appendAssemblyId>false</appendAssemblyId>
117+
</configuration>
118+
<executions>
119+
<execution>
120+
<id>make-assembly</id>
121+
<phase>package</phase>
122+
<goals>
123+
<goal>single</goal>
124+
</goals>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
-->
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-shade-plugin</artifactId>
132+
<version>3.6.0</version>
133+
<executions>
134+
<execution>
135+
<phase>package</phase>
136+
<goals>
137+
<goal>shade</goal>
138+
</goals>
139+
<configuration>
140+
<createDependencyReducedPom>false</createDependencyReducedPom>
141+
<filters>
142+
<filter>
143+
<artifact>*:*</artifact>
144+
<excludes>
145+
<exclude>META-INF/*.SF</exclude>
146+
<exclude>META-INF/*.DSA</exclude>
147+
<exclude>META-INF/*.RSA</exclude>
148+
</excludes>
149+
</filter>
150+
</filters>
151+
<finalName>app</finalName>
152+
<transformers>
153+
<transformer
154+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
155+
<mainClass>dev.zcscloud.ml.tpj.app.App</mainClass>
156+
<manifestEntries>
157+
<Implementation-Version>${project.version}</Implementation-Version>
158+
<Main-Class>dev.zcscloud.ml.tpj.app.App</Main-Class>
159+
</manifestEntries>
160+
</transformer>
161+
<transformer
162+
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
163+
</transformers>
164+
</configuration>
165+
</execution>
166+
</executions>
167+
</plugin>
168+
</plugins>
169+
<resources>
170+
<resource>
171+
<directory>src/main/resources</directory>
172+
<includes>
173+
<include>**/*</include>
174+
</includes>
175+
<filtering>true</filtering>
176+
</resource>
177+
</resources>
178+
</build>
179+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.zcscloud.ml.tpj.app;
2+
3+
import dev.zcscloud.ml.tpj.app.config.AppConfig;
4+
5+
import lombok.extern.slf4j.Slf4j;
6+
7+
@Slf4j
8+
public class App {
9+
10+
public static void main(String[] args) {
11+
12+
var appConfig = AppConfig.getInstance();
13+
log.info("Welcome to {} - App version: {} - Env: {}", appConfig.getAppName(), appConfig.getAppVersion(),
14+
appConfig.getAppEnv());
15+
16+
}
17+
18+
}

0 commit comments

Comments
 (0)