1
0

feat: docker编译

This commit is contained in:
TsMask
2024-01-11 15:30:10 +08:00
parent 02a45da0be
commit bb6a929720
10 changed files with 34 additions and 6 deletions

View File

@@ -39,7 +39,7 @@ RUN cd /backend/restagent && go build -o backend -v -ldflags "-X 'ems.agt/lib/gl
## 镜像基座 ====> 编译输出前后端可运行的程序
FROM alpine
## 安装时区工具
## 安装工具
RUN apk add --no-cache tzdata nginx openssh \
&& ssh-keygen -A \
&& adduser -D omc \
@@ -52,13 +52,19 @@ 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/config.yaml /usr/local/omc/etc/config.yaml
COPY ./backend/docker/nginx.conf /etc/nginx/nginx.conf
# 其余文件
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/config.yaml"]
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
View 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

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB