Skip to content

Commit

Permalink
optimization the image building of KubeSphere/console (kubesphere#3591)
Browse files Browse the repository at this point in the history
Signed-off-by: zhoutian <[email protected]>

Signed-off-by: zhoutian <[email protected]>
Co-authored-by: zhoutian <[email protected]>
  • Loading branch information
zt1046656665 and zhoutian authored Aug 25, 2022
1 parent 8ea1fa8 commit 6d29fbf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
20 changes: 20 additions & 0 deletions build/Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 The KubeSphere Authors. All rights reserved.
# Use of this source code is governed by an Apache license
# that can be found in the LICENSE file.

FROM node:12-alpine3.14

RUN adduser -D -g kubesphere -u 1002 kubesphere && \
mkdir -p /opt/kubesphere/console && \
chown -R kubesphere:kubesphere /opt/kubesphere/console

WORKDIR /opt/kubesphere/console
COPY ./out/ /opt/kubesphere/console/

RUN mv dist/server.js server/server.js
USER kubesphere

EXPOSE 8080

CMD ["npm", "run", "serve"]

22 changes: 21 additions & 1 deletion hack/docker_build_multiarch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,29 @@ fi
# supported platforms
PLATFORMS=linux/amd64,linux/arm64

# build the preimage
docker buildx build -f build/Dockerfile --target builder --load -t ks-console-pre:"${TAG}" .

# create preimage container
${CONTAINER_CLI} create \
--name predbuild ks-console-pre:"${TAG}"

# copy file from preimage container:./out/ ./out/
${CONTAINER_CLI} cp \
predbuild:/out/ ./out/

# shellcheck disable=SC2086 # inteneded splitting of CONTAINER_BUILDER
${CONTAINER_CLI} ${CONTAINER_BUILDER} \
--platform ${PLATFORMS} \
${PUSH} \
-f build/Dockerfile \
-f build/Dockerfile.dapper \
-t "${REPO}"/ks-console:"${TAG}" .

# delete preimage
docker rmi ks-console-pre:"${TAG}" -f

# delete prebuild container
docker rm predbuild

# delete the folder in ./out
rm -rf ./out

0 comments on commit 6d29fbf

Please sign in to comment.