Skip to content

Commit

Permalink
fix: add admin file (#179)
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>
  • Loading branch information
cubxxw authored Sep 4, 2023
1 parent f604c62 commit 2b5d574
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ifeq ($(origin GOBIN), undefined)
GOBIN := $(GOPATH)/bin
endif

COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/*))
COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/*/*))
BINS ?= $(foreach cmd,${COMMANDS},$(notdir ${cmd}))

ifeq (${COMMANDS},)
Expand Down Expand Up @@ -185,15 +185,9 @@ go.build.%:
@echo "=====> BIN_DIR=$(BIN_DIR)"
@echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS)_$(ARCH)"
@mkdir -p $(BIN_DIR)/platforms/$(OS)/$(ARCH)
@if [ "$(COMMAND)" = "rpc" ] || [ "$(COMMAND)" = "api" ]; then \
for d in $(wildcard $(ROOT_DIR)/cmd/$(COMMAND)/*/); do \
cd $$d && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$$(basename $$d)$(GO_OUT_EXT) .; \
done; \
else \
@CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_PACKAGE)/cmd/$(COMMAND)/main.go; \
fi
@cd $(ROOT_DIR)/cmd/*/$(COMMAND) && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) .


## build-multiarch: Build binaries for multiple platforms.
.PHONY: build-multiarch
Expand Down
10 changes: 5 additions & 5 deletions build/docker/api-admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ RUN go mod download
COPY . .

RUN make clean
RUN make build BINS=api

RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/chat-api
RUN make build BINS=admin-api

FROM ghcr.io/openim-sigs/openim-bash-image:latest

Expand All @@ -47,6 +45,8 @@ COPY --from=builder ${OPENIM_CHAT_BINDIR}/platforms /openim/openim-chat/_output/
COPY --from=builder ${OPENIM_CHAT_CONFIG_NAME} /openim/openim-chat/config/config.yaml

ENV PORT=10009
EXPOSE 10009

RUN mv ${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/admin-api /usr/bin/admin-api

EXPOSE ${PORT}
CMD ["bash","-c","${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/admin-api --port ${PORT} --config_folder_path ${OPENIM_CHAT_CONFIG_NAME}"]
ENTRYPOINT ["bash", "-c", "admin-api --port $PORT -c $OPENIM_CHAT_CONFIG_NAME"]
10 changes: 5 additions & 5 deletions build/docker/api-chat/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ RUN go mod download
COPY . .

RUN make clean
RUN make build BINS=api

RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/admin-api
RUN make build BINS=chat-api

FROM ghcr.io/openim-sigs/openim-bash-image:latest

Expand All @@ -44,6 +42,8 @@ COPY --from=builder ${OPENIM_CHAT_BINDIR}/platforms /openim/openim-chat/_output/
COPY --from=builder ${OPENIM_CHAT_CONFIG_NAME} /openim/openim-chat/config/config.yaml

ENV PORT=10008
EXPOSE 10008

RUN mv ${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/chat-api /usr/bin/chat-api

EXPOSE ${PORT}
CMD ["bash", "-c","${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/chat-api --port ${PORT} --config_folder_path ${OPENIM_CHAT_CONFIG_NAME}"]
ENTRYPOINT ["bash", "-c", "chat-api --port $PORT -c $OPENIM_CHAT_CONFIG_NAME"]
13 changes: 8 additions & 5 deletions build/docker/rpc-admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ RUN go mod download
COPY . .

RUN make clean
RUN make build BINS=rpc

RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/chat-rpc
RUN make build BINS=admin-rpc

FROM ghcr.io/openim-sigs/openim-bash-image:latest

Expand All @@ -43,7 +41,12 @@ WORKDIR ${CHAT_WORKDIR}
COPY --from=builder ${OPENIM_CHAT_BINDIR}/platforms /openim/openim-chat/_output/bin/platforms
COPY --from=builder ${OPENIM_CHAT_CONFIG_NAME} /openim/openim-chat/config/config.yaml

ENV PORT=30200

EXPOSE ${PORT}
CMD ["bash", "-c", "${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/admin-rpc --port ${PORT} --config_folder_path ${OPENIM_CHAT_CONFIG_NAME}"]

ENV PORT=30200
EXPOSE 30200

RUN mv ${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/admin-rpc /usr/bin/admin-rpc

ENTRYPOINT ["bash", "-c", "admin-rpc --port $PORT -c $OPENIM_CHAT_CONFIG_NAME"]
8 changes: 5 additions & 3 deletions build/docker/rpc-chat/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN go mod download
COPY . .

RUN make clean
RUN make build BINS=rpc
RUN make build BINS=chat-rpc

RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/admin-rpc

Expand All @@ -44,6 +44,8 @@ COPY --from=builder ${OPENIM_CHAT_BINDIR}/platforms /openim/openim-chat/_output/
COPY --from=builder ${OPENIM_CHAT_CONFIG_NAME} /openim/openim-chat/config/config.yaml

ENV PORT=30300
EXPOSE 30300

EXPOSE ${PORT}
CMD ["bash", "-c","${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/chat-rpc --port ${PORT} --config_folder_path ${OPENIM_CHAT_CONFIG_NAME}"]
RUN mv ${OPENIM_CHAT_BINDIR}/platforms/$(get_os)/$(get_arch)/chat-rpc /usr/bin/chat-rpc

ENTRYPOINT ["bash", "-c", "chat-rpc --port $PORT -c $OPENIM_CHAT_CONFIG_NAME"]

0 comments on commit 2b5d574

Please sign in to comment.