feat: add test file

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
pull/540/head
Xinwei Xiong(cubxxw-openim) 2 years ago
parent ce33b79915
commit fd3c19d6a5

@ -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/

@ -0,0 +1,36 @@
name: OpenIM Build Docker Images
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
bin:
- ssserver
- sslocal
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

@ -83,7 +83,7 @@ jobs:
- name: Build source code for host platform - name: Build source code for host platform
run: | run: |
make multiarch make build
echo "Build source code for host platform successfully" echo "Build source code for host platform successfully"
# - name: Collect Test Coverage File # - name: Collect Test Coverage File
@ -132,22 +132,3 @@ jobs:
# - name: Test docker image # - name: Test docker image
# run: | # run: |
# docker build -t openim:ci-build . # docker build -t openim:ci-build .
# goreleaser-test:
# runs-on: ubuntu-20.04
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: ${{ env.GO_VERSION }}
# - name: Run GoReleaser
# uses: goreleaser/goreleaser-action@v4
# with:
# version: latest
# args: release --clean --skip-publish --snapshot

@ -1,39 +1,43 @@
# Build Stage
FROM golang as build FROM golang as build
# go mod Installation source, container environment variable addition will override the default variable value # Set go mod installation source and proxy
ENV GO111MODULE=on ARG GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct ARG GOPROXY=https://goproxy.cn,direct
ENV GO111MODULE=$GO111MODULE
ENV GOPROXY=$GOPROXY
# Set up the working directory # Set up the working directory
WORKDIR /Open-IM-Server WORKDIR /Open-IM-Server
# add all files to the container
COPY . .
WORKDIR /Open-IM-Server/scripts # Copy all files to the container
RUN chmod +x *.sh ADD . .
RUN /bin/sh -c ./build_all_service.sh
#Blank image Multi-Stage Build RUN /bin/sh -c "make build"
FROM ubuntu
RUN rm -rf /var/lib/apt/lists/* # Production Stage
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\ FROM alpine
&&apt-get install net-tools
#Non-interactive operation
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y vim curl tzdata gawk
#Time zone adjusted to East eighth District
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN apk --no-cache add tzdata
#set directory to map logs,config file,scripts file. # Set directory to map logs, config files, scripts, and SDK
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/scripts","/Open-IM-Server/db/sdk"] VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"]
#Copy scripts files and binary files to the blank image # Copy scripts and binary files to the production image
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts
COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/amd64 /Open-IM-Server/_output/bin/platforms/linux/amd64 COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/arm64 /Open-IM-Server/_output/bin/platforms/linux/arm64
WORKDIR /Open-IM-Server/scripts WORKDIR /Open-IM-Server/scripts
CMD ["./docker_start_all.sh"] CMD ["./docker_start_all.sh"]
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross

@ -100,7 +100,7 @@ services:
openim_server: openim_server:
image: ghcr.io/openimsdk/openim-server:v3.0.0-alpha.0 image: ghcr.io/openimsdk/openim-server:v3.0.0-alpha.1
container_name: openim-server container_name: openim-server
volumes: volumes:
- ./logs:/Open-IM-Server/logs - ./logs:/Open-IM-Server/logs

@ -37,10 +37,12 @@ echo -e "${BOLD_PREFIX}_________________________________________________________
bin_dir="$BIN_DIR" bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs" logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/db/sdk/" sdk_db_dir="$OPENIM_ROOT/db/sdk/"
echo "==> bin_dir=$bin_dir"
echo "==> logs_dir=$logs_dir"
echo "==> sdk_db_dir=$sdk_db_dir"
# Automatically created when there is no bin, logs folder # Automatically created when there is no bin, logs folder
if [ ! -d $bin_dir ]; then
mkdir -p $bin_dir
fi
if [ ! -d $logs_dir ]; then if [ ! -d $logs_dir ]; then
mkdir -p $logs_dir mkdir -p $logs_dir
fi fi
@ -48,16 +50,6 @@ if [ ! -d $sdk_db_dir ]; then
mkdir -p $sdk_db_dir mkdir -p $sdk_db_dir
fi fi
#Include shell font styles and some basic information
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
echo "PWD=================>$PWD"
#Include shell font styles and some basic information
source ./style_info.sh
source ./path_info.sh
source ./function.sh
cd $OPENIM_ROOT cd $OPENIM_ROOT
# Execute 'make build' # Execute 'make build'

Loading…
Cancel
Save