Skip to content

Commit a69ee26

Browse files
System.out.println("Bismillah");
1 parent 03969cd commit a69ee26

27 files changed

+667
-252
lines changed

.env

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#spring config
2+
APPLICATION_NAME=minio-file
3+
SERVER_PORT=7007
4+
5+
#database configs
6+
DATABASE_HOST=localhost
7+
DATABASE_PORT=5432
8+
DATABASE_NAME=minio_db
9+
DATABASE_USER=root
10+
DATABASE_PASS=1234root
11+
12+
#minio configs
13+
MINIO_URL=http://localhost:9000
14+
ACCESS_KEY=root
15+
SECRET_KEY=1234root

docker/docker-compose.yml

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,5 @@
11
name: erp-retail-module
22
services:
3-
consul:
4-
image: docker.io/bitnami/consul:1.17.0
5-
ports:
6-
- 127.0.0.1:8300:8300
7-
- 127.0.0.1:8500:8500
8-
- 127.0.0.1:8600:8600
9-
command: consul agent -dev -ui -client 0.0.0.0 -log-level=INFO
10-
11-
consul-config-loader:
12-
image: jhipster/consul-config-loader:v0.4.1
13-
volumes:
14-
- ./central-server-config:/config
15-
environment:
16-
- INIT_SLEEP_SECONDS=5
17-
- CONSUL_URL=consul
18-
- CONSUL_PORT=8500
19-
20-
### ------------------------------------------------------- KEYCLOAK ------------------------------------------------------- ###
21-
keycloak:
22-
image: quay.io/keycloak/keycloak:23.0.1
23-
command: 'start-dev --import-realm'
24-
volumes:
25-
- ./realm-config:/opt/keycloak/data/import
26-
- ./realm-config/keycloak-health-check.sh:/opt/keycloak/health-check.sh
27-
environment:
28-
- KC_DB=dev-file
29-
- KEYCLOAK_ADMIN=admin
30-
- KEYCLOAK_ADMIN_PASSWORD=admin
31-
- KC_FEATURES=scripts
32-
- KC_HTTP_PORT=9080
33-
- KC_HTTPS_PORT=9443
34-
- KC_HEALTH_ENABLED=true
35-
ports:
36-
- 127.0.0.1:9080:9080
37-
- 127.0.0.1:9443:9443
38-
healthcheck:
39-
test: 'bash /opt/keycloak/health-check.sh'
40-
interval: 5s
41-
timeout: 5s
42-
retries: 20
43-
start_period: 10s
44-
45-
#--------------------minio----------------------#
463
minio:
474
image: quay.io/minio/minio
485
container_name: minio
@@ -59,23 +16,3 @@ services:
5916
command: minio server /data
6017

6118

62-
### ------------------------------------------------------- POSTGRESQL ------------------------------------------------------- ###
63-
postgresql:
64-
image: postgres:16.1
65-
volumes:
66-
- postgres_data:/var/lib/postgresql/data
67-
environment:
68-
- POSTGRES_USER=postgres
69-
- POSTGRES_PASSWORD=123
70-
- POSTGRES_HOST_AUTH_METHOD=trust
71-
healthcheck:
72-
test: ['CMD-SHELL', 'pg_isready -U $${POSTGRES_USER}']
73-
interval: 5s
74-
timeout: 5s
75-
retries: 10
76-
ports:
77-
- 127.0.0.1:5432:5432
78-
79-
volumes:
80-
postgres_data:
81-

pom.xml

Lines changed: 120 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,126 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<parent>
6-
<groupId>org.springframework.boot</groupId>
7-
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.4.0</version>
9-
<relativePath/> <!-- lookup parent from repository -->
10-
</parent>
11-
<groupId>uz.javadev</groupId>
12-
<artifactId>minio-file</artifactId>
13-
<version>0.0.1-SNAPSHOT</version>
14-
<name>minio-file</name>
15-
<description>minio-file</description>
16-
<url/>
17-
<licenses>
18-
<license/>
19-
</licenses>
20-
<developers>
21-
<developer/>
22-
</developers>
23-
<scm>
24-
<connection/>
25-
<developerConnection/>
26-
<tag/>
27-
<url/>
28-
</scm>
29-
<properties>
30-
<java.version>17</java.version>
31-
</properties>
32-
<dependencies>
33-
<dependency>
34-
<groupId>org.springframework.boot</groupId>
35-
<artifactId>spring-boot-starter-data-jpa</artifactId>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.springframework.boot</groupId>
39-
<artifactId>spring-boot-starter-web</artifactId>
40-
</dependency>
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>3.1.0</version>
9+
</parent>
10+
<groupId>uz.javadev</groupId>
11+
<artifactId>minio-file</artifactId>
12+
<version>0.0.1</version>
13+
<name>minio-file</name>
14+
<description>minio-file</description>
4115

42-
<dependency>
43-
<groupId>org.postgresql</groupId>
44-
<artifactId>postgresql</artifactId>
45-
<scope>runtime</scope>
46-
</dependency>
47-
<dependency>
48-
<groupId>org.projectlombok</groupId>
49-
<artifactId>lombok</artifactId>
50-
<optional>true</optional>
51-
</dependency>
52-
<dependency>
53-
<groupId>org.springframework.boot</groupId>
54-
<artifactId>spring-boot-starter-test</artifactId>
55-
<scope>test</scope>
56-
</dependency>
57-
</dependencies>
16+
<properties>
17+
<java.version>17</java.version>
18+
<mapstruct.version>1.5.5.Final</mapstruct.version>
19+
<minio.version>8.5.2</minio.version>
20+
<swagger.version>2.0.2</swagger.version>
21+
</properties>
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-data-jpa</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-web</artifactId>
30+
</dependency>
5831

59-
<build>
60-
<plugins>
61-
<plugin>
62-
<groupId>org.apache.maven.plugins</groupId>
63-
<artifactId>maven-compiler-plugin</artifactId>
64-
<configuration>
65-
<annotationProcessorPaths>
66-
<path>
67-
<groupId>org.projectlombok</groupId>
68-
<artifactId>lombok</artifactId>
69-
</path>
70-
</annotationProcessorPaths>
71-
</configuration>
72-
</plugin>
73-
<plugin>
74-
<groupId>org.springframework.boot</groupId>
75-
<artifactId>spring-boot-maven-plugin</artifactId>
76-
<configuration>
77-
<excludes>
78-
<exclude>
79-
<groupId>org.projectlombok</groupId>
80-
<artifactId>lombok</artifactId>
81-
</exclude>
82-
</excludes>
83-
</configuration>
84-
</plugin>
85-
</plugins>
86-
</build>
32+
<dependency>
33+
<groupId>org.postgresql</groupId>
34+
<artifactId>postgresql</artifactId>
35+
<scope>runtime</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.projectlombok</groupId>
39+
<artifactId>lombok</artifactId>
40+
<optional>true</optional>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-test</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springdoc</groupId>
49+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
50+
<version>${swagger.version}</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>io.minio</groupId>
54+
<artifactId>minio</artifactId>
55+
<version>${minio.version}</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.mapstruct</groupId>
59+
<artifactId>mapstruct</artifactId>
60+
<version>${mapstruct.version}</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.mapstruct</groupId>
64+
<artifactId>mapstruct-processor</artifactId>
65+
<version>${mapstruct.version}</version>
66+
<scope>provided</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>jakarta.validation</groupId>
70+
<artifactId>jakarta.validation-api</artifactId>
71+
<version>3.0.2</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.springframework.boot</groupId>
75+
<artifactId>spring-boot-starter-jdbc</artifactId>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.springframework.boot</groupId>
79+
<artifactId>spring-boot-starter-logging</artifactId>
80+
</dependency>
81+
</dependencies>
82+
83+
<build>
84+
<plugins>
85+
<plugin>
86+
<groupId>org.springframework.boot</groupId>
87+
<artifactId>spring-boot-maven-plugin</artifactId>
88+
<configuration>
89+
<excludes>
90+
<exclude>
91+
<groupId>org.projectlombok</groupId>
92+
<artifactId>lombok</artifactId>
93+
</exclude>
94+
</excludes>
95+
</configuration>
96+
</plugin>
97+
<plugin>
98+
<groupId>org.apache.maven.plugins</groupId>
99+
<artifactId>maven-compiler-plugin</artifactId>
100+
<version>${maven-compiler-plugin.version}</version>
101+
<configuration>
102+
<source>${java.version}</source>
103+
<target>${java.version}</target>
104+
<annotationProcessorPaths>
105+
<path>
106+
<groupId>org.mapstruct</groupId>
107+
<artifactId>mapstruct-processor</artifactId>
108+
<version>${mapstruct.version}</version>
109+
</path>
110+
<path>
111+
<groupId>org.projectlombok</groupId>
112+
<artifactId>lombok</artifactId>
113+
<version>${lombok.version}</version>
114+
</path>
115+
<path>
116+
<groupId>org.projectlombok</groupId>
117+
<artifactId>lombok-mapstruct-binding</artifactId>
118+
<version>0.2.0</version>
119+
</path>
120+
</annotationProcessorPaths>
121+
</configuration>
122+
</plugin>
123+
</plugins>
124+
</build>
87125

