🐳 分离 docker 镜像.

This commit is contained in:
lijiahangmax
2025-03-17 21:27:48 +08:00
parent bc776e4186
commit 9752dfa680
12 changed files with 110 additions and 55 deletions

View File

@@ -1,6 +1,9 @@
SERVICE_PORT=1081
VOLUME_BASE=/data/orion-visor-space/docker-volumes VOLUME_BASE=/data/orion-visor-space/docker-volumes
SERVICE_PORT=1081
SPRING_PROFILES_ACTIVE=prod
SECRET_KEY=uQeacXV8b3isvKLK
MYSQL_HOST=mysql MYSQL_HOST=mysql
MYSQL_PORT=3306 MYSQL_PORT=3306
MYSQL_DATABASE=orion_visor MYSQL_DATABASE=orion_visor
@@ -11,5 +14,4 @@ MYSQL_ROOT_PASSWORD=Data@123456
REDIS_HOST=redis REDIS_HOST=redis
REDIS_PASSWORD=Data@123456 REDIS_PASSWORD=Data@123456
SECRET_KEY=uQeacXV8b3isvKLK
DEMO_MODE=false DEMO_MODE=false

View File

@@ -1,11 +1,13 @@
version: '3.3' version: '3.3'
services: services:
service: service:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest
privileged: true privileged: true
ports: ports:
- 1081:80 - 9200:9200
environment: environment:
- SPRING_PROFILES_ACTIVE=prod
- MYSQL_HOST=mysql - MYSQL_HOST=mysql
- MYSQL_PORT=3306 - MYSQL_PORT=3306
- MYSQL_DATABASE=orion_visor - MYSQL_DATABASE=orion_visor
@@ -19,18 +21,18 @@ services:
- /data/orion-visor-space/docker-volumes/service/root-orion:/root/orion - /data/orion-visor-space/docker-volumes/service/root-orion:/root/orion
healthcheck: healthcheck:
test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ] test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ]
interval: 3s interval: 15s
timeout: 300s timeout: 5s
retries: 200 retries: 10
start_period: 3s start_period: 15s
depends_on: depends_on:
mysql: mysql:
condition: service_healthy condition: service_healthy
redis: redis:
condition: service_healthy condition: service_healthy
links: networks:
- mysql - orion-visor-net
- redis
mysql: mysql:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:latest image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:latest
privileged: true privileged: true
@@ -44,13 +46,15 @@ services:
volumes: volumes:
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql:/var/lib/mysql - /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql:/var/lib/mysql
- /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql-files:/var/lib/mysql-files - /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql-files:/var/lib/mysql-files
- /data/orion-visor-space/docker-volumes/mysql/etc-mysql:/etc/mysql
healthcheck: healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ] test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ]
interval: 3s interval: 15s
timeout: 60s timeout: 5s
retries: 10 retries: 10
start_period: 3s start_period: 5s
networks:
- orion-visor-net
redis: redis:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest
privileged: true privileged: true
@@ -63,10 +67,13 @@ services:
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}" command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
healthcheck: healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 3s interval: 15s
timeout: 60s timeout: 5s
retries: 10 retries: 10
start_period: 3s start_period: 5s
networks:
- orion-visor-net
testing: testing:
build: build:
context: ./docker/e2e context: ./docker/e2e
@@ -75,5 +82,9 @@ services:
depends_on: depends_on:
service: service:
condition: service_healthy condition: service_healthy
links: networks:
- service - orion-visor-net
networks:
orion-visor-net:
driver: bridge

View File

@@ -1,11 +1,22 @@
version: '3.3' version: '3.3'
services: services:
ui:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-ui:latest
ports:
- ${SERVICE_PORT:-1081}:80
restart: unless-stopped
depends_on:
service:
condition: service_healthy
networks:
- orion-visor-net
service: service:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest
privileged: true privileged: true
ports:
- ${SERVICE_PORT:-1081}:80
environment: environment:
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-prod}
- MYSQL_HOST=${MYSQL_HOST:-mysql} - MYSQL_HOST=${MYSQL_HOST:-mysql}
- MYSQL_PORT=${MYSQL_PORT:-3306} - MYSQL_PORT=${MYSQL_PORT:-3306}
- MYSQL_DATABASE=${MYSQL_DATABASE:-orion_visor} - MYSQL_DATABASE=${MYSQL_DATABASE:-orion_visor}
@@ -17,20 +28,21 @@ services:
- DEMO_MODE=${DEMO_MODE:-false} - DEMO_MODE=${DEMO_MODE:-false}
volumes: volumes:
- ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/service/root-orion:/root/orion - ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/service/root-orion:/root/orion
restart: unless-stopped
healthcheck: healthcheck:
test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ] test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ]
interval: 15s interval: 15s
timeout: 300s timeout: 5s
retries: 15 retries: 10
start_period: 3s start_period: 15s
depends_on: depends_on:
mysql: mysql:
condition: service_healthy condition: service_healthy
redis: redis:
condition: service_healthy condition: service_healthy
links: networks:
- mysql - orion-visor-net
- redis
mysql: mysql:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:latest image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:latest
privileged: true privileged: true
@@ -44,13 +56,16 @@ services:
volumes: volumes:
- ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/mysql/var-lib-mysql:/var/lib/mysql - ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/mysql/var-lib-mysql:/var/lib/mysql
- ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/mysql/var-lib-mysql-files:/var/lib/mysql-files - ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/mysql/var-lib-mysql-files:/var/lib/mysql-files
- ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/mysql/etc-mysql:/etc/mysql restart: unless-stopped
healthcheck: healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ] test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ]
interval: 15s interval: 15s
timeout: 60s timeout: 5s
retries: 15 retries: 10
start_period: 3s start_period: 5s
networks:
- orion-visor-net
redis: redis:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest
privileged: true privileged: true
@@ -61,18 +76,28 @@ services:
volumes: volumes:
- ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/redis/data:/data - ${VOLUME_BASE:-/data/orion-visor-space/docker-volumes}/redis/data:/data
command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}" command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
restart: unless-stopped
healthcheck: healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 15s interval: 15s
timeout: 60s timeout: 5s
retries: 15 retries: 10
start_period: 3s start_period: 5s
networks:
- orion-visor-net
adminer: adminer:
image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:latest image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:latest
ports: ports:
- 8081:8080 - 8081:8080
environment:
- ADMINER_DEFAULT_SERVER=${MYSQL_HOST:-mysql}
depends_on: depends_on:
mysql: mysql:
condition: service_healthy condition: service_healthy
links: networks:
- mysql - orion-visor-net
networks:
orion-visor-net:
driver: bridge

