From 3d6122bc2739724ec3495fe05a3a6167f8a396ff Mon Sep 17 00:00:00 2001 From: shruti2522 Date: Tue, 23 Apr 2024 18:50:21 +0530 Subject: [PATCH] feat:added kcl-builder-alpine Signed-off-by: shruti2522 --- scripts/docker/kcl-builder-alpine/Dockerfile | 50 ++++++++++++++++++++ scripts/docker/kcl-builder-alpine/Makefile | 30 ++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 scripts/docker/kcl-builder-alpine/Dockerfile create mode 100644 scripts/docker/kcl-builder-alpine/Makefile diff --git a/scripts/docker/kcl-builder-alpine/Dockerfile b/scripts/docker/kcl-builder-alpine/Dockerfile new file mode 100644 index 000000000..4cc3ead6c --- /dev/null +++ b/scripts/docker/kcl-builder-alpine/Dockerfile @@ -0,0 +1,50 @@ +# Copyright 2021 The KCL Authors. All rights reserved. + +FROM alpine:latest + +# set timezone +RUN apk add --no-cache tzdata \ + && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo 'Asia/Shanghai' >/etc/timezone + +# update repositories and install required packages +RUN apk add --no-cache \ + make \ + wget \ + git \ + ca-certificates \ + clang \ + llvm \ + libffi-dev \ + go \ + python3 \ + python3-dev \ + py3-pip + +# set environment variables +ENV GOPATH=/go \ + GOLANG_VERSION=1.20.5 \ + PATH="/root/.cargo/bin:${PATH}" \ + CARGO_NET_GIT_FETCH_WITH_CLI=true + +# install rust and cargo +RUN wget -qO- https://sh.rustup.rs | sh -s -- -y \ + && echo 'source $HOME/.cargo/env' >> $HOME/.ashrc \ + && . $HOME/.cargo/env \ + && cargo version \ + && rustc --version + +# install go tools +RUN go install golang.org/x/lint/golint@latest \ + && go install golang.org/x/tools/cmd/goimports@latest \ + && go install github.com/t-yuki/gocover-cobertura@latest \ + && go install github.com/jstemmer/go-junit-report@latest + +RUN rm -rf /root/.cache/go-build \ + && rm -rf /go/pkg/mod \ + && rm -rf /go/pkg/sumdb \ + && rm -rf /var/cache/apk/* + +WORKDIR /root + +CMD ["ash"] diff --git a/scripts/docker/kcl-builder-alpine/Makefile b/scripts/docker/kcl-builder-alpine/Makefile new file mode 100644 index 000000000..431859b61 --- /dev/null +++ b/scripts/docker/kcl-builder-alpine/Makefile @@ -0,0 +1,30 @@ +# Copyright 2021 The KCL Authors. All rights reserved. + +PWD:=$(shell pwd) + +BUILDER_IMAGE:=kcllang/kcl-builder-alpine + +# export DOCKER_DEFAULT_PLATFORM=linux/amd64 +# or +# --platform linux/amd64 + +RUN_IN_DOCKER:=docker run -it --rm --platform linux/amd64 +RUN_IN_DOCKER+=-v ~/.ssh:/root/.ssh +RUN_IN_DOCKER+=-v ~/.gitconfig:/root/.gitconfig +RUN_IN_DOCKER+=-v ~/go/pkg/mod:/go/pkg/mod + +kcl-builder: + docker build --platform linux/amd64 -t ${BUILDER_IMAGE} . + @echo "ok" + +publish-builder: + # docker login --username= + + # make kcl-builder + docker push ${BUILDER_IMAGE} + @echo "push ${BUILDER_IMAGE} ok" + +sh-in-builder: + ${RUN_IN_DOCKER} -v ${PWD}/../../..:/root/kclvm -w /root ${BUILDER_IMAGE} sh + +clean: