1
0

feat: 添加Docker构建

This commit is contained in:
TsMask
2025-05-15 14:40:57 +08:00
parent bbbd5471c7
commit 7891d268cb
12 changed files with 591 additions and 44 deletions

22
.gitignore vendored Normal file
View File

@@ -0,0 +1,22 @@
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
.idea/
# Built Visual Studio Code Extensions
*.vsix
*.log
*.log
*.bak
*.exe
# Build Output
tmp/*

View File

@@ -12,13 +12,23 @@ node.js: v20.18.0 (or above)
## Build Guide
### Pull Code
`pwd` default in `/root`
```bash
git clone https://xxx@git/ems.git omc.git
cd omc.git
cd omc.git && ls
# be.ems build.ems fe.ems.vue3
```
### Build System Pageage Manager
```bash
# Universal
bash pkg.sh --web --api -v 2.2503.2
# RemoveChinese
bash pkg-en.sh --web --api -v 2.2503.2
bash pkg-remove-chinese.sh --web --api -v 2.2503.2
# Place in upper directory for execution - Remote copy front-end files for packaging
bash ../pkg-front.sh --web -v 2.2503.2
bash pkg-copy-front.sh --web -v 2.2503.2
```

158
build-docker.sh Normal file
View File

@@ -0,0 +1,158 @@
#!/bin/bash
# Check if Docker is installed
if command -v docker &> /dev/null then
echo $(docker --version)
else
echo "Docker is not installed"
exit 1
fi
# Default Version
VERSION="1.0.0"
# Default Platform
PLATFORM="linux/amd64"
# Default Platform Architecture
PLATFORM_ARCH="amd64"
# Default System
SYSTEM="ubuntu22.04"
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Build Software Package OPTION:"
echo " -v, --version Specify the version"
echo " -p, --platform Specify the platform architecture (linux/amd64,linux/arm64)"
echo " -s, --system Specify the system image (ubuntu22.04)"
echo " -h Display this help message"
echo
exit 1
}
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v|--version) VERSION="$2"; shift 2 ;; # Processing the version after -v
-p|--platform) PLATFORM="$2"; shift 2 ;; # Processing the platform after -p
-s|--system) SYSTEM="$2"; shift 2 ;; # Processing the system after -s
*) usage ;;
esac
done
# output result
echo "Version: $VERSION"
# =================== Compile System Information
# Determine if -p is passed in
if [ -n "$PLATFORM" ]; then
if [[ "$PLATFORM" != "linux/amd64" && "$PLATFORM" != "linux/arm64" ]]; then
echo "Error: platform can only be 'linux/amd64' or 'linux/arm64'."
exit 1
fi
fi
echo "Platform: $PLATFORM"
# Get the platform architecture
get_platform_arch() {
if [[ "$PLATFORM" = "linux/amd64" ]]; then
echo "amd64"
elif [[ "$PLATFORM" = "linux/arm64" ]]; then
echo "arm64"
else
echo "unknown platform"
exit 1
fi
}
PLATFORM_ARCH=$(get_platform_arch)
# Determine if -s is passed in
if [ -n "$SYSTEM" ]; then
case $SYSTEM in
ubuntu22.04) ;;
*)
echo "unknown system image: $SYSTEM"
exit 1
;;
esac
fi
echo "System: $SYSTEM"
# =================== Compile Variable Information
# Script Path
RootDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Compile Linux System Directory
BuildLinuxDir=${RootDir}/linux
# Compile Package Management Directory
BuildPackagelDir=${RootDir}/pkg
# Compile the build directory
BuildDir=${RootDir}/tmp
# Release Package directory
ReleaseDir=${RootDir}/release/docker/${PLATFORM_ARCH}
# Release Package name file
ReleaseFileName=omc-r${VERSION}-${SYSTEM}-docker
# =================== file processing
# Apply file handling
app() {
cd ${BuildDir}
# Database scripts within common are rebuild scripts
modeList="std lite"
for v in ${modeList}; do
# . /Located in the temporary directory
path=./usr/local/etc/omc/database/${v}
cp -rf $path/common/* $path/install/
cp -rf $path/common/* $path/upgrade/
rm -rf $path/common
done
}
# =================== compile
docker_build() {
cd ${BuildDir}
# check docker image
if ! docker images | grep -q "mariadb:10.6.21"; then
docker pull mariadb:10.6.21
fi
if [ ! -f $ReleaseFileName/tar/mariadb_10.6.21.tar ]; then
docker save mariadb:10.6.21 -o ${ReleaseFileName}/tar/mariadb_10.6.21.tar
fi
if ! docker images | grep -q "bitnami/keydb:6.3.4"; then
docker pull bitnami/keydb:6.3.4
fi
if [ ! -f $ReleaseFileName/tar/keydb_6.3.4.tar ]; then
docker save bitnami/keydb:6.3.4 -o ${ReleaseFileName}/tar/keydb_6.3.4.tar
fi
# build omc
docker build --platform ${PLATFORM} --build-arg VERSION=${VERSION} -t omc:${VERSION} .
docker save omc:${VERSION} -o ${ReleaseFileName}/tar/omc_${VERSION}.tar
# tar package
tar -czvf ${ReleaseDir}/${ReleaseFileName}.tar ${ReleaseFileName}/
# Generate MD5 file
rm -f omc_md5sum.txt
md5sum ${ReleaseDir}/${ReleaseFileName}.tar >${ReleaseDir}/omc_md5sum.txt
cat ${ReleaseDir}/omc_md5sum.txt
}
# =================== building
echo
echo "building omc..."
rm -rf ${BuildDir} && mkdir -p ${BuildDir}/${ReleaseFileName}
cp -rf ${BuildPackagelDir}/docker/Dockerfile.${SYSTEM}.${PLATFORM_ARCH} ${BuildDir}/Dockerfile
cp -rf ${BuildPackagelDir}/docker/script/* ${BuildDir}/${ReleaseFileName}
cp -rf ${BuildLinuxDir} ${BuildDir}
app
docker_build
# bash build-docker.sh --version 2.2505.2 --platform linux/arm64 --system ubuntu22.04

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# 默认版本值
# Default Version
VERSION="1.0.0"
# usage
usage() {
@@ -12,19 +12,19 @@ usage() {
echo
exit 1
}
# 读取命令行参数
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v) VERSION="$2"; shift 2 ;; # 处理 -v 后面的版本
-v) VERSION="$2"; shift 2 ;; # Processing the version after -v
*) usage ;;
esac
done
# 输出结果
# output result
echo "Version: $VERSION"
# ===================
# =================== Compile System Information
# 包管理器
# package manager
get_manager() {
if command -v rpm &> /dev/null; then
echo "rpm"
@@ -36,11 +36,11 @@ get_manager() {
exit 1
fi
}
# 获取当前系统的包管理器
# Get the package manager of the current system
PACKAGE_MANAGER=$(get_manager)
echo "Package Manager: $PACKAGE_MANAGER"
# 架构
# System Architecture
get_arch() {
ARCH_UNAME=$(uname -m)
case $ARCH_UNAME in
@@ -53,12 +53,12 @@ get_arch() {
;;
esac
}
# 获取当前系统的架构
# Get the architecture of the current system
PACKAGE_ARCH=$(get_arch)
echo "Architecture: $PACKAGE_ARCH"
# 操作系统名称
get_os_name() {
# Operating System Name Version
get_os_name_version() {
if [ -f /etc/os-release ]; then
. /etc/os-release
# 检查 $ID 是否为空
@@ -72,32 +72,34 @@ get_os_name() {
exit 1
fi
}
# 获取当前操作系统名称
OS_NAME=$(get_os_name)
echo "OS: $OS_NAME"
# Get the current operating system name version
OS_NAME=$(get_os_name_version)
echo "OS Version: $OS_NAME"
# ===================
# 编译日期
# =================== Compile Variable Information
# Compile Date
Date=`date +%Y%m%d`
# 脚本所在路径
# Script Path
RootDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# 编译Linux目录
# Compile Linux System Directory
BuildLinuxDir=${RootDir}/linux
# 编译包管理目录
# Compile Package Management Directory
BuildPackagelDir=${RootDir}/pkg
# 编译目录
# Compile the build directory
BuildDir=${RootDir}/tmp
# 发布包目录
# Release Package directory
ReleaseDir=${RootDir}/release/${PACKAGE_MANAGER}/${PACKAGE_ARCH}
# 发布包文件名称
# Release Package name file
ReleaseFileName=omc-r${VERSION}-${Date}-${OS_NAME}-${PACKAGE_ARCH}.${PACKAGE_MANAGER}
# ===================
# 应用文件处理 ./位于临时目录
# =================== file processing
# Apply file handling . /Located in the temporary directory
app() {
# 数据库脚本 common属于重建脚本
# Database scripts within common are rebuild scripts
modeList="std lite"
for v in ${modeList}; do
path=./usr/local/etc/omc/database/${v}
@@ -107,54 +109,56 @@ app() {
done
}
# ===================
# deb包管理器
# =================== system package manager
# deb package manager
deb() {
cd ${BuildDir}
# 替换标签 {version} {arch}
# Replacement Tags {version} {arch}
sed -i "s/{arch}/${PACKAGE_ARCH}/g" ./DEBIAN/control
sed -i "s/{version}/${VERSION}/g" ./DEBIAN/control
sed -i "s/{date}/${Date}/g" ./DEBIAN/control
# 打包deb
# Packaging deb
chmod 755 -R ${BuildDir}
dpkg -b ${BuildDir} ${ReleaseDir}/${ReleaseFileName}
# 生成MD5文件
# Generate MD5 file
rm -f omc_md5sum.txt
md5sum ${ReleaseDir}/${ReleaseFileName} >${ReleaseDir}/omc_md5sum.txt
cat ${ReleaseDir}/omc_md5sum.txt
}
# rpm包管理器
# rpm package manager
rpm() {
cd ${BuildDir}
ARCH_UNAME=$(uname -m)
# 替换标签 {version} {arch} {date}
# Replacement Tags {version} {arch} {date}
sed -i "s/{version}/${VERSION}/g" ./SPECS/omc.spec
sed -i "s/{arch}/${ARCH_UNAME}/g" ./SPECS/omc.spec
sed -i "s/{date}/${Date}/g" ./SPECS/omc.spec
# 打包rpm
# Packaging rpm
chmod 755 -R ${BuildDir}
rpmbuild -bb -D "_topdir ${BuildDir}" ${BuildDir}/SPECS/omc.spec
# 移动rpm包到发布目录
if [[ "$OS_NAME" == kylin* ]]; then # 麒麟系统有ky10标签
# Moving package to the distribution directory
if [[ "$OS_NAME" = "kylinV10" ]]; then # kylin system has ky10 tags
mv ${BuildDir}/RPMS/${ARCH_UNAME}/omc-${VERSION}-${Date}.ky10.${ARCH_UNAME}.rpm ${ReleaseDir}/${ReleaseFileName}
else
mv ${BuildDir}/RPMS/${ARCH_UNAME}/omc-${VERSION}-${Date}.${ARCH_UNAME}.rpm ${ReleaseDir}/${ReleaseFileName}
fi
rm -rf ${BuildDir}/RPMS
# 生成MD5文件
# Generate MD5 file
rm -f omc_md5sum.txt
md5sum ${ReleaseDir}/${ReleaseFileName} >${ReleaseDir}/omc_md5sum.txt
cat ${ReleaseDir}/omc_md5sum.txt
}
# ===================
# =================== building
echo
echo "building omc..."
rm -rf ${BuildDir} && mkdir -p ${BuildDir}
@@ -162,18 +166,16 @@ cp -rf ${BuildPackagelDir}/${PACKAGE_MANAGER}/* ${BuildDir}
if [[ $PACKAGE_MANAGER = "deb" ]]; then
cp -rf ${BuildLinuxDir}/* ${BuildDir}
cd ${BuildDir}
# 应用文件处理
app
# 打包
deb
elif [[ $PACKAGE_MANAGER = "rpm" ]]; then
cp -rf ${BuildLinuxDir}/* ${BuildDir}/BUILD
cd ${BuildDir}/BUILD
# 应用文件处理
app
# 打包
rpm
else
echo "unknown runing: $PACKAGE_MANAGER"
exit 1
fi
# bash build.sh -v 2.2505.2

View File

@@ -0,0 +1,87 @@
## 第一阶段 ====> Nodejs打包编译输出前端资源
FROM node:20-alpine AS build-node
# 前端程序
# COPY ./omc_web /web
COPY./omc_web/src /web/src
COPY./omc_web/public /web/public
COPY./omc_web/index.html /web/index.html
COPY./omc_web/.env.production /web/.env.production
COPY./omc_web/.env.development /web/.env.development
COPY./omc_web/package-lock.json /web/package-lock.json
COPY./omc_web/package.json /web/package.json
COPY./omc_web/tsconfig.json /web/tsconfig.json
COPY./omc_web/tsconfig.node.json /web/tsconfig.node.json
COPY./omc_web/vite.config.ts /web/vite.config.ts
RUN npm config set registry https://registry.npmmirror.com
RUN cd /web && npm install && npm run build
RUN touch /web/dist/config.js && echo 'sessionStorage.clear()' | tee /web/dist/config.js
# 后端程序
# COPY ./omc_api /api
COPY ./omc_api/features /api/features
COPY ./omc_api/lib /api/lib
COPY ./omc_api/src /api/src
COPY ./omc_api/sshsvc /api/sshsvc
COPY ./omc_api/swagger_docs /api/swagger_docs
COPY ./omc_api/go.sum /api/go.sum
COPY ./omc_api/go.mod /api/go.mod
COPY ./omc_api/main.go /api/main.go
# 系统文件
COPY ./omc_api/docker/linux /linux
## 第二阶段 ====> Go打包编译输出后端程序
FROM golang:1.24-alpine AS build-golang
# 从上个阶段复制文件
COPY --from=build-node /web/dist /web
COPY --from=build-node /api /api
COPY --from=build-node /linux /linux
# 安装其他依赖
RUN apk add gcc musl-dev libpcap-dev
# 设置变量
ENV CGO_ENABLED 1
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct
ARG VERSION
RUN cd /api && go mod download
RUN cd /api && go build -o omc -v -ldflags "-s -w \
-X 'be.ems/src/framework/config.Version=$VERSION' \
-X 'be.ems/src/framework/config.BuildTime=$(date)' \
-X 'be.ems/src/framework/config.GoVer=$(go version)'"
RUN cd /api/sshsvc && go build -o sshsvc -v -ldflags "-s -w \
-X 'be.ems/lib/global.Version=${VERSION}' \
-X 'be.ems/lib/global.BuildTime=$(date)' \
-X 'be.ems/lib/global.GoVer=$(go version)'"
## 第三阶段 ====> 构建前后端融合镜像
FROM ubuntu:22.04
# 更新apt并安装必要工具
RUN apt update -y && apt install -y \
sudo systemd libpcap-dev tzdata nginx
# 设置时区和语言环境
ENV LANG="en_US.UTF-8"
ENV TZ="Asia/Shanghai"
WORKDIR /usr/local/etc/omc
COPY --from=build-golang /linux /
COPY --from=build-golang /web /usr/local/etc/omc/web
COPY --from=build-golang /api/omc /usr/local/bin/omc
COPY --from=build-golang /api/sshsvc/sshsvc /usr/local/bin/sshsvc
EXPOSE 80 443 33030
CMD ["/sbin/init"]
# 构建
# docker build --build-arg VERSION=241101 -t omc:2.241101 .
# docker run -it omc:2.241101 sh
# service ssh start && service nginx start && /usr/local/bin/omc --env prod -c /usr/local/etc/omc/omc.yaml

109
pkg/docker/README.md Normal file
View File

@@ -0,0 +1,109 @@
# Docker 编译
编译目录内含 `omc_web``omc_api` 两个项目代码
将后端项目代码中的 `docker/Dockerfile` 文件移动到最外层目录下,`docker/omc`是内部文件挂载的文件资源。
编译目录结构
```text
probject
├── omc_web 目录-前端项目代码
├── omc_api 目录-后端项目代码
└── Dockerfile 文件-Docker编译需要
```
内部文件资源
| 路径 | 说明 |
| --------------------------- | -------------------------- |
| /usr/local/etc/omc/static | 网管静态资源文件路径 |
| /usr/local/etc/omc/upload | 网管上传文件资源路径 |
| /usr/local/etc/omc/omc.yaml | 网管配置文件 |
| /usr/local/etc/omc | 网管与网元之间相关文件 |
| /etc/nginx/cert | 网管前端 nginx 代理证书 |
| /etc/nginx/nginx.conf | 网管前端 nginx 代理配置 |
| /var/log | 网管相关日志输出 |
| /tmp/omc | 存放从网元拉取到本地的文件 |
端口声明
| 端口 | 说明 |
| ----- | ----------------------------- |
| 22 | 网管 容器内部 SSH 服务 |
| 80 | 网管 Nginx HTTP 服务 |
| 443 | 网管 Nginx HTTP2 服务 |
| 33030 | 网管后台 API HTTP 服务 |
| 33443 | 网管后台 API HTTP2 服务 |
| 33033 | 网管信令跟踪 UDP 协议接收服务 |
| 33060 | 网管性能分析监控 metrics 服务 |
## 编译
- `VERSION` 变量是后端程序打包版本号注入
```sh
docker build --build-arg VERSION="241212" -t omc:2.2412.1 .
```
## 部署
- `APPENV` 程序启动环境变量 local、prod -e APPENV="local"
```sh
docker run -d \
--privileged=true \
--restart=always \
-p 8822:22 \
-p 8880:80 \
-p 8884:443 \
-p 8830:33030 \
-p 8833:33033 \
-p 8860:33060 \
-v /home/manager/probject/omc_api/docker/omc:/usr/local/etc/omc \
-v /home/manager/probject/omc_api/docker/omc/logs:/var/log \
-v /home/manager/probject/omc_api/docker/omc/tmp:/tmp/omc \
-v /home/manager/probject/omc_api/docker/omc/nginx/cert:/etc/nginx/cert \
-v /home/manager/probject/omc_api/docker/omc/nginx/nginx.conf:/etc/nginx/nginx.conf \
-e TZ="Asia/Shanghai" \
-e APPENV="prod" \
-m 512M \
--name omc \
omc:2.2412.1
```
## 调试
```sh
docker run -it omc:xxx sh
docker exec -it omc:xxx sh
service ssh start && service nginx start && /usr/local/bin/omc --env prod -c /usr/local/etc/omc/omc.yaml
```
## 镜像导出导入
```sh
docker save bitnami/keydb:6.3.4 -o keydb_6.3.4.tar
docker save mariadb:10.6.21 -o mariadb_10.6.21.tar
docker save omc:xx -o omc_xx.tar
docker load -i keydb_6.3.4.tar
docker load -i mariadb_10.6.21.tar
docker load -i omc_xx.tar
sudo bash omc-docker.sh install
mkdir omc-r2.2412.1-ub22-cloud
tar -czvf omc-r2.2412.1-ub22-cloud.tgz omc-r2.2412.1-ub22-cloud/
tar -xzvf omc-r2.2412.1-ub22-cloud.tgz
scp omc_2.2412.1.tar manager@192.168.9.59:/home/manager/omc-r2.2412.1-ub22-cloud/tar/
```

View File

@@ -0,0 +1,158 @@
#!/bin/bash
OMC_CONTAINER_NAME="omc"
MYSQL_CONTAINER_NAME="omc_mysql"
REDIS_CONTAINER_NAME="omc_redis"
# usage
usage() {
echo "Usage: bash omc-docker.sh [install|uninstall|restart|start|stop]"
exit 1
}
# install
install(){
echo "====================== Install container omc service ====================="
echo "Install mysql and redis service program, default N (Y/N):"
read DB_SERVICE
DB_SERVICE=${DB_SERVICE:-"N"}
echo "Select the image in the tar directory (omc_2.2412.1.tar):"
read OMC_FILE
OMC_FILE=${OMC_FILE:-"omc_2.2412.1.tar"}
echo "Container time zone (Asia/Shanghai):"
read OMC_TZ
OMC_TZ=${OMC_TZ:-"Asia/Shanghai"}
echo "Container service http port (80):"
read OMC_HTTP_PORT
OMC_HTTP_PORT=${OMC_HTTP_PORT:-"80"}
echo "Container service https port (443):"
read OMC_HTTPS_PORT
OMC_HTTPS_PORT=${OMC_HTTPS_PORT:-"443"}
echo "Container name ($OMC_CONTAINER_NAME):"
read OMC_CONTAINER_NAME
OMC_CONTAINER_NAME=${OMC_CONTAINER_NAME:-"omc"}
echo "==> Checking Docker version $OMC_CONTAINER_NAME"
sed -i "s/^OMC_CONTAINER_NAME=.*/OMC_CONTAINER_NAME=\"$OMC_CONTAINER_NAME\"/" ./omc-docker.sh
echo "===================== Install container omc service ====================="
echo "==> Checking Docker version"
if sudo docker -v > /dev/null 2>&1; then
sudo docker -v
else
echo "Docker is not available or sudo privileges are not granted."
exit 1
fi
echo "==> Created service network"
NETWORK="omcnet"
if ! docker network ls --filter name=$NETWORK -q | grep -q .; then
docker network create $NETWORK
echo "Network '$NETWORK' created."
else
echo "Network '$NETWORK' already exists."
fi
echo "==> Install service mysql and redis container"
MYSQL_CONTAINER_NAME="omc_mysql"
REDIS_CONTAINER_NAME="omc_redis"
if [[ "$DB_SERVICE" =~ ^[Yy]$ ]]; then
# MySQL Config
mysql_container=$(docker ps --filter "name=$MYSQL_CONTAINER_NAME" --format "{{.Names}}")
if [[ -z "$mysql_container" ]]; then
echo "MySQL container is not running. Installing MySQL container..."
docker load --input $(pwd)/tar/mysql_8.0.39.tar
MYSQL_IMAGE="mysql:8.0.39"
MYSQL_ROOT_PASSWORD="1000omc@kp!"
SQL_FILE_PATH="$(pwd)/sql/install/omc_db.sql"
MYSQL_DATA=/usr/local/etc/$MYSQL_CONTAINER_NAME/data
mkdir -p $MYSQL_DATA
docker run --privileged=true --restart=always -e TZ="$OMC_TZ" \
-e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
-v $SQL_FILE_PATH:/docker-entrypoint-initdb.d/database.sql \
-v $MYSQL_DATA:/var/lib/mysql \
--network $NETWORK \
--name $MYSQL_CONTAINER_NAME \
-d $MYSQL_IMAGE
else
echo "MySQL container is already running: $mysql_container"
fi
# Redis Config
redis_container=$(docker ps --filter "name=$REDIS_CONTAINER_NAME" --format "{{.Names}}")
if [[ -z "$redis_container" ]]; then
echo "Redis container is not running. Installing Redis container..."
docker load --input $(pwd)/tar/redis_7.2.5.tar
REDIS_IMAGE="redis:7.2.5"
REDIS_PASSWORD="helloearth"
REDIS_DATA=/usr/local/etc/$REDIS_CONTAINER_NAME/data
mkdir -p $REDIS_DATA
docker run --privileged=true --restart=always -e TZ="$OMC_TZ" \
-e REDIS_PASSWORD=$REDIS_PASSWORD \
-v $REDIS_DATA:/data \
--network $NETWORK \
--name $REDIS_CONTAINER_NAME \
-d $REDIS_IMAGE
else
echo "Redis container is already running: $redis_container"
fi
else
echo "You chose not to install MySQL and Redis containers."
fi
echo "==> Loading service omc container"
docker load --input $(pwd)/tar/$OMC_FILE
if [ ! -d /usr/local/etc/omc ]; then
mkdir -p /usr/local/etc/omc
cp -rf ./omc/* /usr/local/etc/omc
fi
OMC_IMAGE=$(echo "$OMC_FILE" | sed -e 's/_/:/' -e 's/\.tar$//')
docker run --privileged=true --restart=always -m 512M \
-v /usr/local/etc/omc:/usr/local/etc/omc \
-v /usr/local/etc/omc/logs:/var/log \
-v /usr/local/etc/omc/tmp:/tmp/omc \
-v /usr/local/etc/omc/nginx/cert:/etc/nginx/cert \
-v /usr/local/etc/omc/nginx/nginx.conf:/etc/nginx/nginx.conf \
-e TZ=$OMC_TZ \
-p $OMC_HTTP_PORT:80 \
-p $OMC_HTTPS_PORT:443 \
--network $NETWORK \
--name $OMC_CONTAINER_NAME \
-d $OMC_IMAGE
echo "Running service $OMC_CONTAINER_NAME container http port $OMC_HTTP_PORT / https port $OMC_HTTPS_PORT"
}
# uninstall
uninstall(){
docker stop $OMC_CONTAINER_NAME && docker rm $OMC_CONTAINER_NAME
docker stop $REDIS_CONTAINER_NAME && docker rm $REDIS_CONTAINER_NAME
docker stop $MYSQL_CONTAINER_NAME && docker rm $MYSQL_CONTAINER_NAME
}
# According to the input parameters, the corresponding method will be selected for execution, and the instructions will be executed without input.
case "$1" in
"install")
install
;;
"uninstall")
uninstall
;;
"restart")
echo "restart container $OMC_CONTAINER_NAME"
docker restart $OMC_CONTAINER_NAME
;;
"start")
echo "start container $OMC_CONTAINER_NAME"
docker start $OMC_CONTAINER_NAME
;;
"stop")
echo "stop container $OMC_CONTAINER_NAME"
docker stop $OMC_CONTAINER_NAME
;;
*)
usage
;;
esac

View File

View File

View File

@@ -0,0 +1 @@
Building a temporary catalog for losing