From 9f01ecaf8003eebc1089782b6795d59b2ee51e43 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 3 Aug 2023 16:49:25 +0800 Subject: [PATCH] fix --- .gitignore | 2 +- fs_package_docker_image.sh | 10 ++++++++++ server/assistant/Dockerfile | 3 ++- server/backend/Dockerfile | 3 ++- server/canteen/Dockerfile | 3 ++- server/data-transfer/Dockerfile | 3 ++- server/home-user-auth/Dockerfile | 3 ++- server/inventory/Dockerfile | 3 ++- server/map-library/Dockerfile | 3 ++- server/orders/Dockerfile | 3 ++- server/pay/Dockerfile | 3 ++- server/product-model/Dockerfile | 3 ++- server/product-template-tag/Dockerfile | 3 ++- server/product-template/Dockerfile | 3 ++- server/product/Dockerfile | 3 ++- server/render/Dockerfile | 3 ++- server/shopping-cart-confirmation/Dockerfile | 3 ++- server/upload/Dockerfile | 3 ++- server/webset/Dockerfile | 3 ++- server/websocket/Dockerfile | 3 ++- 20 files changed, 47 insertions(+), 19 deletions(-) create mode 100755 fs_package_docker_image.sh diff --git a/.gitignore b/.gitignore index 9a4b0c48..2b19cbb7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ *.dll *.so *.dylib - +bin/ # Test binary, built with `go test -c` *.test diff --git a/fs_package_docker_image.sh b/fs_package_docker_image.sh new file mode 100755 index 00000000..04a1ab9e --- /dev/null +++ b/fs_package_docker_image.sh @@ -0,0 +1,10 @@ +#!/bin/bash +name=${1%%\\*} +#进入对应服务目录 +cd server/$name +#构建二进制文件 +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/api-$name-srv ./$name.go +#删除之前旧的镜像 +docker rmi -f api-$name-srv:latest +#打包docker镜像 +docker build -t api-$name-srv:latest . diff --git a/server/assistant/Dockerfile b/server/assistant/Dockerfile index 2a482d6f..55d617cc 100755 --- a/server/assistant/Dockerfile +++ b/server/assistant/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-assistant-srv /www/fusenapi/ +COPY ./bin/api-assistant-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-assistant-srv"] diff --git a/server/backend/Dockerfile b/server/backend/Dockerfile index 65f2a7e5..e30c6bed 100755 --- a/server/backend/Dockerfile +++ b/server/backend/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-backend-srv /www/fusenapi/ +COPY ./bin/api-backend-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-backend-srv"] diff --git a/server/canteen/Dockerfile b/server/canteen/Dockerfile index bebaacaa..a268222d 100755 --- a/server/canteen/Dockerfile +++ b/server/canteen/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-canteen-srv /www/fusenapi/ +COPY ./bin/api-canteen-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-canteen-srv"] diff --git a/server/data-transfer/Dockerfile b/server/data-transfer/Dockerfile index ccb4944b..82090c4b 100755 --- a/server/data-transfer/Dockerfile +++ b/server/data-transfer/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-data-transfer-srv /www/fusenapi/ +COPY ./bin/api-data-transfer-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-data-transfer-srv"] diff --git a/server/home-user-auth/Dockerfile b/server/home-user-auth/Dockerfile index 80b09874..3c7a0da5 100755 --- a/server/home-user-auth/Dockerfile +++ b/server/home-user-auth/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-home-user-auth-srv /www/fusenapi/ +COPY ./bin/api-home-user-auth-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-home-user-auth-srv"] diff --git a/server/inventory/Dockerfile b/server/inventory/Dockerfile index 4a6e1a1a..4fa34360 100755 --- a/server/inventory/Dockerfile +++ b/server/inventory/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-inventory-srv /www/fusenapi/ +COPY ./bin/api-inventory-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-inventory-srv"] diff --git a/server/map-library/Dockerfile b/server/map-library/Dockerfile index 7bec150c..460cbfd5 100755 --- a/server/map-library/Dockerfile +++ b/server/map-library/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-map-library-srv /www/fusenapi/ +COPY ./bin/api-map-library-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-map-library-srv"] diff --git a/server/orders/Dockerfile b/server/orders/Dockerfile index 16130ac0..2a5043d6 100755 --- a/server/orders/Dockerfile +++ b/server/orders/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-order-srv /www/fusenapi/ +COPY ./bin/api-order-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-order-srv"] diff --git a/server/pay/Dockerfile b/server/pay/Dockerfile index dfa78ce5..df5dab5b 100755 --- a/server/pay/Dockerfile +++ b/server/pay/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-pay-srv /www/fusenapi/ +COPY ./bin/api-pay-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-pay-srv"] diff --git a/server/product-model/Dockerfile b/server/product-model/Dockerfile index 6aedc86f..e207b762 100755 --- a/server/product-model/Dockerfile +++ b/server/product-model/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-product-model-srv /www/fusenapi/ +COPY ./bin/api-product-model-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-product-model-srv"] diff --git a/server/product-template-tag/Dockerfile b/server/product-template-tag/Dockerfile index 719821a6..abc15189 100755 --- a/server/product-template-tag/Dockerfile +++ b/server/product-template-tag/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-product-template-tag-srv /www/fusenapi/ +COPY ./bin/api-product-template-tag-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-product-template-tag-srv"] diff --git a/server/product-template/Dockerfile b/server/product-template/Dockerfile index a26db3b3..2012a6d9 100755 --- a/server/product-template/Dockerfile +++ b/server/product-template/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-product-template-srv /www/fusenapi/ +COPY ./bin/api-product-template-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-product-template-srv"] diff --git a/server/product/Dockerfile b/server/product/Dockerfile index 5c066e4c..4ec40fcf 100755 --- a/server/product/Dockerfile +++ b/server/product/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-product-srv /www/fusenapi/ +COPY ./bin/api-product-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-product-srv"] diff --git a/server/render/Dockerfile b/server/render/Dockerfile index b56cc917..b9722b92 100755 --- a/server/render/Dockerfile +++ b/server/render/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-render-srv /www/fusenapi/ +COPY ./bin/api-render-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-render-srv"] diff --git a/server/shopping-cart-confirmation/Dockerfile b/server/shopping-cart-confirmation/Dockerfile index ae93ddea..5aa4c0d5 100755 --- a/server/shopping-cart-confirmation/Dockerfile +++ b/server/shopping-cart-confirmation/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-shopping-cart-confirmation-srv /www/fusenapi/ +COPY ./bin/api-shopping-cart-confirmation-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-shopping-cart-confirmation-srv"] diff --git a/server/upload/Dockerfile b/server/upload/Dockerfile index 84f5d6e4..b3ee358e 100755 --- a/server/upload/Dockerfile +++ b/server/upload/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-upload-srv /www/fusenapi/ +COPY ./bin/api-upload-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-upload-srv"] diff --git a/server/webset/Dockerfile b/server/webset/Dockerfile index c33eaa87..7cbcc7eb 100755 --- a/server/webset/Dockerfile +++ b/server/webset/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-webset-srv /www/fusenapi/ +COPY ./bin/api-webset-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-webset-srv"] diff --git a/server/websocket/Dockerfile b/server/websocket/Dockerfile index ed7ab7c0..e183ac2b 100755 --- a/server/websocket/Dockerfile +++ b/server/websocket/Dockerfile @@ -1,5 +1,6 @@ FROM alpine WORKDIR /www/fusenapi/ -COPY ./api-websocket-srv /www/fusenapi/ +COPY ./bin/api-websocket-srv /www/fusenapi/ +COPY ./etc /www/fusenapi/etc CMD ["/www/fusenapi/api-websocket-srv"]