thêm docker file. test còn lỗi docker compose không connect được mongodb và redis. chạy trên IDE thì connect local thành công.
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
# ===== BUILD STAGE =====
|
||||
FROM maven:3.9-eclipse-temurin-21 AS build
|
||||
WORKDIR /build
|
||||
COPY pom.xml .
|
||||
COPY src ./src
|
||||
RUN mvn clean package -DskipTests
|
||||
|
||||
# ===== RUN STAGE =====
|
||||
FROM eclipse-temurin:21-jre
|
||||
WORKDIR /app
|
||||
COPY target/*.jar app.jar
|
||||
ENTRYPOINT ["java","-jar","app.jar"]
|
||||
COPY --from=build /build/target/*.jar app.jar
|
||||
ENTRYPOINT ["java","-jar","app.jar"]
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package com.dken.userservice.config;
|
||||
// package com.dken.userservice.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
// import org.springframework.context.annotation.Bean;
|
||||
// import org.springframework.context.annotation.Configuration;
|
||||
// import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
// import org.springframework.data.redis.core.RedisTemplate;
|
||||
// import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
// @Configuration
|
||||
// public class RedisConfig {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, String> redisTemplate(
|
||||
RedisConnectionFactory factory) {
|
||||
// @Bean
|
||||
// public RedisTemplate<String, String> redisTemplate(
|
||||
// RedisConnectionFactory factory) {
|
||||
|
||||
RedisTemplate<String, String> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(factory);
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(new StringRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
}
|
||||
// RedisTemplate<String, String> template = new RedisTemplate<>();
|
||||
// template.setConnectionFactory(factory);
|
||||
// template.setKeySerializer(new StringRedisSerializer());
|
||||
// template.setValueSerializer(new StringRedisSerializer());
|
||||
// return template;
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -2,21 +2,15 @@ package com.dken.userservice.service;
|
||||
|
||||
import com.dken.userservice.client.GiftCodeClient;
|
||||
import com.dken.userservice.dto.request.CreateUserRequest;
|
||||
import com.dken.userservice.dto.request.GiftCodeValidateRequest;
|
||||
import com.dken.userservice.dto.request.UserApplyGiftCodeRequest;
|
||||
import com.dken.userservice.dto.response.UserApplyGiftCodeResponse;
|
||||
import com.dken.userservice.dto.response.UserResponse;
|
||||
import com.dken.userservice.model.User;
|
||||
import com.dken.userservice.model.UserSex;
|
||||
import com.dken.userservice.repository.UserRepository;
|
||||
import com.dken.userservice.exception.DefaultException;
|
||||
import com.dken.userservice.exception.InvalidUserIdException;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
18
user-service/src/main/resources/application-docker.yml
Normal file
18
user-service/src/main/resources/application-docker.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
server:
|
||||
port: 8601
|
||||
|
||||
giftcode:
|
||||
service:
|
||||
url: http://giftcode-service:8602
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: user-service
|
||||
data:
|
||||
mongodb:
|
||||
host: mongodb
|
||||
port: 27017
|
||||
database: userdb
|
||||
redis:
|
||||
host: redis
|
||||
port: 6379
|
||||
@@ -1 +0,0 @@
|
||||
spring.application.name=demo
|
||||
@@ -8,8 +8,9 @@ spring:
|
||||
name: user-service
|
||||
data:
|
||||
mongodb:
|
||||
uri: mongodb://localhost:27017/userdb
|
||||
auto-index-creation: true
|
||||
host: localhost
|
||||
port: 27017
|
||||
database: userdb
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
Reference in New Issue
Block a user