Add Docker support and update Java version to 21
This commit is contained in:
Generated
+11
@@ -9,10 +9,21 @@
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="ListHubBackend" />
|
||||
</profile>
|
||||
<profile name="Annotation profile for ListHubBackend" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar" />
|
||||
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar" />
|
||||
</processorPath>
|
||||
<module name="ArtisanConnectBackend" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="ArtisanConnectBackend" options="-parameters" />
|
||||
<module name="ListHubBackend" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
|
||||
Generated
+18
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CopilotDiffPersistence">
|
||||
<option name="pendingDiffs">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$/src/main/java/_11/asktpk/artisanconnectbackend/ArtisanConnectBackendApplication.java">
|
||||
<value>
|
||||
<PendingDiffInfo>
|
||||
<option name="filePath" value="$PROJECT_DIR$/src/main/java/_11/asktpk/artisanconnectbackend/ArtisanConnectBackendApplication.java" />
|
||||
<option name="originalContent" value="package _11.asktpk.artisanconnectbackend; import jakarta.annotation.PostConstruct; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; @SpringBootApplication public class ArtisanConnectBackendApplication { private final Environment environment; public ArtisanConnectBackendApplication(Environment environment) { this.environment = environment; } static void main(String[] args) { SpringApplication.run(ArtisanConnectBackendApplication.class, args); } @PostConstruct public void logDataSourceUrl() { System.out.println("Datasource URL: " + environment.getProperty("spring.datasource.url")); } } " />
|
||||
<option name="updatedContent" value="package _11.asktpk.artisanconnectbackend; import jakarta.annotation.PostConstruct; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; @SpringBootApplication public class ArtisanConnectBackendApplication { private final Environment environment; public ArtisanConnectBackendApplication(Environment environment) { this.environment = environment; } public static void main(String[] args) { SpringApplication.run(ArtisanConnectBackendApplication.class, args); } @PostConstruct public void logDataSourceUrl() { System.out.println("Datasource URL: " + environment.getProperty("spring.datasource.url")); } } " />
|
||||
</PendingDiffInfo>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,65 @@
|
||||
# How to run container
|
||||
|
||||
### Build
|
||||
In the root directory of project there is `Dockerfile` in which image is defined.
|
||||
<br> Build the image:
|
||||
```bash
|
||||
docker build -t listhub:1.0 .
|
||||
```
|
||||
Then after building the image you can run it. You will need to define some environment variables.
|
||||
```bash
|
||||
docker run -d \
|
||||
--name listhub_backend \
|
||||
-p 8080:8080 \
|
||||
-e JWT_SECRET=<paste_your_secret_here> \
|
||||
-e DB_URL=jdbc:postgresql://db:5432/postgres \
|
||||
-e DB_USER=postgres \
|
||||
-e DB_PASS=postgres \
|
||||
listhub_backend:1.0
|
||||
```
|
||||
|
||||
or you can use compose file with .env file
|
||||
|
||||
```text
|
||||
// .env
|
||||
JWT_SECRET=<paste_your_secret_here>
|
||||
|
||||
DB_URL=jdbc:postgresql://db:5432/postgres
|
||||
DB_USER=listhub
|
||||
DB_PASS=postgres
|
||||
```
|
||||
|
||||
```yaml
|
||||
# docker-compose.yaml
|
||||
services:
|
||||
db:
|
||||
image: postgres:14
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: listhub
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
listhub_backend:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
DB_URL: jdbc:postgresql://db:5432/listhub
|
||||
DB_USER: postgres
|
||||
DB_PASS: postgres
|
||||
JWT_SECRET: awdpokawodjawoidjawidjoij120391829d3j8a0jd8s9dawd
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- listhub_data:/app
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
listhub_data:
|
||||
```
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
FROM maven:3-amazoncorretto-21-alpine AS builder
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY pom.xml ./
|
||||
COPY mvnw ./
|
||||
COPY .mvn .mvn
|
||||
|
||||
RUN mvn -B -DskipTests dependency:go-offline
|
||||
|
||||
COPY src ./src
|
||||
RUN mvn -B -DskipTests package
|
||||
|
||||
FROM amazoncorretto:21-alpine AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /workspace/target/*.jar /app/app.jar
|
||||
|
||||
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75.0 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -Djava.security.egd=file:/dev/./urandom"
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS -jar /app/app.jar"]
|
||||
@@ -0,0 +1,31 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: listhub
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
listhub_backend:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
DB_URL: jdbc:postgresql://db:5432/listhub
|
||||
DB_USER: postgres
|
||||
DB_PASS: postgres
|
||||
JWT_SECRET: awdpokawodjawoidjawidjoij120391829d3j8a0jd8s9dawd
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- listhub_data:/app
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
listhub_data:
|
||||
@@ -27,7 +27,7 @@
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>25</java.version>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -70,7 +70,8 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>1.18.30</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -120,6 +121,23 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- Ensure Lombok annotation processing during Maven compile inside Docker -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class ArtisanConnectBackendApplication {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
static void main(String[] args) {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ArtisanConnectBackendApplication.class, args);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user