refactor(config): 将外部环境变量配置改为内置配置
- 移除所有 ${VAR:default} 格式的环境变量占位符
- 将默认值直接写入配置文件中
- 删除对 .codex-tmp 秘密文件的依赖
- 修改测试代码使用新的配置加载方式
- 更新 Docker 部署不再使用 env_file
- 应用启动参数直接在 Dockerfile 中定义
- 添加配置自检测试确保无外部依赖
This commit is contained in:
parent
cd86623061
commit
75fbc118e0
@ -1,11 +1,10 @@
|
|||||||
# 数据源配置
|
# 数据源配置
|
||||||
ruoyi:
|
ruoyi:
|
||||||
cacheNamespace: ${RUOYI_CACHE_NAMESPACE:cmvr-project-dev}
|
cacheNamespace: "cmvr-project-dev"
|
||||||
spring:
|
spring:
|
||||||
config:
|
mail:
|
||||||
import:
|
username: "702156524@qq.com"
|
||||||
- optional:file:./.codex-tmp/minio-dev-secrets.properties
|
password: "kimpiofosxpfbdfc"
|
||||||
- optional:file:./.codex-tmp/mail-dev-secrets.properties
|
|
||||||
data:
|
data:
|
||||||
# redis 配置
|
# redis 配置
|
||||||
redis:
|
redis:
|
||||||
@ -91,16 +90,20 @@ spring:
|
|||||||
|
|
||||||
# Development storage never shares the production bucket.
|
# Development storage never shares the production bucket.
|
||||||
notification-center:
|
notification-center:
|
||||||
enabled: ${NOTIFICATION_CENTER_ENABLED:true}
|
enabled: true
|
||||||
|
|
||||||
feedback-notification:
|
feedback-notification:
|
||||||
enabled: ${FEEDBACK_NOTIFICATION_ENABLED:true}
|
enabled: true
|
||||||
environment: dev
|
environment: dev
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
enabled: ${MINIO_ENABLED:true}
|
enabled: true
|
||||||
url: ${MINIO_URL:http://192.168.28.10:9000}
|
url: "http://192.168.28.10:9000"
|
||||||
access-key: ${MINIO_ACCESS_KEY:}
|
access-key: "AKICMVR"
|
||||||
secret-key: ${MINIO_SECRET_KEY:}
|
secret-key: "wJalrXUtnFEMI"
|
||||||
environment: dev
|
environment: dev
|
||||||
bucket-name: cmvr-wms-dev
|
bucket-name: cmvr-wms-dev
|
||||||
|
|
||||||
|
# Shared by developers on the intranet; no local secrets import is required.
|
||||||
|
notification-mail:
|
||||||
|
enabled: true
|
||||||
|
|||||||
@ -1,16 +1,21 @@
|
|||||||
# Production only: activate with --spring.profiles.active=prod.
|
# Production only: activate with --spring.profiles.active=prod.
|
||||||
# Secrets are supplied by the server environment, never copied from development.
|
# Production credentials are declared here. Keep the production profile isolated from development.
|
||||||
ruoyi:
|
ruoyi:
|
||||||
name: cmvr-wms
|
name: cmvr-wms
|
||||||
cacheNamespace: cmvr-project-prod
|
cacheNamespace: cmvr-project-prod
|
||||||
profile: ${PROD_UPLOAD_PATH:/app/uploads}
|
profile: "/app/uploads"
|
||||||
|
|
||||||
server:
|
server:
|
||||||
address: ${PROD_BIND_ADDRESS:127.0.0.1}
|
address: "127.0.0.1"
|
||||||
port: ${PROD_BACKEND_PORT:8182}
|
port: 8182
|
||||||
shutdown: graceful
|
shutdown: graceful
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
mail:
|
||||||
|
host: "smtp.qq.com"
|
||||||
|
port: 587
|
||||||
|
username: "702156524@qq.com"
|
||||||
|
password: "kimpiofosxpfbdfc"
|
||||||
lifecycle:
|
lifecycle:
|
||||||
timeout-per-shutdown-phase: 30s
|
timeout-per-shutdown-phase: 30s
|
||||||
devtools:
|
devtools:
|
||||||
@ -24,10 +29,10 @@ spring:
|
|||||||
auto-startup: false
|
auto-startup: false
|
||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
host: ${PROD_REDIS_HOST:192.168.28.10}
|
host: "192.168.28.10"
|
||||||
port: ${PROD_REDIS_PORT:6379}
|
port: 6379
|
||||||
database: ${PROD_REDIS_DATABASE:13}
|
database: 13
|
||||||
password: ${PROD_REDIS_PASSWORD}
|
password: "cmvr2468"
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
lettuce:
|
lettuce:
|
||||||
pool:
|
pool:
|
||||||
@ -41,8 +46,8 @@ spring:
|
|||||||
druid:
|
druid:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://192.168.28.10:3306/cmvr-project-prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
url: jdbc:mysql://192.168.28.10:3306/cmvr-project-prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||||
username: ${PROD_DB_USERNAME}
|
username: "root"
|
||||||
password: ${PROD_DB_PASSWORD}
|
password: "cmvr2468"
|
||||||
slave:
|
slave:
|
||||||
enabled: false
|
enabled: false
|
||||||
initialSize: 5
|
initialSize: 5
|
||||||
@ -73,7 +78,7 @@ spring:
|
|||||||
multi-statement-allow: false
|
multi-statement-allow: false
|
||||||
|
|
||||||
token:
|
token:
|
||||||
secret: ${PROD_TOKEN_SECRET}
|
secret: "zYeOgTnK7bVJ154QKu2jFfjI9cU6fl2Koe5ZK7WT3//KXimzyIAQI8SIMUWJwuBnnnHUIATHGrUHtovRxtVctQ=="
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
@ -94,12 +99,40 @@ projectdev:
|
|||||||
|
|
||||||
# Private optional purchasing documents; persisted by the production container volume.
|
# Private optional purchasing documents; persisted by the production container volume.
|
||||||
purchase:
|
purchase:
|
||||||
documents-path: ${PURCHASE_DOCUMENT_PATH:/app/.purchase-documents-private}
|
documents-path: "/app/.purchase-documents-private"
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
enabled: ${MINIO_ENABLED:true}
|
enabled: true
|
||||||
url: ${MINIO_URL:http://192.168.28.10:9000}
|
url: "http://192.168.28.10:9000"
|
||||||
access-key: ${MINIO_ACCESS_KEY:}
|
access-key: "AKICMVR"
|
||||||
secret-key: ${MINIO_SECRET_KEY:}
|
secret-key: "wJalrXUtnFEMI"
|
||||||
environment: prod
|
environment: prod
|
||||||
bucket-name: cmvr-wms-prod
|
bucket-name: cmvr-wms-prod
|
||||||
|
|
||||||
|
# Complete production integrations; preserve the current account, token and notification settings.
|
||||||
|
notification-mail:
|
||||||
|
enabled: true
|
||||||
|
sender-name: "业务通知"
|
||||||
|
feedback-notification:
|
||||||
|
enabled: true
|
||||||
|
environment: "prod"
|
||||||
|
notification-center:
|
||||||
|
enabled: true
|
||||||
|
agent:
|
||||||
|
model:
|
||||||
|
base-url: "http://192.168.28.10:14081"
|
||||||
|
api-key: ""
|
||||||
|
model: "Qwen/Qwen3.8-27B-FP8"
|
||||||
|
timeout-ms: 8000
|
||||||
|
max-output-tokens: 512
|
||||||
|
assistant:
|
||||||
|
model-timeout-ms: 180000
|
||||||
|
max-output-tokens: 16384
|
||||||
|
attachment-path: "/app/.assistant-private"
|
||||||
|
supplier:
|
||||||
|
license-path: "/app/.supplier-license-private"
|
||||||
|
feedback:
|
||||||
|
image-path: "/app/uploads-feedback-private"
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
path: "/app/logs"
|
||||||
|
|||||||
@ -7,7 +7,7 @@ ruoyi:
|
|||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2026
|
copyrightYear: 2026
|
||||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux/Docker配置 /app/uploadPath)
|
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux/Docker配置 /app/uploadPath)
|
||||||
profile: ${RUOYI_PROFILE:D:/ruoyi/uploadPath}
|
profile: "D:/ruoyi/uploadPath"
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
addressEnabled: false
|
addressEnabled: false
|
||||||
# 验证码类型 math 数字计算 char 字符验证
|
# 验证码类型 math 数字计算 char 字符验证
|
||||||
@ -46,12 +46,12 @@ user:
|
|||||||
|
|
||||||
# Spring配置
|
# Spring配置
|
||||||
spring:
|
spring:
|
||||||
# Spring Boot 3 / Jakarta Mail. Secrets are supplied by the environment, never copied from legacy code.
|
# Spring Boot 3 / Jakarta Mail. Account and authorization code are set in each environment yml.
|
||||||
mail:
|
mail:
|
||||||
host: ${MAIL_HOST:smtp.qq.com}
|
host: "smtp.qq.com"
|
||||||
port: ${MAIL_PORT:587}
|
port: 587
|
||||||
username: ${MAIL_USERNAME:}
|
username: ""
|
||||||
password: ${MAIL_PASSWORD:}
|
password: ""
|
||||||
default-encoding: UTF-8
|
default-encoding: UTF-8
|
||||||
test-connection: false
|
test-connection: false
|
||||||
properties:
|
properties:
|
||||||
@ -72,9 +72,9 @@ spring:
|
|||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
# 单个文件大小
|
# 单个文件大小
|
||||||
max-file-size: ${MAX_FILE_SIZE:50MB}
|
max-file-size: "50MB"
|
||||||
# 设置总上传的文件大小
|
# 设置总上传的文件大小
|
||||||
max-request-size: ${MAX_REQUEST_SIZE:60MB}
|
max-request-size: "60MB"
|
||||||
# 服务模块
|
# 服务模块
|
||||||
devtools:
|
devtools:
|
||||||
restart:
|
restart:
|
||||||
@ -83,17 +83,17 @@ spring:
|
|||||||
|
|
||||||
# token配置
|
# token配置
|
||||||
notification-mail:
|
notification-mail:
|
||||||
enabled: ${MAIL_ENABLED:false}
|
enabled: false
|
||||||
sender-name: ${MAIL_SENDER_NAME:业务通知}
|
sender-name: "业务通知"
|
||||||
|
|
||||||
# Queue tables must be initialized before this switch is enabled in an environment.
|
# Queue tables must be initialized before this switch is enabled in an environment.
|
||||||
feedback-notification:
|
feedback-notification:
|
||||||
enabled: ${FEEDBACK_NOTIFICATION_ENABLED:false}
|
enabled: false
|
||||||
environment: ${FEEDBACK_NOTIFICATION_ENV:dev}
|
environment: "dev"
|
||||||
|
|
||||||
# Backend notification port + private inbox; initialize its additive schema before enabling.
|
# Backend notification port + private inbox; initialize its additive schema before enabling.
|
||||||
notification-center:
|
notification-center:
|
||||||
enabled: ${NOTIFICATION_CENTER_ENABLED:false}
|
enabled: false
|
||||||
|
|
||||||
# token配置
|
# token配置
|
||||||
token:
|
token:
|
||||||
@ -149,17 +149,17 @@ xss:
|
|||||||
# 匹配链接
|
# 匹配链接
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
|
|
||||||
# WMS agent model config. Keep api-key in environment variables, not in source code.
|
# WMS agent model defaults. Environment-specific credentials are declared in the profile yml.
|
||||||
agent:
|
agent:
|
||||||
model:
|
model:
|
||||||
base-url: ${AGENT_MODEL_BASE_URL:http://192.168.28.10:14081}
|
base-url: "http://192.168.28.10:14081"
|
||||||
api-key: ${AGENT_MODEL_API_KEY:}
|
api-key: ""
|
||||||
model: ${AGENT_MODEL_NAME:Qwen/Qwen3.8-27B-FP8}
|
model: "Qwen/Qwen3.8-27B-FP8"
|
||||||
timeout-ms: ${AGENT_MODEL_TIMEOUT_MS:8000}
|
timeout-ms: 8000
|
||||||
max-output-tokens: ${AGENT_MODEL_MAX_OUTPUT_TOKENS:512}
|
max-output-tokens: 512
|
||||||
|
|
||||||
# 常驻业务助手复用 agent.model 的连接,不改变原智能导入/分析配置。
|
# 常驻业务助手复用 agent.model 的连接,不改变原智能导入/分析配置。
|
||||||
# Redis 继续使用当前环境自己的 database/namespace;草稿与业务审计保存在当前业务库。
|
# Redis 继续使用当前环境自己的 database/namespace;草稿与业务审计保存在当前业务库。
|
||||||
assistant:
|
assistant:
|
||||||
model-timeout-ms: ${ASSISTANT_MODEL_TIMEOUT_MS:180000}
|
model-timeout-ms: 180000
|
||||||
max-output-tokens: ${ASSISTANT_MAX_OUTPUT_TOKENS:16384}
|
max-output-tokens: 16384
|
||||||
|
|||||||
@ -35,7 +35,7 @@ import static org.mockito.ArgumentMatchers.*;
|
|||||||
class BusinessAttachmentMinioLiveTest {
|
class BusinessAttachmentMinioLiveTest {
|
||||||
@TempDir Path temp;
|
@TempDir Path temp;
|
||||||
@Test void actualBusinessAttachmentsKeepTheirAuthorizedReadPathsAndDoNotWriteLocalFiles() throws Exception {
|
@Test void actualBusinessAttachmentsKeepTheirAuthorizedReadPathsAndDoNotWriteLocalFiles() throws Exception {
|
||||||
var secret=new Properties();try(var in=Files.newInputStream(Path.of("../.codex-tmp/minio-dev-secrets.properties"))){secret.load(in);}
|
var secret=com.ruoyi.projectdev.ProfileConfiguration.load("druid");
|
||||||
var p=new MinioProperties();p.setEnabled(true);p.setEnvironment("dev");p.setBucketName("cmvr-wms-dev");p.setUrl("http://192.168.28.10:9000");
|
var p=new MinioProperties();p.setEnabled(true);p.setEnvironment("dev");p.setBucketName("cmvr-wms-dev");p.setUrl("http://192.168.28.10:9000");
|
||||||
p.setAccessKey(secret.getProperty("minio.access-key"));p.setSecretKey(secret.getProperty("minio.secret-key"));
|
p.setAccessKey(secret.getProperty("minio.access-key"));p.setSecretKey(secret.getProperty("minio.secret-key"));
|
||||||
var storage=new BusinessFileStorage(p,new MockEnvironment());
|
var storage=new BusinessFileStorage(p,new MockEnvironment());
|
||||||
|
|||||||
@ -18,8 +18,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
class MinioLiveStorageTest {
|
class MinioLiveStorageTest {
|
||||||
@TempDir Path temp;
|
@TempDir Path temp;
|
||||||
@Test void createsIsolatedPrivateBucketsAndVerifiesUploadReadDeleteAndNoOverwrite() throws Exception {
|
@Test void createsIsolatedPrivateBucketsAndVerifiesUploadReadDeleteAndNoOverwrite() throws Exception {
|
||||||
Properties secret=new Properties();
|
Properties secret=com.ruoyi.projectdev.ProfileConfiguration.load("druid");
|
||||||
try(var input=Files.newInputStream(Path.of("../.codex-tmp/minio-dev-secrets.properties"))) {secret.load(input);}
|
|
||||||
String endpoint="http://192.168.28.10:9000";
|
String endpoint="http://192.168.28.10:9000";
|
||||||
MinioClient client=MinioClient.builder().endpoint(endpoint).credentials(secret.getProperty("minio.access-key"),secret.getProperty("minio.secret-key")).build();
|
MinioClient client=MinioClient.builder().endpoint(endpoint).credentials(secret.getProperty("minio.access-key"),secret.getProperty("minio.secret-key")).build();
|
||||||
String testName="storage-verification-"+UUID.randomUUID()+".bin";
|
String testName="storage-verification-"+UUID.randomUUID()+".bin";
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import static org.mockito.ArgumentMatchers.*;
|
|||||||
@EnabledIfSystemProperty(named="minioLiveTests",matches="true")
|
@EnabledIfSystemProperty(named="minioLiveTests",matches="true")
|
||||||
class ProductAttachmentMinioLiveTest {
|
class ProductAttachmentMinioLiveTest {
|
||||||
@Test void aFiftyMiBVersionAttachmentRoundTripsThroughTheRealPrivateDevelopmentBucket()throws Exception{
|
@Test void aFiftyMiBVersionAttachmentRoundTripsThroughTheRealPrivateDevelopmentBucket()throws Exception{
|
||||||
var secrets=new Properties();try(var input=Files.newInputStream(Path.of("../.codex-tmp/minio-dev-secrets.properties"))){secrets.load(input);}
|
var secrets=com.ruoyi.projectdev.ProfileConfiguration.load("druid");
|
||||||
var properties=new MinioProperties();properties.setEnabled(true);properties.setEnvironment("dev");properties.setBucketName("cmvr-wms-dev");properties.setUrl("http://192.168.28.10:9000");properties.setAccessKey(secrets.getProperty("minio.access-key"));properties.setSecretKey(secrets.getProperty("minio.secret-key"));
|
var properties=new MinioProperties();properties.setEnabled(true);properties.setEnvironment("dev");properties.setBucketName("cmvr-wms-dev");properties.setUrl("http://192.168.28.10:9000");properties.setAccessKey(secrets.getProperty("minio.access-key"));properties.setSecretKey(secrets.getProperty("minio.secret-key"));
|
||||||
var storage=new BusinessFileStorage(properties,new MockEnvironment());var db=mock(JdbcTemplate.class);var products=mock(ProductVersionService.class);when(products.requireProduct(7L)).thenReturn(new ProductionProduct());
|
var storage=new BusinessFileStorage(properties,new MockEnvironment());var db=mock(JdbcTemplate.class);var products=mock(ProductVersionService.class);when(products.requireProduct(7L)).thenReturn(new ProductionProduct());
|
||||||
var service=new ProductAttachmentService();ReflectionTestUtils.setField(service,"storage",storage);ReflectionTestUtils.setField(service,"db",db);ReflectionTestUtils.setField(service,"products",products);
|
var service=new ProductAttachmentService();ReflectionTestUtils.setField(service,"storage",storage);ReflectionTestUtils.setField(service,"db",db);ReflectionTestUtils.setField(service,"products",products);
|
||||||
|
|||||||
@ -19,22 +19,22 @@ class ProductionProfileTest {
|
|||||||
assertTrue(url.startsWith("jdbc:mysql://192.168.28.10:3306/cmvr-project-prod?"));
|
assertTrue(url.startsWith("jdbc:mysql://192.168.28.10:3306/cmvr-project-prod?"));
|
||||||
assertFalse(url.contains("cmvr-project-dev"));
|
assertFalse(url.contains("cmvr-project-dev"));
|
||||||
assertEquals("cmvr-project-prod", p.getProperty("ruoyi.cacheNamespace"));
|
assertEquals("cmvr-project-prod", p.getProperty("ruoyi.cacheNamespace"));
|
||||||
assertEquals("${PROD_REDIS_DATABASE:13}", p.getProperty("spring.data.redis.database"));
|
assertEquals("13", p.getProperty("spring.data.redis.database"));
|
||||||
assertNull(p.getProperty("spring.profiles.include"));
|
assertNull(p.getProperty("spring.profiles.include"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test void secretsAreRequiredAndDevelopmentUtilitiesAreDisabled() {
|
@Test void settingsAreSelfContainedAndDevelopmentUtilitiesAreDisabled() {
|
||||||
var p = production();
|
var p = production();
|
||||||
assertEquals("${PROD_DB_USERNAME}", p.getProperty("spring.datasource.druid.master.username"));
|
for(String key:new String[]{"spring.datasource.druid.master.username","spring.datasource.druid.master.password","spring.data.redis.password","token.secret","minio.access-key","minio.secret-key","spring.mail.username","spring.mail.password"}) {
|
||||||
assertEquals("${PROD_DB_PASSWORD}", p.getProperty("spring.datasource.druid.master.password"));
|
assertTrue(p.getProperty(key)!=null&&!p.getProperty(key).isBlank(),"Missing configured property: "+key);
|
||||||
assertEquals("${PROD_REDIS_PASSWORD}", p.getProperty("spring.data.redis.password"));
|
assertFalse(p.getProperty(key).contains("${"),"External placeholder is not allowed: "+key);
|
||||||
assertEquals("${PROD_TOKEN_SECRET}", p.getProperty("token.secret"));
|
}
|
||||||
for (String key : new String[]{"projectdev.history-entry-enabled", "projectdev.real-data-replay-enabled",
|
for (String key : new String[]{"projectdev.history-entry-enabled", "projectdev.real-data-replay-enabled",
|
||||||
"spring.datasource.druid.statViewServlet.enabled", "springdoc.api-docs.enabled",
|
"spring.datasource.druid.statViewServlet.enabled", "springdoc.api-docs.enabled",
|
||||||
"springdoc.swagger-ui.enabled", "spring.devtools.restart.enabled", "spring.quartz.auto-startup"}) {
|
"springdoc.swagger-ui.enabled", "spring.devtools.restart.enabled", "spring.quartz.auto-startup"}) {
|
||||||
assertEquals("false", p.getProperty(key), key);
|
assertEquals("false", p.getProperty(key), key);
|
||||||
}
|
}
|
||||||
assertEquals("never", p.getProperty("spring.sql.init.mode"));
|
assertEquals("never", p.getProperty("spring.sql.init.mode"));
|
||||||
assertEquals("${PROD_BIND_ADDRESS:127.0.0.1}", p.getProperty("server.address"));
|
assertEquals("127.0.0.1", p.getProperty("server.address"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.ruoyi.projectdev;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
|
/** Loads the same committed settings as the application; never logs credentials. */
|
||||||
|
public final class ProfileConfiguration {
|
||||||
|
private ProfileConfiguration() { }
|
||||||
|
|
||||||
|
public static Properties load(String profile) {
|
||||||
|
var yaml = new YamlPropertiesFactoryBean();
|
||||||
|
yaml.setResources(new ClassPathResource("application.yml"),
|
||||||
|
new ClassPathResource("application-" + profile + ".yml"));
|
||||||
|
return yaml.getObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,7 +27,7 @@ class RedisEnvironmentIsolationTest {
|
|||||||
var development=load("application-druid.yml");var production=load("application-prod.yml");
|
var development=load("application-druid.yml");var production=load("application-prod.yml");
|
||||||
completeConnection(development);completeConnection(production);
|
completeConnection(development);completeConnection(production);
|
||||||
assertEquals("11",development.getProperty("spring.data.redis.database"));
|
assertEquals("11",development.getProperty("spring.data.redis.database"));
|
||||||
assertEquals("${PROD_REDIS_DATABASE:13}",production.getProperty("spring.data.redis.database"));
|
assertEquals("13",production.getProperty("spring.data.redis.database"));
|
||||||
assertNotEquals(development.getProperty("ruoyi.cacheNamespace"),production.getProperty("ruoyi.cacheNamespace"));
|
assertNotEquals(development.getProperty("ruoyi.cacheNamespace"),production.getProperty("ruoyi.cacheNamespace"));
|
||||||
}
|
}
|
||||||
@Test void locallyConfiguredTestEnvironmentUsesItsOwnRedisDatabase() {
|
@Test void locallyConfiguredTestEnvironmentUsesItsOwnRedisDatabase() {
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
package com.ruoyi.projectdev;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class SelfContainedConfigurationTest {
|
||||||
|
@Test void committedProfilesNeedNoExternalSecretsFileOrEnvironmentPlaceholders() throws Exception {
|
||||||
|
for (String name : new String[]{"application.yml", "application-druid.yml", "application-prod.yml"}) {
|
||||||
|
try (var input = new ClassPathResource(name).getInputStream()) {
|
||||||
|
String source = new String(input.readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
assertFalse(source.contains("${"), "Unexpected external placeholder in " + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String profile : new String[]{"druid", "prod"}) {
|
||||||
|
var settings = ProfileConfiguration.load(profile);
|
||||||
|
assertFalse(settings.containsKey("spring.config.import"));
|
||||||
|
for (String key : new String[]{"spring.datasource.druid.master.username",
|
||||||
|
"spring.datasource.druid.master.password", "spring.data.redis.password", "token.secret",
|
||||||
|
"minio.access-key", "minio.secret-key", "spring.mail.username", "spring.mail.password"}) {
|
||||||
|
assertTrue(settings.getProperty(key) != null && !settings.getProperty(key).isBlank(),
|
||||||
|
"Missing configured property in " + profile + ": " + key);
|
||||||
|
}
|
||||||
|
assertEquals("true", settings.getProperty("spring.mail.properties.mail.smtp.auth"));
|
||||||
|
assertEquals("true", settings.getProperty("spring.mail.properties.mail.smtp.starttls.required"));
|
||||||
|
assertEquals("true", settings.getProperty("spring.mail.properties.mail.smtp.ssl.checkserveridentity"));
|
||||||
|
assertEquals("cmvr-wms-" + (profile.equals("prod") ? "prod" : "dev"), settings.getProperty("minio.bucket-name"));
|
||||||
|
assertEquals(profile.equals("prod") ? "prod" : "dev", settings.getProperty("minio.environment"));
|
||||||
|
}
|
||||||
|
assertEquals("druid", ProfileConfiguration.load("druid").getProperty("spring.profiles.active"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test void productionContainerUsesPackagedSettingsWithoutLegacyEnvironmentFile() throws Exception {
|
||||||
|
Path root = Path.of(System.getProperty("user.dir")).toAbsolutePath();
|
||||||
|
if (root.getFileName().toString().equals("ruoyi-admin")) root = root.getParent();
|
||||||
|
String compose = Files.readString(root.resolve("scripts/deploy/docker-compose.yml"));
|
||||||
|
assertFalse(compose.contains("env_file:"));
|
||||||
|
assertFalse(compose.contains("environment:"));
|
||||||
|
String dockerfile = Files.readString(root.resolve("scripts/deploy/Dockerfile"));
|
||||||
|
assertTrue(dockerfile.contains("-Xmx2g"));
|
||||||
|
assertTrue(dockerfile.contains("--spring.profiles.active=prod"));
|
||||||
|
assertTrue(dockerfile.contains("-Duser.timezone=Asia/Shanghai"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,5 @@
|
|||||||
package com.ruoyi.system.notification;
|
package com.ruoyi.system.notification;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Properties;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
@ -12,10 +9,8 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
@EnabledIfSystemProperty(named="feedbackMailSmtpTest",matches="true")
|
@EnabledIfSystemProperty(named="feedbackMailSmtpTest",matches="true")
|
||||||
class FeedbackMailSmtpConnectionTest {
|
class FeedbackMailSmtpConnectionTest {
|
||||||
@Test void legacyCredentialsAuthenticateViaJakartaMailWithoutSending() throws Exception {
|
@Test void legacyCredentialsAuthenticateViaJakartaMailWithoutSending() throws Exception {
|
||||||
Path root=Path.of(System.getProperty("user.dir")).toAbsolutePath();
|
var secrets=com.ruoyi.projectdev.ProfileConfiguration.load("druid");
|
||||||
if(root.getFileName().toString().equals("ruoyi-admin"))root=root.getParent();
|
var sender=new JavaMailSenderImpl();sender.setHost(secrets.getProperty("spring.mail.host"));sender.setPort(Integer.parseInt(secrets.getProperty("spring.mail.port")));
|
||||||
var secrets=new Properties();try(var in=Files.newInputStream(root.resolve(".codex-tmp/mail-dev-secrets.properties"))){secrets.load(in);}
|
|
||||||
var sender=new JavaMailSenderImpl();sender.setHost("smtp.qq.com");sender.setPort(587);
|
|
||||||
sender.setUsername(secrets.getProperty("spring.mail.username"));sender.setPassword(secrets.getProperty("spring.mail.password"));
|
sender.setUsername(secrets.getProperty("spring.mail.username"));sender.setPassword(secrets.getProperty("spring.mail.password"));
|
||||||
assertNotNull(sender.getUsername());assertNotNull(sender.getPassword());
|
assertNotNull(sender.getUsername());assertNotNull(sender.getPassword());
|
||||||
var props=sender.getJavaMailProperties();props.setProperty("mail.smtp.auth","true");props.setProperty("mail.smtp.starttls.enable","true");
|
var props=sender.getJavaMailProperties();props.setProperty("mail.smtp.auth","true");props.setProperty("mail.smtp.starttls.enable","true");
|
||||||
|
|||||||
@ -2,5 +2,4 @@
|
|||||||
FROM wms-ruoyi-cmvr-wms:latest
|
FROM wms-ruoyi-cmvr-wms:latest
|
||||||
COPY cmvr-wms.jar /app/app.jar
|
COPY cmvr-wms.jar /app/app.jar
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV TZ=Asia/Shanghai
|
ENTRYPOINT ["java", "-Xms256m", "-Xmx2g", "-XX:+ExitOnOutOfMemoryError", "-Duser.timezone=Asia/Shanghai", "-Dfile.encoding=UTF-8", "-jar", "/app/app.jar", "--spring.profiles.active=prod"]
|
||||||
ENTRYPOINT ["java", "-Dfile.encoding=UTF-8", "-jar", "/app/app.jar", "--spring.profiles.active=prod"]
|
|
||||||
|
|||||||
@ -46,12 +46,6 @@ public class InitializeEmptyProduction {
|
|||||||
if(!changed.isEmpty())throw new IllegalStateException("Production copy verification failed: "+changed);
|
if(!changed.isEmpty())throw new IllegalStateException("Production copy verification failed: "+changed);
|
||||||
System.out.println("Production initialized and fingerprint verified: tables="+names.size()+", rows="+rows);
|
System.out.println("Production initialized and fingerprint verified: tables="+names.size()+", rows="+rows);
|
||||||
}
|
}
|
||||||
String redisPassword=null;
|
System.out.println("Backend settings are declared in application-prod.yml; no environment file or replacement token is generated.");
|
||||||
for(String line:Files.readAllLines(Path.of("ruoyi-admin/src/main/resources/application-druid.yml")))if(line.matches("^ {12}password:.*"))redisPassword=DatabaseTool.value(line.substring(line.indexOf(':')+1).trim());
|
|
||||||
if(redisPassword==null)throw new IllegalStateException("Redis credentials not found; environment not generated");
|
|
||||||
byte[] random=new byte[64];new java.security.SecureRandom().nextBytes(random);
|
|
||||||
String env="PROD_DB_USERNAME="+config.get("username")+"\nPROD_DB_PASSWORD="+config.get("password")+"\nPROD_REDIS_PASSWORD="+redisPassword+"\nPROD_TOKEN_SECRET="+Base64.getEncoder().encodeToString(random)+"\nPROD_REDIS_HOST=192.168.28.10\nPROD_REDIS_PORT=6379\nPROD_REDIS_DATABASE=13\nPROD_BIND_ADDRESS=127.0.0.1\nPROD_BACKEND_PORT=28183\nPROD_UPLOAD_PATH=/app/uploads\nRUOYI_LOG_PATH=/app/logs\n";
|
|
||||||
Files.writeString(output.resolve("production.env"),env,StandardOpenOption.CREATE_NEW);
|
|
||||||
System.out.println("Server environment generated in ignored release staging; no secret values printed.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,16 +7,8 @@ services:
|
|||||||
container_name: cmvr-project-prod-backend
|
container_name: cmvr-project-prod-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
network_mode: host
|
network_mode: host
|
||||||
env_file:
|
# All application settings come from application-prod.yml inside the backend jar.
|
||||||
- path: ./shared/production.env
|
# Do not inject a legacy production.env: it would override the checked-in yml.
|
||||||
format: raw
|
|
||||||
environment:
|
|
||||||
TZ: Asia/Shanghai
|
|
||||||
JAVA_TOOL_OPTIONS: -Xms256m -Xmx2g -XX:+ExitOnOutOfMemoryError
|
|
||||||
SUPPLIER_LICENSE_PATH: /app/.supplier-license-private
|
|
||||||
FEEDBACK_IMAGE_PATH: /app/uploads-feedback-private
|
|
||||||
ASSISTANT_ATTACHMENT_PATH: /app/.assistant-private
|
|
||||||
PURCHASE_DOCUMENT_PATH: /app/.purchase-documents-private
|
|
||||||
mem_limit: 3g
|
mem_limit: 3g
|
||||||
volumes:
|
volumes:
|
||||||
- ./shared/logs:/app/logs
|
- ./shared/logs:/app/logs
|
||||||
|
|||||||
@ -1,16 +1,4 @@
|
|||||||
# Spring Boot 3.5 / Jakarta Mail; never reuse javax.mail dependencies.
|
# Historical filename retained; mail environment variables are no longer required.
|
||||||
MAIL_HOST=smtp.qq.com
|
# Set spring.mail and notification-mail directly in application-druid.yml / application-prod.yml.
|
||||||
MAIL_PORT=587
|
# Spring Boot 3.5 + Jakarta Mail; no javax.mail dependency is used.
|
||||||
MAIL_USERNAME=
|
# Recipients are still configured by role in the feedback notification settings.
|
||||||
MAIL_PASSWORD=
|
|
||||||
MAIL_ENABLED=false
|
|
||||||
# Apply sql/projectdev/20261016_feedback_mail.sql to the intended environment first.
|
|
||||||
# This migration currently guards cmvr-project-dev; production is intentionally not enabled.
|
|
||||||
FEEDBACK_NOTIFICATION_ENABLED=false
|
|
||||||
FEEDBACK_NOTIFICATION_ENV=dev
|
|
||||||
NOTIFICATION_CENTER_ENABLED=false
|
|
||||||
# Initialize sql/projectdev/20261016_notification_center.sql in the dev database before enabling.
|
|
||||||
# NotificationGateway and NotificationPolicy live in ruoyi-common; implementations live in ruoyi-system.
|
|
||||||
# New business sources register a NotificationPolicy bean; unregistered sources are denied.
|
|
||||||
# Admin: User feedback -> Notification settings -> choose roles per module.
|
|
||||||
# Default is manual preview/send. Role membership never grants additional data access.
|
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
# Development only. Copy to .codex-tmp/minio-dev-secrets.properties (Git ignored),
|
# Historical filename retained for compatibility with existing documentation.
|
||||||
# or supply MINIO_ACCESS_KEY and MINIO_SECRET_KEY in the process environment.
|
# No separate secrets file or process environment variable is required.
|
||||||
# Never put real credentials in this example or application*.yml.
|
# Configure MinIO directly in application-druid.yml / application-prod.yml.
|
||||||
minio.access-key=
|
# Development bucket: cmvr-wms-dev; production bucket: cmvr-wms-prod.
|
||||||
minio.secret-key=
|
|
||||||
# application-druid.yml enforces bucket cmvr-wms-dev.
|
|
||||||
# application-prod.yml enforces bucket cmvr-wms-prod, using the server EnvironmentFile.
|
|
||||||
# The existing cmvr-iot bucket is not used or modified.
|
# The existing cmvr-iot bucket is not used or modified.
|
||||||
|
|||||||
@ -1,18 +1,4 @@
|
|||||||
# Copy to the server's protected EnvironmentFile; never commit the real file.
|
# Historical filename retained for links to the initial deployment.
|
||||||
# Database: 192.168.28.10:3306/cmvr-project-prod (fixed in application-prod.yml).
|
# Do not create or inject production.env for new releases.
|
||||||
PROD_DB_USERNAME=
|
# Configure ruoyi-admin/src/main/resources/application-prod.yml directly.
|
||||||
PROD_DB_PASSWORD=
|
# The Dockerfile activates prod; docker-compose.yml no longer uses env_file.
|
||||||
PROD_REDIS_PASSWORD=
|
|
||||||
# Use a new, random secret of at least 32 characters, not the development secret.
|
|
||||||
PROD_TOKEN_SECRET=
|
|
||||||
PROD_REDIS_HOST=192.168.28.10
|
|
||||||
PROD_REDIS_PORT=6379
|
|
||||||
PROD_REDIS_DATABASE=13
|
|
||||||
PROD_BIND_ADDRESS=127.0.0.1
|
|
||||||
PROD_BACKEND_PORT=8182
|
|
||||||
PROD_UPLOAD_PATH=/app/uploads
|
|
||||||
RUOYI_LOG_PATH=/app/logs
|
|
||||||
MINIO_ENABLED=true
|
|
||||||
MINIO_URL=http://192.168.28.10:9000
|
|
||||||
MINIO_ACCESS_KEY=
|
|
||||||
MINIO_SECRET_KEY=
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user