diff --git a/.github/workflows/docker-buildx.yml b/.github/workflows/docker-buildx.yml index 6ca47e924..9734e05e2 100644 --- a/.github/workflows/docker-buildx.yml +++ b/.github/workflows/docker-buildx.yml @@ -317,4 +317,69 @@ jobs: tags: ${{ steps.meta13.outputs.tags }} labels: ${{ steps.meta13.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + build-tools-ghcr: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + install: true + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker openim-web + id: meta1 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openim-web + + - name: Build and push Docker image for openim-web + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/images/openim-tools/openim-web/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta1.outputs.tags }} + labels: ${{ steps.meta1.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Extract metadata (tags, labels) for Docker openim-web + id: meta2 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/component + + - name: Build and push Docker image for component + uses: docker/build-push-action@v4 + with: + context: . + file: ./build/images/openim-tools/component/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file diff --git a/build/goreleaser.yaml b/build/goreleaser.yaml index d16e25f65..173ff1368 100644 --- a/build/goreleaser.yaml +++ b/build/goreleaser.yaml @@ -291,6 +291,24 @@ builds: - "6" - "7" + - binary: openim-web + id: openim-web + main: ./tools/openim-web/openim-web.go + goos: + - darwin + - windows + - linux + goarch: + - s390x + - mips64 + - mips64le + - amd64 + - ppc64le + - arm64 + goarm: + - "6" + - "7" + - binary: component id: component main: ./tools/component/component.go diff --git a/build/images/openim-api/Dockerfile b/build/images/openim-api/Dockerfile index 878689e47..2ffd221d0 100644 --- a/build/images/openim-api/Dockerfile +++ b/build/images/openim-api/Dockerfile @@ -49,4 +49,4 @@ EXPOSE $PORT RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/openim-api /usr/bin/openim-api -CMD ["bash", "-c", "openim-api -c $CONFIG --port $PORT"] +ENTRYPOINT ["bash", "-c", "openim-api -c $CONFIG --port $PORT"] diff --git a/build/images/openim-tools/component/Dockerfile b/build/images/openim-tools/component/Dockerfile new file mode 100644 index 000000000..048b02f70 --- /dev/null +++ b/build/images/openim-tools/component/Dockerfile @@ -0,0 +1,49 @@ +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + +# OpenIM base image: https://github.com/openim-sigs/openim-base-image + +# Set go mod installation source and proxy + +FROM golang:1.20 AS builder + +ARG GO111MODULE=on +ARG GOPROXY=https://goproxy.cn,direct + +WORKDIR /openim/openim-server + +ENV GO111MODULE=$GO111MODULE +ENV GOPROXY=$GOPROXY + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +RUN make clean +RUN make build BINS=component + +# FROM ghcr.io/openim-sigs/openim-bash-image:latest +FROM ghcr.io/openim-sigs/openim-bash-image:latest + +WORKDIR /openim/openim-server + +COPY --from=builder /openim/openim-server/_output/bin/tools /openim/openim-server/_output/bin/tools/ +COPY --from=builder /openim/openim-server/config /openim/openim-server/config + +ENV CONFIG=/openim/openim-server/config + +RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/component /usr/bin/component + +ENTRYPOINT ["bash", "-c", "component -c $CONFIG"]