feat: docker编译
This commit is contained in:
70
docker/Dockerfile
Normal file
70
docker/Dockerfile
Normal file
@@ -0,0 +1,70 @@
|
||||
## 第一阶段 ====> Nodejs打包编译输出前端资源
|
||||
FROM node:18-alpine AS build-nodejs
|
||||
|
||||
## 工作目录存放程序源码
|
||||
WORKDIR /frontend
|
||||
|
||||
## 复制实际需要的文件到工作目录
|
||||
COPY ./frontend ./
|
||||
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
RUN cd /frontend && npm install && npm run build
|
||||
|
||||
## 第二阶段 ====> GO打包编译输出后端程序
|
||||
FROM golang:alpine AS build-go
|
||||
|
||||
ARG VERSION
|
||||
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOOS linux
|
||||
ENV GOPROXY https://goproxy.cn,direct
|
||||
|
||||
WORKDIR /backend
|
||||
|
||||
## 复制实际需要的文件到工作目录
|
||||
COPY ./backend/docker ./docker
|
||||
COPY ./backend/restagent/config ./restagent/config
|
||||
COPY ./backend/restagent/etc ./restagent/etc
|
||||
COPY ./backend/restagent/restagent.go ./restagent/restagent.go
|
||||
COPY ./backend/features ./features
|
||||
COPY ./backend/lib ./lib
|
||||
COPY ./backend/src ./src
|
||||
COPY ./backend/go.sum ./
|
||||
COPY ./backend/go.mod ./
|
||||
|
||||
RUN cd /backend && go mod download
|
||||
RUN cd /backend/restagent && go build -o backend -v -ldflags "-X 'ems.agt/lib/global.Version=${VERSION}' -X 'ems.agt/lib/global.BuildTime=`date`' -X 'ems.agt/lib/global.GoVer=`go version`'"
|
||||
# RUN cd /backend/restagent && go build -ldflags="-s -w" -o backend
|
||||
|
||||
## 镜像基座 ====> 编译输出前后端可运行的程序
|
||||
FROM alpine
|
||||
|
||||
## 安装工具
|
||||
RUN apk add --no-cache tzdata nginx openssh \
|
||||
&& ssh-keygen -A \
|
||||
&& adduser -D omc \
|
||||
&& echo 'omc:password' | chpasswd \
|
||||
&& mkdir /home/omc/.ssh \
|
||||
&& chmod 700 /home/omc/.ssh
|
||||
|
||||
# 设置时区和语言环境
|
||||
ENV TZ="Asia/Shanghai"
|
||||
ENV LANG="en_US.UTF-8"
|
||||
|
||||
WORKDIR /usr/local/omc
|
||||
|
||||
# 前端编译
|
||||
COPY --from=build-nodejs /frontend/dist /usr/local/omc/bin/frontend
|
||||
RUN touch /usr/local/omc/bin/frontend/config.js
|
||||
|
||||
# 后端编译
|
||||
COPY --from=build-go /backend/restagent/backend /usr/local/omc/bin/backend
|
||||
|
||||
# 其余文件
|
||||
COPY ./backend/docker/omc/etc/omc.yaml /usr/local/omc/etc/omc.yaml
|
||||
COPY ./backend/docker/omc/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY ./backend/docker/omc/static /usr/local/omc/static
|
||||
|
||||
EXPOSE 22 80 3030
|
||||
|
||||
CMD ["/bin/sh", "-c", "/usr/sbin/sshd && nginx && /usr/local/omc/bin/backend --env prod -c /usr/local/omc/etc/omc.yaml"]
|
||||
22
docker/README.md
Normal file
22
docker/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## Docker 编译
|
||||
|
||||
docker build --build-arg VERSION=2.240111 -t omc:2.240111 .
|
||||
|
||||
docker run -it omc:2.240111 sh
|
||||
|
||||
-v /var/log/omc
|
||||
-v /etc/nginx
|
||||
-v /usr/local/omc/etc
|
||||
-v /usr/local/omc/static
|
||||
-v /usr/local/omc/upload
|
||||
|
||||
docker run -d \
|
||||
--privileged=true \
|
||||
--restart=always \
|
||||
-p 3222:22 \
|
||||
-p 3280:80 \
|
||||
-p 3230:3030 \
|
||||
-e TZ="Asia/Shanghai" \
|
||||
-m 512M \
|
||||
--name omc_001 \
|
||||
omc:2.240111
|
||||
BIN
docker/omc/static/helpDoc/en_doc.pdf
Normal file
BIN
docker/omc/static/helpDoc/en_doc.pdf
Normal file
Binary file not shown.
BIN
docker/omc/static/helpDoc/zh_doc.pdf
Normal file
BIN
docker/omc/static/helpDoc/zh_doc.pdf
Normal file
Binary file not shown.
BIN
docker/omc/static/logo/en_brand.png
Normal file
BIN
docker/omc/static/logo/en_brand.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
BIN
docker/omc/static/logo/en_icon.png
Normal file
BIN
docker/omc/static/logo/en_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
docker/omc/static/logo/zh_brand.png
Normal file
BIN
docker/omc/static/logo/zh_brand.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
docker/omc/static/logo/zh_icon.png
Normal file
BIN
docker/omc/static/logo/zh_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Reference in New Issue
Block a user