From 226d71548d13f14a3c774160b1492be65d2a0b9b Mon Sep 17 00:00:00 2001 From: "lin.huang" Date: Thu, 28 Sep 2023 12:08:23 +0800 Subject: [PATCH] change dockerfiles script --- manifest/build-docker.sh | 37 +++++++++++++++++-- manifest/dockerfiles/openim-api/Dockerfile | 25 ++----------- .../dockerfiles/openim-crontask/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-msggateway/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-msgtransfer/Dockerfile | 27 ++++++++++++++ manifest/dockerfiles/openim-push/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-rpc-auth/Dockerfile | 27 ++++++++++++++ .../openim-rpc-conversation/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-rpc-friend/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-rpc-group/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-rpc-msg/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-rpc-third/Dockerfile | 27 ++++++++++++++ .../dockerfiles/openim-rpc-user/Dockerfile | 27 ++++++++++++++ 13 files changed, 335 insertions(+), 24 deletions(-) create mode 100644 manifest/dockerfiles/openim-crontask/Dockerfile create mode 100644 manifest/dockerfiles/openim-msggateway/Dockerfile create mode 100644 manifest/dockerfiles/openim-msgtransfer/Dockerfile create mode 100644 manifest/dockerfiles/openim-push/Dockerfile create mode 100644 manifest/dockerfiles/openim-rpc-auth/Dockerfile create mode 100644 manifest/dockerfiles/openim-rpc-conversation/Dockerfile create mode 100644 manifest/dockerfiles/openim-rpc-friend/Dockerfile create mode 100644 manifest/dockerfiles/openim-rpc-group/Dockerfile create mode 100644 manifest/dockerfiles/openim-rpc-msg/Dockerfile create mode 100644 manifest/dockerfiles/openim-rpc-third/Dockerfile create mode 100644 manifest/dockerfiles/openim-rpc-user/Dockerfile diff --git a/manifest/build-docker.sh b/manifest/build-docker.sh index fd19121ac..648e6370d 100755 --- a/manifest/build-docker.sh +++ b/manifest/build-docker.sh @@ -1,6 +1,37 @@ #!/bin/bash +IMAGEHUB="registry.cn-shenzhen.aliyuncs.com/huanglin_hub" PROJECT=$1 -DOCKER_IMG=${PROJECT} -docker rmi ${DOCKER_IMG} -docker build -f manifest/dockerfiles/${DOCKER_IMG}/Dockerfile -t ${DOCKER_IMG} . \ No newline at end of file +ALLPRO="all" +servers=(openim-api openim-crontask openim-msggateway openim-msgtransfer openim-push openim-rpc-auth openim-rpc-conversation openim-rpc-friend openim-rpc-group openim-rpc-msg openim-rpc-third openim-rpc-user) + + +if [ "$1" != "" ] +then + if [[ "${servers[@]}" =~ "${1}" ]] + then + echo "building ${PROJECT}" + DOCKER_PUSHIMG=${IMAGEHUB}/${PROJECT}:dev + docker rmi ${DOCKER_PUSHIMG} + docker build -f manifest/dockerfiles/${PROJECT}/Dockerfile -t ${DOCKER_PUSHIMG} . + docker push ${DOCKER_PUSHIMG} + elif [[ ! "${servers[@]}" =~ "${1}" ]] + then + if [ ${PROJECT} == ${ALLPRO} ] + then + echo "building allproject" + for element in ${servers[@]} + do + SUB_IMG=${element} + SUB_PUSHIMG=${IMAGEHUB}/${element}:dev + docker rmi ${SUB_PUSHIMG} + docker build -f manifest/dockerfiles/${SUB_IMG}/Dockerfile -t ${SUB_PUSHIMG} . + docker push ${SUB_PUSHIMG} + done + else + echo "输入的项目名称不正确" + fi + fi +else + echo "请传入一个参数" +fi \ No newline at end of file diff --git a/manifest/dockerfiles/openim-api/Dockerfile b/manifest/dockerfiles/openim-api/Dockerfile index 20aed0dc6..c5198d2ad 100644 --- a/manifest/dockerfiles/openim-api/Dockerfile +++ b/manifest/dockerfiles/openim-api/Dockerfile @@ -1,20 +1,3 @@ -# ****************************************************************************** -# 2019 - present Contributed by Apulis Technology (Shenzhen) Co. LTD -# -# This program and the accompanying materials are made available under the -# terms of the MIT License, which is available at -# https://www.opensource.org/licenses/MIT -# -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# SPDX-License-Identifier: MIT -#******************************************************************************/ # build container FROM golang:1.20-alpine3.18 AS builder @@ -22,7 +5,7 @@ ENV GOPROXY https://goproxy.cn,direct ENV GOSUMDB=sum.golang.google.cn ENV GO111MODULE=on -WORKDIR /openim/openim-server +WORKDIR /app RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN apk --no-cache add git pkgconfig build-base ADD go.mod . @@ -39,6 +22,6 @@ RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone \ && apk del tzdata -WORKDIR /openim/openim-server/bin -COPY --from=builder /openim/openim-server/cmd/openim-api/openim-api /openim/openim-server/bin/ -ENTRYPOINT ["/openim/openim-server/bin/openim-api"] +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-api/openim-api /app/bin/ +ENTRYPOINT ["/app/bin/openim-api"] diff --git a/manifest/dockerfiles/openim-crontask/Dockerfile b/manifest/dockerfiles/openim-crontask/Dockerfile new file mode 100644 index 000000000..bba54b2e2 --- /dev/null +++ b/manifest/dockerfiles/openim-crontask/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-crontask/openim-crontask cmd/openim-crontask/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-crontask/openim-crontask /app/bin/ +ENTRYPOINT ["/app/bin/openim-crontask"] diff --git a/manifest/dockerfiles/openim-msggateway/Dockerfile b/manifest/dockerfiles/openim-msggateway/Dockerfile new file mode 100644 index 000000000..582178013 --- /dev/null +++ b/manifest/dockerfiles/openim-msggateway/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-msggateway/openim-msggateway cmd/openim-msggateway/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-msggateway/openim-msggateway /app/bin/ +ENTRYPOINT ["/app/bin/openim-msggateway"] diff --git a/manifest/dockerfiles/openim-msgtransfer/Dockerfile b/manifest/dockerfiles/openim-msgtransfer/Dockerfile new file mode 100644 index 000000000..1e08eb38a --- /dev/null +++ b/manifest/dockerfiles/openim-msgtransfer/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-msgtransfer/openim-msgtransfer cmd/openim-msgtransfer/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-msgtransfer/openim-msgtransfer /app/bin/ +ENTRYPOINT ["/app/bin/openim-msgtransfer"] diff --git a/manifest/dockerfiles/openim-push/Dockerfile b/manifest/dockerfiles/openim-push/Dockerfile new file mode 100644 index 000000000..c1ae3ed84 --- /dev/null +++ b/manifest/dockerfiles/openim-push/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-push/openim-push cmd/openim-push/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-push/openim-push /app/bin/ +ENTRYPOINT ["/app/bin/openim-push"] diff --git a/manifest/dockerfiles/openim-rpc-auth/Dockerfile b/manifest/dockerfiles/openim-rpc-auth/Dockerfile new file mode 100644 index 000000000..5124da7a1 --- /dev/null +++ b/manifest/dockerfiles/openim-rpc-auth/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth cmd/openim-rpc/openim-rpc-auth/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth /app/bin/ +ENTRYPOINT ["/app/bin/openim-rpc-auth"] diff --git a/manifest/dockerfiles/openim-rpc-conversation/Dockerfile b/manifest/dockerfiles/openim-rpc-conversation/Dockerfile new file mode 100644 index 000000000..539d441b9 --- /dev/null +++ b/manifest/dockerfiles/openim-rpc-conversation/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation cmd/openim-rpc/openim-rpc-conversation/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation /app/bin/ +ENTRYPOINT ["/app/bin/openim-rpc-conversation"] diff --git a/manifest/dockerfiles/openim-rpc-friend/Dockerfile b/manifest/dockerfiles/openim-rpc-friend/Dockerfile new file mode 100644 index 000000000..9927c1d30 --- /dev/null +++ b/manifest/dockerfiles/openim-rpc-friend/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend cmd/openim-rpc/openim-rpc-friend/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend /app/bin/ +ENTRYPOINT ["/app/bin/openim-rpc-friend"] diff --git a/manifest/dockerfiles/openim-rpc-group/Dockerfile b/manifest/dockerfiles/openim-rpc-group/Dockerfile new file mode 100644 index 000000000..754151156 --- /dev/null +++ b/manifest/dockerfiles/openim-rpc-group/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-rpc/openim-rpc-group/openim-rpc-group cmd/openim-rpc/openim-rpc-group/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-rpc/openim-rpc-group/openim-rpc-group /app/bin/ +ENTRYPOINT ["/app/bin/openim-rpc-group"] diff --git a/manifest/dockerfiles/openim-rpc-msg/Dockerfile b/manifest/dockerfiles/openim-rpc-msg/Dockerfile new file mode 100644 index 000000000..0f942ba8e --- /dev/null +++ b/manifest/dockerfiles/openim-rpc-msg/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg cmd/openim-rpc/openim-rpc-msg/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg /app/bin/ +ENTRYPOINT ["/app/bin/openim-rpc-msg"] diff --git a/manifest/dockerfiles/openim-rpc-third/Dockerfile b/manifest/dockerfiles/openim-rpc-third/Dockerfile new file mode 100644 index 000000000..a1391c0c3 --- /dev/null +++ b/manifest/dockerfiles/openim-rpc-third/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-rpc/openim-rpc-third/openim-rpc-third cmd/openim-rpc/openim-rpc-third/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-rpc/openim-rpc-third/openim-rpc-third /app/bin/ +ENTRYPOINT ["/app/bin/openim-rpc-third"] diff --git a/manifest/dockerfiles/openim-rpc-user/Dockerfile b/manifest/dockerfiles/openim-rpc-user/Dockerfile new file mode 100644 index 000000000..b45b4aa2f --- /dev/null +++ b/manifest/dockerfiles/openim-rpc-user/Dockerfile @@ -0,0 +1,27 @@ + +# build container +FROM golang:1.20-alpine3.18 AS builder +ENV GOPROXY https://goproxy.cn,direct +ENV GOSUMDB=sum.golang.google.cn +ENV GO111MODULE=on + +WORKDIR /app +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add git pkgconfig build-base +ADD go.mod . +ADD go.sum . +RUN go mod download +ADD . . +RUN go build -o cmd/openim-rpc/openim-rpc-user/openim-rpc-user cmd/openim-rpc/openim-rpc-user/main.go + +# archive container +FROM alpine:3.18 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk --no-cache add ca-certificates libdrm +RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone \ + && apk del tzdata + +WORKDIR /app/bin +COPY --from=builder /app/cmd/openim-rpc/openim-rpc-user/openim-rpc-user /app/bin/ +ENTRYPOINT ["/app/bin/openim-rpc-user"]