Skip to content

Commit

Permalink
perf: 更新 Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
wojiushixiaobai committed Jul 12, 2024
1 parent be00eda commit 3d6146f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 51 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ RUN set -ex \
&& chown root:root /opt/koko/bin/* \
&& rm -f *.tar.gz

ARG MONGOSH_VERSION=2.2.12
RUN set -ex \
&& mkdir -p /opt/koko/lib \
&& \
case "${TARGETARCH}" in \
amd64) \
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH_VERSION}-linux-x64.tgz \
&& tar -xf mongosh-${MONGOSH_VERSION}-linux-x64.tgz \
&& chown root:root mongosh-${MONGOSH_VERSION}-linux-x64/bin/* \
&& mv mongosh-${MONGOSH_VERSION}-linux-x64/bin/mongosh /opt/koko/bin/ \
&& mv mongosh-${MONGOSH_VERSION}-linux-x64/bin/mongosh_crypt_v1.so /opt/koko/lib/ \
&& rm -rf mongosh-${MONGOSH_VERSION}-linux-x64* \
;; \
arm64|ppc64le|s390x) \
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}.tgz \
&& tar -xf mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}.tgz \
&& chown root:root mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}/bin/* \
&& mv mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}/bin/mongosh /opt/koko/bin/ \
&& mv mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}/bin/mongosh_crypt_v1.so /opt/koko/lib/ \
&& rm -rf mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}* \
;; \
*) \
echo "Unsupported architecture: ${TARGETARCH}" \
;; \
esac

ARG GOPROXY=https://goproxy.io
ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
52 changes: 1 addition & 51 deletions Dockerfile-ee
Original file line number Diff line number Diff line change
@@ -1,52 +1,5 @@
ARG VERSION

FROM debian:bullseye-slim AS stage-build
ARG TARGETARCH

ARG DEPENDENCIES=" \
ca-certificates \
curl \
wget"

ARG APT_MIRROR=http://mirrors.ustc.edu.cn
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=koko \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=koko \
set -ex \
&& rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache \
&& sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
&& apt-get update \
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \
&& echo "no" | dpkg-reconfigure dash

WORKDIR /opt/koko

ARG MONGOSH_VERSION=2.2.10
RUN set -ex \
&& mkdir -p /opt/koko/bin /opt/koko/lib \
&& \
case "${TARGETARCH}" in \
amd64) \
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH_VERSION}-linux-x64.tgz \
&& tar -xf mongosh-${MONGOSH_VERSION}-linux-x64.tgz \
&& chown root:root mongosh-${MONGOSH_VERSION}-linux-x64/bin/* \
&& mv mongosh-${MONGOSH_VERSION}-linux-x64/bin/mongosh /opt/koko/bin/ \
&& mv mongosh-${MONGOSH_VERSION}-linux-x64/bin/mongosh_crypt_v1.so /opt/koko/lib/ \
&& rm -rf mongosh-${MONGOSH_VERSION}-linux-x64* \
;; \
arm64) \
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}.tgz \
&& tar -xf mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}.tgz \
&& chown root:root mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}/bin/* \
&& mv mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}/bin/mongosh /opt/koko/bin/ \
&& mv mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}/bin/mongosh_crypt_v1.so /opt/koko/lib/ \
&& rm -rf mongosh-${MONGOSH_VERSION}-linux-${TARGETARCH}* \
;; \
*) \
echo "Unsupported architecture: ${TARGETARCH}" \
;; \
esac

FROM registry.fit2cloud.com/jumpserver/koko:${VERSION}-ce
ARG TARGETARCH

Expand All @@ -69,7 +22,4 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=koko \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=koko \
set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends ${DEPENDENCIES}

COPY --from=stage-build /opt/koko/bin /usr/local/bin
COPY --from=stage-build /opt/koko/lib /usr/local/lib
&& apt-get install -y --no-install-recommends ${DEPENDENCIES}

0 comments on commit 3d6146f

Please sign in to comment.