Skip to content

Commit

Permalink
feat: add images address
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>
  • Loading branch information
cubxxw committed Jul 27, 2023
1 parent 93fe78f commit 648076a
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 47 deletions.
31 changes: 31 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Ignore files and directories starting with a dot

# Ignore specific files
.dockerignore

# Ignore build artifacts
_output/
logs/

# Ignore non-essential documentation
README.md
README-zh_CN.md
CONTRIBUTING.md
CHANGELOG/
# LICENSE

# Ignore testing and linting configuration
.golangci.yml

# Ignore deployment-related files
docker-compose.yaml
deployments/

# Ignore assets
assets/

# Ignore components
components/

# Ignore tools and scripts
.github/
35 changes: 0 additions & 35 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,38 +101,3 @@ jobs:
tags: ${{ steps.meta3.outputs.tags }}
labels: ${{ steps.meta3.outputs.labels }}

# name: OpenIM Build Docker Images
# on:
# push:
# tags:
# - v*
# jobs:
# build:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# bin:
# - openim-chat
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Setup Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Docker metadata
# id: metadata
# uses: docker/metadata-action@v4
# with:
# images: ghcr.io/${{ github.repository_owner }}/openim-${{ matrix.bin }}
# - name: Build and release Docker images
# uses: docker/build-push-action@v3
# with:
# platforms: linux/386,linux/amd64,linux/arm64/v8
# target: ${{ matrix.bin }}
# tags: ${{ steps.metadata.outputs.tags }}
# push: true
35 changes: 35 additions & 0 deletions .github/workflows/docker-buildx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: OpenIM Build Docker Images
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
bin:
- openim-chat
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/openim-${{ matrix.bin }}
- name: Build and release Docker images
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64/v8
target: ${{ matrix.bin }}
tags: ${{ steps.metadata.outputs.tags }}
push: true
41 changes: 31 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
# 使用官方 Golang 镜像作为构建环境
FROM golang:1.20 AS builder

WORKDIR /app

ARG GOARCH
ARG GOOS

ENV GOPROXY=https://goproxy.cn

# 复制 go mod 和 go sum 文件然后下载依赖
COPY go.mod go.sum ./
RUN go mod download

# 复制源码文件到镜像中
COPY . .

# 编译源码
RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o open_im_admin ./cmd/rpc/admin
RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o open_im_admin_api ./cmd/api/admin_api
RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o open_im_chat ./cmd/rpc/chat
RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o open_im_chat_api ./cmd/api/chat_api

# 使用 scratch 创建一个新的镜像层,复制构建好的二进制文件进去
FROM ubuntu

# 设置固定的项目路径
ENV WORKDIR /chat
ENV CMDDIR $WORKDIR/scripts

ENV CONFIG_NAME $WORKDIR/config/config.yaml

# 将可执行文件复制到目标目录
ADD ./bin/open_im_admin $WORKDIR/bin/open_im_admin
ADD ./bin/open_im_admin_api $WORKDIR/bin/open_im_admin_api
ADD ./bin/open_im_chat $WORKDIR/bin/open_im_chat
ADD ./bin/open_im_chat_api $WORKDIR/bin/open_im_chat_api
ADD ./scripts $WORKDIR/scripts
ADD ./config/config.yaml $WORKDIR/config/config.yaml
COPY --from=builder /app/open_im_admin $WORKDIR/bin/open_im_admin
COPY --from=builder /app/open_im_admin_api $WORKDIR/bin/open_im_admin_api
COPY --from=builder /app/open_im_chat $WORKDIR/bin/open_im_chat
COPY --from=builder /app/open_im_chat_api $WORKDIR/bin/open_im_chat_api
COPY ./scripts $WORKDIR/scripts
COPY ./config/config.yaml $WORKDIR/config/config.yaml

# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs && \
Expand All @@ -23,4 +44,4 @@ RUN apt-get -qq update \
VOLUME ["/chat/logs","/chat/config","/chat/scripts"]

WORKDIR $CMDDIR
CMD ["./docker_start_all.sh"]
CMD ["./docker_start_all.sh"]
26 changes: 26 additions & 0 deletions Dockerfile_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu

# 设置固定的项目路径
ENV WORKDIR /chat
ENV CMDDIR $WORKDIR/scripts

ENV CONFIG_NAME $WORKDIR/config/config.yaml

# 将可执行文件复制到目标目录
ADD ./bin/open_im_admin $WORKDIR/bin/open_im_admin
ADD ./bin/open_im_admin_api $WORKDIR/bin/open_im_admin_api
ADD ./bin/open_im_chat $WORKDIR/bin/open_im_chat
ADD ./bin/open_im_chat_api $WORKDIR/bin/open_im_chat_api
ADD ./scripts $WORKDIR/scripts
ADD ./config/config.yaml $WORKDIR/config/config.yaml

# 创建用于挂载的几个目录,添加可执行权限
RUN mkdir $WORKDIR/logs && \
chmod +x $WORKDIR/bin/open_im_admin $WORKDIR/bin/open_im_chat $WORKDIR/bin/open_im_admin_api $WORKDIR/bin/open_im_chat_api
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl

VOLUME ["/chat/logs","/chat/config","/chat/scripts"]

WORKDIR $CMDDIR
CMD ["./docker_start_all.sh"]
4 changes: 2 additions & 2 deletions docs/conversions/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ When pulling OpenIM's Docker images, you can choose the most suitable source bas

```
bashCopy code
docker pull ghcr.io/openim/openim-server:latest
docker pull ghcr.io/openimsdk/openim-server:latest
```

- Pull from Alibaba Cloud:
Expand All @@ -47,7 +47,7 @@ When pulling OpenIM's Docker images, you can choose the most suitable source bas

```
bashCopy code
docker pull ghcr.io/openim/openim-chat:latest
docker pull ghcr.io/openimsdk/openim-chat:latest
```

- Pull from Alibaba Cloud:
Expand Down

0 comments on commit 648076a

Please sign in to comment.