pull/2202/head
skiffer-git 1 year ago
parent c239307f77
commit 6a29662786

@ -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
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
FROM ghcr.io/openim-sigs/openim-bash-image:latest
# Use scratch as the base image for the minimal production image
FROM scratch
WORKDIR /openim/openim-server
# Copy the compiled binaries from the builder image to the production image
COPY --from=builder /openim-server/_output /openim-server/_output
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 the working directory
WORKDIR /openim-server
ENV OPENIM_SERVER_CONFIG_NAME=/openim/openim-server/config
# Set up volume mounts for the config directory and logs directory
VOLUME ["/openim-server/config", "/openim-server/_output/logs"]
RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/component /usr/bin/component
ENTRYPOINT ["bash", "-c", "component -c $OPENIM_SERVER_CONFIG_NAME"]

Loading…
Cancel
Save