View File

@@ -2,7 +2,7 @@
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json # yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
name: orion-visor name: orion-visor
api: | api: |
{{default "http://orion-visor-service:80" (env "SERVER")}} {{default "http://orion-visor-service:9200" (env "SERVER")}}
items: items:
- name: login - name: login
request: request:

View File

@@ -4,7 +4,9 @@ docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:${ver
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:${version} docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:${version}
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:${version} docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:${version}
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:${version} docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:${version}
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-ui:${version}
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:latest docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:latest
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:latest docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:latest
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-ui:latest

View File

@@ -1,4 +1,4 @@
FROM nginx:alpine FROM openjdk:8-jdk-alpine
USER root USER root
WORKDIR /app WORKDIR /app
# 系统时区 # 系统时区
@@ -8,17 +8,11 @@ RUN \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \ sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update && \ apk update && \
apk add tzdata && \ apk add tzdata && \
apk add dmidecode && \ apk add dmidecode
apk add openjdk8
# 设置时区 # 设置时区
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \ RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo '${TZ}' > /etc/timezone echo '${TZ}' > /etc/timezone
# 删除原 nginx 配置
RUN rm -rf /etc/nginx/conf.d/*
# 复制包 # 复制包
COPY ./orion-visor-launch.jar /app/app.jar COPY ./orion-visor-launch.jar /app/app.jar
COPY ./dist /usr/share/nginx/html
COPY ./entrypoint.sh /app/entrypoint.sh
COPY ./nginx.conf /etc/nginx/conf.d
# 启动 # 启动
ENTRYPOINT [ "sh", "/app/entrypoint.sh" ] CMD ["java", "-jar", "/app/app.jar"]

View File

@@ -1,9 +1,7 @@
#/bin/bash #/bin/bash
version=2.3.5 version=2.3.5
mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar
mv ../../orion-visor-ui/dist ./dist
docker build -t orion-visor-service:${version} . docker build -t orion-visor-service:${version} .
rm -rf ./orion-visor-launch.jar rm -rf ./orion-visor-launch.jar
rm -rf ./dist
docker tag orion-visor-service:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:${version} docker tag orion-visor-service:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:${version}
docker tag orion-visor-service:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest docker tag orion-visor-service:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest

View File

@@ -1,4 +0,0 @@
#!/bin/bash
cd /app
nohup java -jar app.jar --spring.profiles.active=prod 2>&1 &
nginx -g 'daemon off;'

19
docker/ui/Dockerfile Normal file
View File

@@ -0,0 +1,19 @@
FROM nginx:alpine
USER root
# 系统时区
ARG TZ=Asia/Shanghai
# 添加包
RUN \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update && \
apk add tzdata
# 设置时区
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo '${TZ}' > /etc/timezone
# 删除原 nginx 配置
RUN rm -rf /etc/nginx/conf.d/*
# 复制包
COPY ./dist /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/conf.d
# 启动
CMD ["nginx", "-g", "daemon off;"]

8
docker/ui/build.sh Normal file
View File

@@ -0,0 +1,8 @@
#/bin/bash
version=2.3.5
mv ../../orion-visor-ui/dist ./dist
docker build -t orion-visor-ui:${version} .
rm -rf ./orion-visor-launch.jar
rm -rf ./dist
docker tag orion-visor-ui:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-ui:${version}
docker tag orion-visor-ui:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-ui:latest

View File

@@ -39,19 +39,19 @@ import java.util.function.Function;
*/ */
public class ReplaceVersion { public class ReplaceVersion {
private static final String TARGET_VERSION = "2.3.4"; private static final String TARGET_VERSION = "2.3.5";
private static final String REPLACE_VERSION = "2.3.5"; private static final String REPLACE_VERSION = "2.3.6";
private static final String PATH = new File("").getAbsolutePath(); private static final String PATH = new File("").getAbsolutePath();
private static final String[] DOCKER_FILES = new String[]{ private static final String[] DOCKER_FILES = new String[]{
"docker/push.sh", "docker/push.sh",
"docker/adminer/build.sh", "docker/adminer/build.sh",
"docker/adminer/build.sh",
"docker/mysql/build.sh", "docker/mysql/build.sh",
"docker/redis/build.sh", "docker/redis/build.sh",
"docker/service/build.sh", "docker/service/build.sh",
"docker/ui/build.sh",
"docker-compose.yml", "docker-compose.yml",
"docker-compose-testing.yml" "docker-compose-testing.yml"
}; };