mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 18:09:54 +08:00
云快充1.5.0 初始化
This commit is contained in:
40
docker/Dockerfile-App
Normal file
40
docker/Dockerfile-App
Normal file
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/jcpp-base:latest AS base
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN mvn -U -B -T 0.8C clean install -DskipTests
|
||||
|
||||
#分层
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/openjdk:21-jdk-slim-bullseye AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=base /app/jcpp-app-bootstrap/target/application.jar application.jar
|
||||
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
|
||||
|
||||
# 执行
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/openjdk:21-jdk-slim-bullseye
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/extracted/dependencies/ ./
|
||||
COPY --from=builder /app/extracted/spring-boot-loader/ ./
|
||||
COPY --from=builder /app/extracted/snapshot-dependencies/ ./
|
||||
COPY --from=builder /app/extracted/application/ ./
|
||||
COPY --from=base /app/jcpp-app-bootstrap/target/conf ./config
|
||||
COPY --from=base /app/docker/start.sh .
|
||||
|
||||
RUN mkdir -p /var/log/sanbing && \
|
||||
mkdir -p /var/log/sanbing/jcpp && \
|
||||
mkdir -p /var/log/sanbing/accesslog && \
|
||||
mkdir -p /var/log/sanbing/gc && \
|
||||
mkdir -p /var/log/sanbing/heapdump && \
|
||||
chmod 700 -R /var/log/*
|
||||
|
||||
RUN chmod a+x *.sh && mv start.sh /usr/bin
|
||||
|
||||
EXPOSE 8080 8080
|
||||
|
||||
CMD ["start.sh"]
|
||||
|
||||
|
||||
11
docker/Dockerfile-Base
Normal file
11
docker/Dockerfile-Base
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/mvn:3.9.9-jdk21 AS base
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN mvn -U -B -T 0.8C clean install -DskipTests
|
||||
RUN rm -rf /app
|
||||
|
||||
40
docker/Dockerfile-Protocol
Normal file
40
docker/Dockerfile-Protocol
Normal file
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/jcpp-base:latest AS base
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN mvn -U -B -T 0.8C clean install -DskipTests
|
||||
|
||||
#分层
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/openjdk:21-jdk-slim-bullseye AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=base /app/jcpp-protocol-bootstrap/target/application.jar application.jar
|
||||
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
|
||||
|
||||
# 执行
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/sanbing/openjdk:21-jdk-slim-bullseye
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/extracted/dependencies/ ./
|
||||
COPY --from=builder /app/extracted/spring-boot-loader/ ./
|
||||
COPY --from=builder /app/extracted/snapshot-dependencies/ ./
|
||||
COPY --from=builder /app/extracted/application/ ./
|
||||
COPY --from=base /app/jcpp-protocol-bootstrap/target/conf ./config
|
||||
COPY --from=base /app/docker/start.sh .
|
||||
|
||||
RUN mkdir -p /var/log/sanbing && \
|
||||
mkdir -p /var/log/sanbing/jcpp && \
|
||||
mkdir -p /var/log/sanbing/accesslog && \
|
||||
mkdir -p /var/log/sanbing/gc && \
|
||||
mkdir -p /var/log/sanbing/heapdump && \
|
||||
chmod 700 -R /var/log/*
|
||||
|
||||
RUN chmod a+x *.sh && mv start.sh /usr/bin
|
||||
|
||||
EXPOSE 8081 8081
|
||||
|
||||
CMD ["start.sh"]
|
||||
|
||||
|
||||
57
docker/docker-compose.kafka.yml
Normal file
57
docker/docker-compose.kafka.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
networks:
|
||||
sanbing-network:
|
||||
driver: bridge
|
||||
name: sanbing-network
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.10.0.0/24
|
||||
|
||||
services:
|
||||
zookeeper:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/zookeeper:3.9
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
ports:
|
||||
- "2181:2181"
|
||||
environment:
|
||||
ALLOW_ANONYMOUS_LOGIN: true
|
||||
kafka:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/kafka:3.7.1
|
||||
restart: always
|
||||
depends_on:
|
||||
- zookeeper
|
||||
networks:
|
||||
- sanbing-network
|
||||
ports:
|
||||
- "9092:9092"
|
||||
env_file:
|
||||
- kafka.env
|
||||
kafka-exporter:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/kafka-exporter:latest
|
||||
restart: always
|
||||
depends_on:
|
||||
- kafka
|
||||
networks:
|
||||
- sanbing-network
|
||||
ports:
|
||||
- "9308:9308"
|
||||
command:
|
||||
- '--kafka.server=kafka:9092'
|
||||
# 切换示例项目的队列类型为kafka
|
||||
example:
|
||||
restart: always
|
||||
image: example:latest
|
||||
depends_on:
|
||||
- kafka
|
||||
networks:
|
||||
- sanbing-network
|
||||
ports:
|
||||
- "8080:8080"
|
||||
env_file:
|
||||
- queue-kafka.env
|
||||
90
docker/docker-compose.redis-cluster.yml
Normal file
90
docker/docker-compose.redis-cluster.yml
Normal file
@@ -0,0 +1,90 @@
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
networks:
|
||||
sanbing-network:
|
||||
driver: bridge
|
||||
name: sanbing-network
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.10.0.0/24
|
||||
|
||||
services:
|
||||
# Redis cluster
|
||||
redis-node-0:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis-cluster:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
environment:
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
- 'REDISCLI_AUTH=sanbing'
|
||||
- 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
|
||||
|
||||
redis-node-1:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis-cluster:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
depends_on:
|
||||
- redis-node-0
|
||||
environment:
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
- 'REDISCLI_AUTH=sanbing'
|
||||
- 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
|
||||
|
||||
redis-node-2:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis-cluster:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
depends_on:
|
||||
- redis-node-1
|
||||
environment:
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
- 'REDISCLI_AUTH=sanbing'
|
||||
- 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
|
||||
|
||||
redis-node-3:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis-cluster:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
depends_on:
|
||||
- redis-node-2
|
||||
environment:
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
- 'REDISCLI_AUTH=sanbing'
|
||||
- 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
|
||||
|
||||
redis-node-4:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis-cluster:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
depends_on:
|
||||
- redis-node-3
|
||||
environment:
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
- 'REDISCLI_AUTH=sanbing'
|
||||
- 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
|
||||
|
||||
redis-node-5:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis-cluster:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
depends_on:
|
||||
- redis-node-0
|
||||
- redis-node-1
|
||||
- redis-node-2
|
||||
- redis-node-3
|
||||
- redis-node-4
|
||||
environment:
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
- 'REDISCLI_AUTH=sanbing'
|
||||
- 'REDIS_NODES=redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5'
|
||||
- 'REDIS_CLUSTER_REPLICAS=1'
|
||||
- 'REDIS_CLUSTER_CREATOR=yes'
|
||||
49
docker/docker-compose.redis-sentinel.yml
Normal file
49
docker/docker-compose.redis-sentinel.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
networks:
|
||||
sanbing-network:
|
||||
driver: bridge
|
||||
name: sanbing-network
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.10.0.0/24
|
||||
|
||||
services:
|
||||
redis-master:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
environment:
|
||||
- 'REDIS_REPLICATION_MODE=master'
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
|
||||
redis-slave:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
environment:
|
||||
- 'REDIS_REPLICATION_MODE=slave'
|
||||
- 'REDIS_MASTER_HOST=redis-master'
|
||||
- 'REDIS_MASTER_PASSWORD=sanbing'
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
depends_on:
|
||||
- redis-master
|
||||
|
||||
redis-sentinel:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis-sentinel:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
environment:
|
||||
- 'REDIS_MASTER_HOST=redis-master'
|
||||
- 'REDIS_MASTER_SET=mymaster'
|
||||
- 'REDIS_SENTINEL_PASSWORD=sanbing'
|
||||
- 'REDIS_MASTER_PASSWORD=sanbing'
|
||||
depends_on:
|
||||
- redis-master
|
||||
- redis-slave
|
||||
23
docker/docker-compose.redis-standalone.yml
Normal file
23
docker/docker-compose.redis-standalone.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
networks:
|
||||
sanbing-network:
|
||||
driver: bridge
|
||||
name: sanbing-network
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.10.0.0/24
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/sanbing/redis:7.4
|
||||
restart: always
|
||||
networks:
|
||||
- sanbing-network
|
||||
ports:
|
||||
- '6379:6379'
|
||||
environment:
|
||||
- 'REDIS_PASSWORD=sanbing'
|
||||
14
docker/kafka.env
Normal file
14
docker/kafka.env
Normal file
@@ -0,0 +1,14 @@
|
||||
KAFKA_CFG_NODE_ID=0
|
||||
ALLOW_PLAINTEXT_LISTENER=yes
|
||||
KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
|
||||
KAFKA_CFG_LISTENERS=INSIDE://:9093,OUTSIDE://:9092
|
||||
KAFKA_CFG_ADVERTISED_LISTENERS=INSIDE://:9093,OUTSIDE://kafka:9092
|
||||
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
|
||||
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true
|
||||
KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INSIDE
|
||||
KAFKA_CFG_LOG_RETENTION_BYTES=1073741824
|
||||
KAFKA_CFG_SEGMENT_BYTES=268435456
|
||||
KAFKA_CFG_LOG_RETENTION_MS=300000
|
||||
KAFKA_CFG_LOG_CLEANUP_POLICY=delete
|
||||
|
||||
|
||||
2
docker/queue-kafka.env
Normal file
2
docker/queue-kafka.env
Normal file
@@ -0,0 +1,2 @@
|
||||
QUEUE_TYPE=kafka
|
||||
KAFKA_SERVERS=kafka:9092
|
||||
121
docker/schema/schema-postgres.sql
Normal file
121
docker/schema/schema-postgres.sql
Normal file
@@ -0,0 +1,121 @@
|
||||
--
|
||||
-- 抖音关注:程序员三丙
|
||||
-- 知识星球:https://t.zsxq.com/j9b21
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jcpp_user
|
||||
(
|
||||
id uuid not null
|
||||
constraint owner_pkey
|
||||
primary key,
|
||||
created_time timestamp default CURRENT_TIMESTAMP not null,
|
||||
additional_info jsonb,
|
||||
status varchar(16) not null,
|
||||
user_name varchar(255) not null,
|
||||
user_credentials jsonb not null,
|
||||
version int default 1
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uni_user_name
|
||||
on jcpp_user (user_name);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jcpp_station
|
||||
(
|
||||
id uuid not null
|
||||
constraint station_pkey
|
||||
primary key,
|
||||
created_time timestamp default CURRENT_TIMESTAMP not null,
|
||||
additional_info jsonb,
|
||||
station_name varchar(255) not null,
|
||||
station_code varchar(255) not null,
|
||||
owner_id uuid not null,
|
||||
longitude double precision not null,
|
||||
latitude double precision not null,
|
||||
owner_type varchar(16) not null,
|
||||
province varchar(255),
|
||||
city varchar(255),
|
||||
county varchar(255),
|
||||
address varchar(255),
|
||||
status varchar(16) not null,
|
||||
version int default 1
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uni_station_code
|
||||
on jcpp_station (station_code);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jcpp_pile
|
||||
(
|
||||
id uuid not null
|
||||
constraint pile_pkey
|
||||
primary key,
|
||||
created_time timestamp default CURRENT_TIMESTAMP not null,
|
||||
additional_info jsonb,
|
||||
pile_name varchar(255) not null,
|
||||
pile_code varchar(255) not null,
|
||||
protocol varchar(255) not null,
|
||||
station_id uuid not null,
|
||||
owner_id uuid not null,
|
||||
owner_type varchar(16) not null,
|
||||
brand varchar(255),
|
||||
model varchar(255),
|
||||
manufacturer varchar(255),
|
||||
status varchar(16) not null,
|
||||
type varchar(16) not null,
|
||||
version int default 1
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uni_pile_code
|
||||
on jcpp_pile (pile_code);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jcpp_gun
|
||||
(
|
||||
id uuid not null
|
||||
primary key,
|
||||
created_time timestamp default CURRENT_TIMESTAMP not null,
|
||||
additional_info varchar(255),
|
||||
gun_no varchar(255) not null,
|
||||
gun_name varchar(255) not null,
|
||||
gun_code varchar(255) not null,
|
||||
station_id uuid not null,
|
||||
pile_id uuid not null,
|
||||
owner_id uuid not null,
|
||||
owner_type varchar(16) not null,
|
||||
run_status varchar(16) not null,
|
||||
run_status_updated_time timestamp not null,
|
||||
opt_status varchar(16) not null,
|
||||
version int default 1
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uni_gun_code
|
||||
on jcpp_gun (gun_code);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jcpp_order
|
||||
(
|
||||
id uuid not null
|
||||
primary key,
|
||||
internal_order_no varchar(255) not null,
|
||||
external_order_no varchar(255) not null,
|
||||
pile_order_No varchar(255) not null,
|
||||
created_time timestamp default CURRENT_TIMESTAMP not null,
|
||||
additional_info jsonb,
|
||||
updated_time timestamp,
|
||||
cancelled_time timestamp,
|
||||
status varchar(16) not null,
|
||||
type varchar(16) not null,
|
||||
creator_id uuid not null,
|
||||
station_id uuid not null,
|
||||
pile_id uuid not null,
|
||||
gun_id uuid not null,
|
||||
plate_no varchar(64),
|
||||
settlement_amount bigint default 0 not null,
|
||||
settlement_details jsonb,
|
||||
electricity_quantity numeric(16, 9) default 0 not null
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uni_internal_order_no
|
||||
on jcpp_order (internal_order_no);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uni_external_order_no
|
||||
on jcpp_order (external_order_no);
|
||||
|
||||
21
docker/start.sh
Normal file
21
docker/start.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# 抖音关注:程序员三丙
|
||||
# 知识星球:https://t.zsxq.com/j9b21
|
||||
#
|
||||
|
||||
echo "Starting Server ..."
|
||||
|
||||
export JAVA_APP_OPTS="-XX:+UseContainerSupport -XX:InitialRAMPercentage=10 -XX:MaxRAMPercentage=70 \
|
||||
-Xlog:gc*,heap*,age*,safepoint=debug:file=/var/log/sanbing/gc/gc.log:time,uptime,level,tags:filecount=10,filesize=10M \
|
||||
-XX:+HeapDumpOnOutOfMemoryError \
|
||||
-XX:HeapDumpPath=/var/log/sanbing/heapdump/ \
|
||||
-XX:+UseTLAB -XX:+ResizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark \
|
||||
-XX:+UseG1GC -XX:MaxGCPauseMillis=500 -XX:+UseStringDeduplication -XX:+ParallelRefProcEnabled -XX:MaxTenuringThreshold=10 \
|
||||
-Xss512k -XX:MaxDirectMemorySize=128M -XX:G1ReservePercent=20 \
|
||||
-XX:-OmitStackTraceInFastThrow \
|
||||
-Dlogging.config=/app/config/log4j2.xml"
|
||||
|
||||
#export JAVA_OPTS_EXTEND="-Xdebug -Xrunjdwp:transport=dt_socket,address=0.0.0.0:8000,server=y,suspend=n"
|
||||
|
||||
exec java $JAVA_APP_OPTS $JAVA_OPTS_EXTEND $JAVA_OPTS -Dnetworkaddress.cache.ttl=60 -jar /app/application.jar
|
||||
Reference in New Issue
Block a user