Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CI): Slipt Docker to fix ci #976

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 0 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2021 Authors of KubeArmor

### build syscall checker

FROM golang:1.18-alpine3.15 as init-builder
WORKDIR /usr/src/KubeArmor
COPY ./KubeArmor/BPF/tests/main.go main.go
COPY ./KubeArmor/BPF/tests/go.mod go.mod
COPY ./KubeArmor/BPF/tests/go.sum go.sum

RUN go build -o syscheck main.go

### Make compiler image
FROM alpine:3.15 as kubearmor-init

RUN apk --no-cache update
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories

RUN apk --no-cache update
RUN apk --no-cache add bash git clang llvm make gcc bpftool@edge


COPY ./KubeArmor/BPF /KubeArmor/BPF/
COPY ./KubeArmor/build/compile.sh /KubeArmor/compile.sh
COPY --from=init-builder /usr/src/KubeArmor/syscheck /KubeArmor/BPF/tests/syscheck
ENTRYPOINT ["/KubeArmor/compile.sh"]

### Builder

FROM golang:1.18-alpine3.15 as builder
Expand Down
28 changes: 28 additions & 0 deletions Dockerfile.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2021 Authors of KubeArmor

### build syscall checker

FROM golang:1.18-alpine3.15 as init-builder
WORKDIR /usr/src/KubeArmor
COPY ./KubeArmor/BPF/tests/main.go main.go
COPY ./KubeArmor/BPF/tests/go.mod go.mod
COPY ./KubeArmor/BPF/tests/go.sum go.sum

RUN go build -o syscheck main.go

### Make compiler image
FROM alpine:3.15 as kubearmor-init

RUN apk --no-cache update
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories

RUN apk --no-cache update
RUN apk --no-cache add bash git clang llvm make gcc bpftool@edge


COPY ./KubeArmor/BPF /KubeArmor/BPF/
COPY ./KubeArmor/build/compile.sh /KubeArmor/compile.sh
COPY --from=init-builder /usr/src/KubeArmor/syscheck /KubeArmor/BPF/tests/syscheck
ENTRYPOINT ["/KubeArmor/compile.sh"]
4 changes: 2 additions & 2 deletions KubeArmor/build/build_kubearmor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ unset LABEL
# build a kubearmor image
DTAG="-t $REPO:$VERSION"
echo "[INFO] Building $DTAG"
cd $ARMOR_HOME/..; docker build $DTAG --target kubearmor . $LABEL
cd $ARMOR_HOME/..; docker build $DTAG -f Dockerfile --target kubearmor . $LABEL

if [ $? != 0 ]; then
echo "[FAILED] Failed to build $REPO:$VERSION"
Expand All @@ -56,7 +56,7 @@ echo "[PASSED] Built $REPO:$VERSION"
# build a kubearmor-init image
DTAGINI="-t $REPO-init:$VERSION"
echo "[INFO] Building $DTAGINI"
cd $ARMOR_HOME/..; docker build $DTAGINI --target kubearmor-init . $LABEL
cd $ARMOR_HOME/..; docker build $DTAGINI -f Dockerfile.init --target kubearmor-init . $LABEL

if [ $? != 0 ]; then
echo "[FAILED] Failed to build $REPO-init:$VERSION"
Expand Down
4 changes: 2 additions & 2 deletions KubeArmor/build/push_kubearmor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ pwd

# push $REPO
echo "[INFO] Pushing $REPO:$VERSION"
cd $ARMOR_HOME/..; docker buildx build --platform $PLATFORMS -t $REPO:$VERSION --push .
cd $ARMOR_HOME/..; docker buildx build --platform $PLATFORMS -t $REPO:$VERSION -f Dockerfile --push .

[[ $? -ne 0 ]] && echo "[FAILED] Failed to push $REPO:$VERSION" && exit 1
echo "[PASSED] Pushed $REPO:$VERSION"

# push $REPO-init
echo "[INFO] Pushing $REPO-init:$VERSION"
cd $ARMOR_HOME/..; docker buildx build --platform $PLATFORMS -t $REPO-init:$VERSION --push .
cd $ARMOR_HOME/..; docker buildx build --platform $PLATFORMS -t $REPO-init:$VERSION -f Dockerfile.init --push .

[[ $? -ne 0 ]] && echo "[FAILED] Failed to push $REPO-init:$VERSION" && exit 1
echo "[PASSED] Pushed $REPO-init:$VERSION"
Expand Down