88126
</project>
Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,84 @@
11
package uz.javadev;
22

3+
import io.micrometer.common.util.StringUtils;
4+
import lombok.extern.slf4j.Slf4j;
35
import org.springframework.boot.SpringApplication;
46
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.core.env.Environment;
8+
import uz.javadev.config.CRLFLogConverter;
59

6-
@SpringBootApplication
10+
import java.net.InetAddress;
11+
import java.net.UnknownHostException;
12+
import java.util.Optional;
13+
14+
/**
15+
* Minio File management
16+
*
17+
* @author Javohir Yallayev
18+
*/
19+
@Slf4j
20+
@SpringBootApplication(scanBasePackages = "uz.javadev")
721
public class MinioFileApplication {
22+
public static void main(String[] args) {
23+
SpringApplication app = new SpringApplication(MinioFileApplication.class);
24+
Environment env = app.run(args).getEnvironment();
25+
logApplicationStartup(env);
26+
}
827

9-
public static void main(String[] args) {
10-
SpringApplication.run(MinioFileApplication.class, args);
11-
}
28+
private static void logApplicationStartup(Environment env) {
29+
String protocol = Optional.ofNullable(env.getProperty("server.ssl.key-store")).map(key -> "https").orElse("http");
30+
String applicationName = env.getProperty("spring.application.name");
31+
String serverPort = env.getProperty("server.port");
32+
String contextPath = Optional
33+
.ofNullable(env.getProperty("server.servlet.context-path"))
34+
.filter(StringUtils::isNotBlank)
35+
.orElse("/");
36+
String hostAddress = "localhost";
37+
String swaggerUiPath = env.getProperty("springdoc.swagger-ui.path");
38+
try {
39+
hostAddress = InetAddress.getLocalHost().getHostAddress();
40+
} catch (UnknownHostException e) {
41+
log.warn("The host name could not be determined, using `localhost` as fallback");
42+
}
43+
log.info(
44+
CRLFLogConverter.CRLF_SAFE_MARKER,
45+
"""
46+
47+
----------------------------------------------------------
48+
\tApplication '{}' is running! Access URLs:
49+
\tLocal: \t\t{}://localhost:{}{}
50+
\tExternal: \t{}://{}:{}{}
51+
\tSwagger: \t{}://{}:{}{}
52+
\tProfile(s): \t{}
53+
----------------------------------------------------------""",
54+
applicationName,
55+
protocol,
56+
serverPort,
57+
contextPath,
58+
protocol,
59+
hostAddress,
60+
serverPort,
61+
contextPath,
62+
protocol,
63+
hostAddress,
64+
serverPort,
65+
swaggerUiPath,
66+
env.getActiveProfiles().length == 0 ? env.getDefaultProfiles() : env.getActiveProfiles()
67+
);
1268

69+
String configServerStatus = env.getProperty("configserver.status");
70+
if (configServerStatus == null) {
71+
configServerStatus = "Not found or not setup for this application";
72+
}
73+
log.info(
74+
CRLFLogConverter.CRLF_SAFE_MARKER,
75+
"""
76+
77+
----------------------------------------------------------
78+
\t\
79+
Config Server: \t{}
80+
----------------------------------------------------------""",
81+
configServerStatus
82+
);
83+
}
1384
}

0 commit comments

Comments
 (0)