mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 11:52:10 +08:00
refactor
This commit is contained in:
parent
c239307f77
commit
6a29662786
40
Dockerfile
40
Dockerfile
@ -1,30 +1,26 @@
|
||||
# Build Stage
|
||||
FROM golang:1.20 AS builder
|
||||
# Use Go 1.21 as the base image
|
||||
FROM golang:1.21 as builder
|
||||
|
||||
# Set go mod installation source and proxy
|
||||
ARG GO111MODULE=on
|
||||
# Set the working directory
|
||||
WORKDIR /openim-server
|
||||
|
||||
ENV GO111MODULE=$GO111MODULE
|
||||
ENV GOPROXY=$GOPROXY
|
||||
# Copy all files from the current directory to the image
|
||||
COPY . .
|
||||
|
||||
# Set up the working directory
|
||||
WORKDIR /openim/openim-server
|
||||
# Execute the script and build command
|
||||
RUN chmod +x ./bootstrap.sh && \
|
||||
./bootstrap.sh && \
|
||||
mage build
|
||||
|
||||
# Use scratch as the base image for the minimal production image
|
||||
FROM scratch
|
||||
|
||||
# Copy all files to the container
|
||||
ADD . .
|
||||
# Copy the compiled binaries from the builder image to the production image
|
||||
COPY --from=builder /openim-server/_output /openim-server/_output
|
||||
|
||||
RUN Bash bootstrap.sh
|
||||
RUN mage
|
||||
# Set the working directory
|
||||
WORKDIR /openim-server
|
||||
|
||||
FROM ghcr.io/openim-sigs/openim-ubuntu-image:latest
|
||||
# Set up volume mounts for the config directory and logs directory
|
||||
VOLUME ["/openim-server/config", "/openim-server/_output/logs"]
|
||||
|
||||
WORKDIR ${`SERVER_WORKDIR`}
|
||||
|
||||
# Copy scripts and binary files to the production image
|
||||
COPY --from=builder ${OPENIM_SERVER_BINDIR} /openim/openim-server/_output/bin
|
||||
COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
|
||||
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
|
||||
COPY --from=builder ${SERVER_WORKDIR}/deployments /openim/openim-server/deployments
|
||||
|
||||
CMD ["cd /openim/openim-server/scripts/docker-start-all.sh"]
|
||||
|
||||
@ -1,26 +1,48 @@
|
||||
# Use Go 1.21 as the base image
|
||||
FROM golang:1.21 as builder
|
||||
# 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.
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /openim-server
|
||||
# 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
|
||||
|
||||
WORKDIR /openim/openim-server
|
||||
|
||||
ENV GO111MODULE=$GO111MODULE
|
||||
ENV GOPROXY=$GOPROXY
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy all files from the current directory to the image
|
||||
COPY . .
|
||||
|
||||
# Execute the script and build command
|
||||
RUN chmod +x ./bootstrap.sh && \
|
||||
./bootstrap.sh && \
|
||||
mage build
|
||||
RUN make clean
|
||||
RUN make build BINS=component
|
||||
|
||||
# Use scratch as the base image for the minimal production image
|
||||
FROM scratch
|
||||
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
||||
FROM ghcr.io/openim-sigs/openim-bash-image:latest
|
||||
|
||||
# Copy the compiled binaries from the builder image to the production image
|
||||
COPY --from=builder /openim-server/_output /openim-server/_output
|
||||
WORKDIR /openim/openim-server
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /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
|
||||
|
||||
# Set up volume mounts for the config directory and logs directory
|
||||
VOLUME ["/openim-server/config", "/openim-server/_output/logs"]
|
||||
ENV OPENIM_SERVER_CONFIG_NAME=/openim/openim-server/config
|
||||
|
||||
RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/component /usr/bin/component
|
||||
|
||||
ENTRYPOINT ["bash", "-c", "component -c $OPENIM_SERVER_CONFIG_NAME"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user