Files
open-im-server/Dockerfile
T

43 lines
1.6 KiB
Docker
Raw Normal View History

2023-07-13 15:45:03 +08:00
# Build Stage
2023-06-30 18:59:56 +08:00
FROM golang as build
2023-07-13 15:45:03 +08:00
# Set go mod installation source and proxy
ARG GO111MODULE=on
ARG GOPROXY=https://goproxy.cn,direct
ENV GO111MODULE=$GO111MODULE
ENV GOPROXY=$GOPROXY
2023-06-30 18:59:56 +08:00
# Set up the working directory
WORKDIR /Open-IM-Server
2023-07-13 15:45:03 +08:00
# Copy all files to the container
ADD . .
2023-06-30 18:59:56 +08:00
2023-07-13 15:45:03 +08:00
RUN /bin/sh -c "make build"
2023-06-30 18:59:56 +08:00
2023-07-13 15:45:03 +08:00
# Production Stage
FROM alpine
2023-06-30 18:59:56 +08:00
2023-07-13 15:45:03 +08:00
RUN apk --no-cache add tzdata
2023-06-30 18:59:56 +08:00
2023-07-13 15:45:03 +08:00
# 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"]
2023-06-30 18:59:56 +08:00
2023-07-13 15:45:03 +08:00
# Copy scripts and binary files to the production image
2023-06-30 23:21:49 +08:00
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts
2023-07-13 15:45:03 +08:00
COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/arm64 /Open-IM-Server/_output/bin/platforms/linux/arm64
2023-06-30 18:59:56 +08:00
2023-06-30 23:16:33 +08:00
WORKDIR /Open-IM-Server/scripts
2023-06-30 18:59:56 +08:00
CMD ["./docker_start_all.sh"]
2023-07-13 15:45:03 +08:00
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