Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci-runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ COPY . .
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -a -installsuffix cgo -o /go/bin/cirunner


FROM docker:20.10.24-dind
# All these steps will be cached
#RUN apk add --no-cache ca-certificates
Expand Down
37 changes: 37 additions & 0 deletions ci-runner/Dockerfile-v27
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
####--------------
FROM golang:1.21-alpine3.18 AS build-env

RUN apk add --no-cache git gcc musl-dev
RUN apk add --update make

WORKDIR /go/src/github.com/devtron-labs/cirunner
ADD . /go/src/github.com/devtron-labs/cirunner/
COPY . .
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -a -installsuffix cgo -o /go/bin/cirunner


FROM docker:27.3-dind
# All these steps will be cached
#RUN apk add --no-cache ca-certificates
RUN apk update && apk add --no-cache --virtual .build-deps && apk add bash && apk add make && apk add curl && apk add git && apk add zip && apk add jq
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN apk -Uuv add groff less python3 py3-pip pipx
RUN pipx ensurepath
RUN pipx install awscli
RUN apk --purge -v del py-pip
RUN rm /var/cache/apk/*
COPY --from=docker/compose:1.29.2 /usr/local/bin/docker-compose /usr/bin/docker-compose

COPY ./buildpack.json /buildpack.json
COPY ./git-ask-pass.sh /git-ask-pass.sh
RUN chmod +x /git-ask-pass.sh

RUN (curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.27.0/pack-v0.27.0-linux.tgz" | tar -C /usr/local/bin/ --no-same-owner -xzv pack)

COPY --from=build-env /go/bin/cirunner .
COPY ./ssh-config /root/.ssh/config
RUN chmod 644 /root/.ssh/config

# passing PARENT_MODE as argument to cirunner as default behavior
ENTRYPOINT ["./cirunner", "PARENT_MODE"]
19 changes: 11 additions & 8 deletions ci-runner/helper/DockerHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ import (
)

const (
DEVTRON_ENV_VAR_PREFIX = "$devtron_env_"
BUILD_ARG_FLAG = "--build-arg"
ROOT_PATH = "."
BUILDX_K8S_DRIVER_NAME = "devtron-buildx-builder"
BUILDX_NODE_NAME = "devtron-buildx-node-"
DEVTRON_ENV_VAR_PREFIX = "$devtron_env_"
BUILD_ARG_FLAG = "--build-arg"
ROOT_PATH = "."
BUILDX_K8S_DRIVER_NAME = "devtron-buildx-builder"
BUILDX_NODE_NAME = "devtron-buildx-node-"
DOCKERD_OUTPUT_FILE_PATH = "/usr/local/bin/nohup.out"
)

type DockerHelper interface {
Expand Down Expand Up @@ -112,7 +113,7 @@ func (impl *DockerHelperImpl) StartDockerDaemon(commonWorkflowRequest *CommonWor
dockerMtuValueFlag = fmt.Sprintf("--mtu=%d", commonWorkflowRequest.CiBuildDockerMtuValue)
}
if connection == util.INSECURE {
dockerdstart = fmt.Sprintf("dockerd %s --insecure-registry %s --host=unix:///var/run/docker.sock %s --host=tcp://0.0.0.0:2375 > /usr/local/bin/nohup.out 2>&1 &", defaultAddressPoolFlag, host, dockerMtuValueFlag)
dockerdstart = fmt.Sprintf("dockerd %s --insecure-registry %s --host=unix:///var/run/docker.sock %s --host=tcp://0.0.0.0:2375 > %s 2>&1 &", defaultAddressPoolFlag, host, dockerMtuValueFlag, DOCKERD_OUTPUT_FILE_PATH)
log.Println("Insecure Registry")
} else {
if connection == util.SECUREWITHCERT {
Expand Down Expand Up @@ -149,20 +150,22 @@ func (impl *DockerHelperImpl) StartDockerDaemon(commonWorkflowRequest *CommonWor
return err
}
}
dockerdstart = fmt.Sprintf("dockerd %s --host=unix:///var/run/docker.sock %s --host=tcp://0.0.0.0:2375 > /usr/local/bin/nohup.out 2>&1 &", defaultAddressPoolFlag, dockerMtuValueFlag)
dockerdstart = fmt.Sprintf("dockerd %s --host=unix:///var/run/docker.sock %s --host=tcp://0.0.0.0:2375 > %s 2>&1 &", defaultAddressPoolFlag, dockerMtuValueFlag, DOCKERD_OUTPUT_FILE_PATH)
}
cmd := impl.GetCommandToExecute(dockerdstart)
out, err := cmd.CombinedOutput()
if err != nil {
log.Println("failed to start docker daemon")
util.PrintFileContent(DOCKERD_OUTPUT_FILE_PATH)
return err
}
log.Println("docker daemon started ", string(out))
err = impl.waitForDockerDaemon(util.DOCKER_PS_START_WAIT_SECONDS)
if err != nil {
util.PrintFileContent(DOCKERD_OUTPUT_FILE_PATH)
return err
}
return err
return nil
}

if err := util.ExecuteWithStageInfoLog(util.DOCKER_DAEMON, startDockerDaemon); err != nil {
Expand Down
21 changes: 21 additions & 0 deletions ci-runner/util/Util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"github.com/devtron-labs/common-lib/git-manager/util"
"github.com/devtron-labs/common-lib/utils/workFlow"
"io"
"io/ioutil"
"log"
"math/rand"
Expand Down Expand Up @@ -264,3 +265,23 @@ func PopulateStageError(errorMessage string) {
log.Println(util.DEVTRON, "failed to write error message: ", writeErr)
}
}

func PrintFileContent(filePath string) {
// Open the file
file, err := os.Open(filePath)
if err != nil {
log.Println(util.DEVTRON, "Error opening file:", err)
return
}
defer file.Close()

// Read the entire content of the file
content, err := io.ReadAll(file)
if err != nil {
log.Println(util.DEVTRON, "Error reading file:", err)
return
}

// Print the file content
log.Println(util.DEVTRON, string(content))
}