feat: docker编译
This commit is contained in:
65
Dockerfile
Normal file
65
Dockerfile
Normal file
@@ -0,0 +1,65 @@
|
||||
## 第一阶段 ====> Nodejs打包编译输出前端资源
|
||||
FROM node:18-alpine AS buildNode
|
||||
|
||||
ENV FRONTEND_DIR = "/jenkins/.jenkins/workspace/ems_frontend_vue3"
|
||||
|
||||
## 工作目录存放程序源码
|
||||
WORKDIR /frontend
|
||||
|
||||
## 复制实际需要的文件到工作目录
|
||||
COPY ${FRONTEND_DIR} ./
|
||||
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
RUN npm install && npm run build
|
||||
|
||||
## 第二阶段 ====> GO打包编译输出后端程序
|
||||
FROM golang:alpine AS buildGo
|
||||
|
||||
ARG VERSION
|
||||
|
||||
ENV BACKEND_DIR = "/jenkins/.jenkins/workspace/ems_backend"
|
||||
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOOS linux
|
||||
ENV GOPROXY https://goproxy.cn,direct
|
||||
|
||||
WORKDIR /backend
|
||||
|
||||
## 复制实际需要的文件到工作目录
|
||||
COPY ${BACKEND_DIR}/docker ./docker
|
||||
COPY ${BACKEND_DIR}/restagent/config ./restagent/config
|
||||
COPY ${BACKEND_DIR}/restagent/etc ./restagent/etc
|
||||
COPY ${BACKEND_DIR}/restagent/restagent.go ./restagent/restagent.go
|
||||
COPY ${BACKEND_DIR}/features ./features
|
||||
COPY ${BACKEND_DIR}/lib ./lib
|
||||
COPY ${BACKEND_DIR}/src ./src
|
||||
COPY ${BACKEND_DIR}/go.sum ./
|
||||
COPY ${BACKEND_DIR}/go.mod ./
|
||||
|
||||
RUN cd /backend && go mod download
|
||||
RUN cd /backend/restagent && go build -o omc -v -ldflags "-X 'ems.agt/lib/global.Version=${VERSION}' -X 'ems.agt/lib/global.BuildTime=`date`' -X 'ems.agt/lib/global.GoVer=`go version`'"
|
||||
|
||||
## 第三阶段 ====> 构建前后端融合镜像
|
||||
FROM alpine
|
||||
|
||||
## 安装时区工具
|
||||
RUN apk add --no-cache tzdata nginx openssh \
|
||||
&& ssh-keygen -A \
|
||||
&& adduser -D sshuser \
|
||||
&& echo 'sshuser:password' | chpasswd \
|
||||
&& mkdir /home/sshuser/.ssh \
|
||||
&& chmod 700 /home/sshuser/.ssh
|
||||
|
||||
# 设置时区和语言环境
|
||||
ENV TZ="Asia/Shanghai"
|
||||
ENV LANG="en_US.UTF-8"
|
||||
|
||||
WORKDIR /usr/local/omc
|
||||
COPY --from=buildNode /frontend/dist /usr/local/omc/bin/frontend
|
||||
COPY --from=buildGo /backend/restagent/omc /usr/local/omc/bin/backend
|
||||
COPY --from=buildGo /backend/docker/config.yaml /usr/local/omc/etc/config.yaml
|
||||
COPY --from=buildGo /backend/docker/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
EXPOSE 3030 80 22
|
||||
|
||||
CMD ["/usr/sbin/sshd", "-D", ";", "nginx", "-g", "daemon off;", ";", "/usr/local/omc/bin/backend", "--env", "prod", "-c", "/usr/local/omc/etc/config.yaml"]
|
||||
158
docker/config.yaml
Normal file
158
docker/config.yaml
Normal file
@@ -0,0 +1,158 @@
|
||||
# file: log file name
|
||||
# level: /trace/debug/info/warn/error/fatal, default: debug
|
||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
logger:
|
||||
file: /usr/local/omc/log/restagent.log
|
||||
level: debug
|
||||
duration: 24
|
||||
count: 90
|
||||
|
||||
# rest agent listen ipv4/v6 and port, support multiple routines
|
||||
# ip: 0.0.0.0 or ::0, support IPv4/v6
|
||||
# clientAuthType: 0:NoClientCert (default), 1:RequestClientCert, 2:RequireAnyClientCert,
|
||||
# 3:VerifyClientCertIfGiven, 4:RequireAndVerifyClientCerts
|
||||
rest:
|
||||
- ipv4: 0.0.0.0
|
||||
ipv6:
|
||||
port: 3030
|
||||
|
||||
webServer:
|
||||
enabled: false
|
||||
rootDir: /usr/local/omc/htdocs/front
|
||||
listen:
|
||||
- addr: :80
|
||||
schema: http
|
||||
- addr: :443
|
||||
schema: https
|
||||
clientAuthType: 0
|
||||
caFile: /usr/local/omc/etc/certs/omc-ca.crt
|
||||
certFile: /usr/local/omc/etc/certs/omc-server.crt
|
||||
keyFile: /usr/local/omc/etc/certs/omc-server.key
|
||||
|
||||
database:
|
||||
type: mysql
|
||||
user: root
|
||||
password: "root@1234"
|
||||
host: "192.168.5.57"
|
||||
port: 3306
|
||||
name: omc_db
|
||||
backup: /usr/local/omc/database
|
||||
|
||||
# Redis data cache
|
||||
redis:
|
||||
dataSource:
|
||||
# OMC system db
|
||||
default:
|
||||
port: 6379 # Redis port
|
||||
host: "192.168.5.57" # Redis host
|
||||
password: ""
|
||||
db: 10 # Redis db_num
|
||||
# UDM sub/auth db
|
||||
udmuser:
|
||||
port: 6379 # Redis port
|
||||
host: "192.168.5.57"
|
||||
password: ""
|
||||
db: 0 # Redis db_num
|
||||
# used to specify the default data source for multiple data resourece
|
||||
defaultDataSourceName: "default"
|
||||
|
||||
# upfHeaderLength: spare upf buffer, must destroy
|
||||
mml:
|
||||
port: 4100
|
||||
sleep: 200
|
||||
user: admin
|
||||
password: admin
|
||||
mmlHome: ./mmlhome
|
||||
upload: /home/agtuser
|
||||
upfHeaderLength: 2335
|
||||
|
||||
# NE config
|
||||
ne:
|
||||
user: agtuser
|
||||
etcdir: /usr/local/etc
|
||||
bindir: /usr/local/bin
|
||||
omcdir: /usr/local/omc
|
||||
scpdir: /tmp
|
||||
licensedir: /usr/local/etc/{neType}/license
|
||||
# backup etc list of IMS, does not contain spaces
|
||||
etcListIMS: "{*.yaml,mmtel,vars.cfg}"
|
||||
|
||||
# chk2ne: true/false, if put OmcNeConfig parameters to NE
|
||||
omc:
|
||||
uriPrefix: "/omc/rest"
|
||||
neType: OMC
|
||||
neId: 001
|
||||
rmUID: 4400HX101
|
||||
neName: OMC
|
||||
province: GD
|
||||
vendor: ""
|
||||
dn: 4600
|
||||
chk2ne: false
|
||||
sn: "-"
|
||||
checksign: false
|
||||
rootDir: /usr/local/omc
|
||||
binDir: /usr/local/omc/bin
|
||||
backup: /usr/local/omc/backup
|
||||
upload: /usr/local/omc/upload
|
||||
frontUpload: /usr/local/omc/htdocs/front/upload
|
||||
frontTraceDir: /usr/local/omc/htdocs/front/trace
|
||||
software: /usr/local/omc/software
|
||||
license: /usr/local/omc/license
|
||||
gtpUri: gtp:192.168.2.119:2152
|
||||
checkContentType: false
|
||||
testMode: false
|
||||
rbacMode: true
|
||||
runDir: /usr/local/omc/run
|
||||
|
||||
# Alarm module setting
|
||||
# Forward interface:
|
||||
# email/sms
|
||||
alarm:
|
||||
forwardAlarm: true
|
||||
email:
|
||||
smtp: smtp.xxx.com
|
||||
port: 25
|
||||
user: smtpuser@xxx.com
|
||||
password: xxxxxx
|
||||
# TLS skip verify: true/false
|
||||
tlsSkipVerify: true
|
||||
sms:
|
||||
apiURL: http://smsc.xxx.com
|
||||
accessKeyID: xxx
|
||||
accessKeySecret: xxx
|
||||
signName: XXX SMSC
|
||||
templateCode: 1000
|
||||
|
||||
# User authorized information
|
||||
# crypt: mysql/md5/bcrypt
|
||||
# token: true/false to check accessToken
|
||||
# expires for session, unit: second
|
||||
# Support single/multiple session of user
|
||||
#
|
||||
auth:
|
||||
crypt: bcrypt
|
||||
token: true
|
||||
expires: 1800
|
||||
session: multiple
|
||||
publicKey: /usr/local/omc/etc/certs/omc
|
||||
privateKey: /usr/local/omc/etc/certs/omc
|
||||
|
||||
# Parameter for limit number
|
||||
# rmuid_maxnum: the max number of rmUID, default: 50
|
||||
# alarmid_maxnum: the max number of AlarmID, default: 50
|
||||
# pmid_maxnum: the max number of pmID, default: 50
|
||||
# subid_maxnum: the max number of subscription ID, default: 20
|
||||
# uri_maxlen: the max length of uri, default: 8192
|
||||
# rmuid_regexp: regexp pattern of rmUID
|
||||
params:
|
||||
rmuidmaxnum: 50
|
||||
alarmidmaxnum: 50
|
||||
pmidmaxnum: 50
|
||||
subidmaxnum: 20
|
||||
urimaxlen: 2100000
|
||||
rmuidregexp: "[0-9]{4}[A-Z]{2}[A-Z]{2}[0-9A-Z]{1}[0-9A-Z]{3}[0-9A-Z]{1,16}"
|
||||
|
||||
testConfig:
|
||||
enabled: false
|
||||
file: /usr/local/omc/etc/testconfig.yaml
|
||||
36
docker/nginx.conf
Normal file
36
docker/nginx.conf
Normal file
@@ -0,0 +1,36 @@
|
||||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
location /omc-api/ {
|
||||
proxy_pass http://127.0.0.1:3030/;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
}
|
||||
|
||||
location / {
|
||||
root /usr/local/omc/bin/frontend;
|
||||
|
||||
try_files $uri $uri/ /index.html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user