Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>pull/540/head
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
|
@ -1,39 +1,43 @@
|
||||
# Build Stage
|
||||
FROM golang as build
|
||||
|
||||
# go mod Installation source, container environment variable addition will override the default variable value
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
# Set go mod installation source and proxy
|
||||
ARG GO111MODULE=on
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GO111MODULE=$GO111MODULE
|
||||
ENV GOPROXY=$GOPROXY
|
||||
|
||||
# Set up the working directory
|
||||
WORKDIR /Open-IM-Server
|
||||
# add all files to the container
|
||||
COPY . .
|
||||
|
||||
WORKDIR /Open-IM-Server/scripts
|
||||
RUN chmod +x *.sh
|
||||
|
||||
RUN /bin/sh -c ./build_all_service.sh
|
||||
# Copy all files to the container
|
||||
ADD . .
|
||||
|
||||
#Blank image Multi-Stage Build
|
||||
FROM ubuntu
|
||||
RUN /bin/sh -c "make build"
|
||||
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&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
|
||||
# Production Stage
|
||||
FROM alpine
|
||||
|
||||
RUN apk --no-cache add tzdata
|
||||
|
||||
#set directory to map logs,config file,scripts file.
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/scripts","/Open-IM-Server/db/sdk"]
|
||||
# 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"]
|
||||
|
||||
#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/_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
|
||||
|
||||
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
|
Loading…
Reference in new issue