Skip to content

Commit 167a854

Browse files
authored
Merge pull request #20 from devtron-labs/docker-version-upgrade
feat: Docker version upgrade
2 parents a6ee299 + 979cf29 commit 167a854

File tree

4 files changed

+69
-9
lines changed

4 files changed

+69
-9
lines changed

ci-runner/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ COPY . .
1010
# Build the binary
1111
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -a -installsuffix cgo -o /go/bin/cirunner
1212

13-
1413
FROM docker:20.10.24-dind
1514
# All these steps will be cached
1615
#RUN apk add --no-cache ca-certificates

ci-runner/Dockerfile-v27

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
####--------------
2+
FROM golang:1.21-alpine3.18 AS build-env
3+
4+
RUN apk add --no-cache git gcc musl-dev
5+
RUN apk add --update make
6+
7+
WORKDIR /go/src/github.com/devtron-labs/cirunner
8+
ADD . /go/src/github.com/devtron-labs/cirunner/
9+
COPY . .
10+
# Build the binary
11+
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -a -installsuffix cgo -o /go/bin/cirunner
12+
13+
14+
FROM docker:27.3-dind
15+
# All these steps will be cached
16+
#RUN apk add --no-cache ca-certificates
17+
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
18+
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
19+
RUN apk -Uuv add groff less python3 py3-pip pipx
20+
RUN pipx ensurepath
21+
RUN pipx install awscli
22+
RUN apk --purge -v del py-pip
23+
RUN rm /var/cache/apk/*
24+
COPY --from=docker/compose:1.29.2 /usr/local/bin/docker-compose /usr/bin/docker-compose
25+
26+
COPY ./buildpack.json /buildpack.json
27+
COPY ./git-ask-pass.sh /git-ask-pass.sh
28+
RUN chmod +x /git-ask-pass.sh
29+
30+
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)
31+
32+
COPY --from=build-env /go/bin/cirunner .
33+
COPY ./ssh-config /root/.ssh/config
34+
RUN chmod 644 /root/.ssh/config
35+
36+
# passing PARENT_MODE as argument to cirunner as default behavior
37+
ENTRYPOINT ["./cirunner", "PARENT_MODE"]

ci-runner/helper/DockerHelper.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ import (
5353
)
5454

5555
const (
56-
DEVTRON_ENV_VAR_PREFIX = "$devtron_env_"
57-
BUILD_ARG_FLAG = "--build-arg"
58-
ROOT_PATH = "."
59-
BUILDX_K8S_DRIVER_NAME = "devtron-buildx-builder"
60-
BUILDX_NODE_NAME = "devtron-buildx-node-"
56+
DEVTRON_ENV_VAR_PREFIX = "$devtron_env_"
57+
BUILD_ARG_FLAG = "--build-arg"
58+
ROOT_PATH = "."
59+
BUILDX_K8S_DRIVER_NAME = "devtron-buildx-builder"
60+
BUILDX_NODE_NAME = "devtron-buildx-node-"
61+
DOCKERD_OUTPUT_FILE_PATH = "/usr/local/bin/nohup.out"
6162
)
6263

6364
type DockerHelper interface {
@@ -112,7 +113,7 @@ func (impl *DockerHelperImpl) StartDockerDaemon(commonWorkflowRequest *CommonWor
112113
dockerMtuValueFlag = fmt.Sprintf("--mtu=%d", commonWorkflowRequest.CiBuildDockerMtuValue)
113114
}
114115
if connection == util.INSECURE {
115-
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)
116+
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)
116117
log.Println("Insecure Registry")
117118
} else {
118119
if connection == util.SECUREWITHCERT {
@@ -149,20 +150,22 @@ func (impl *DockerHelperImpl) StartDockerDaemon(commonWorkflowRequest *CommonWor
149150
return err
150151
}
151152
}
152-
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)
153+
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)
153154
}
154155
cmd := impl.GetCommandToExecute(dockerdstart)
155156
out, err := cmd.CombinedOutput()
156157
if err != nil {
157158
log.Println("failed to start docker daemon")
159+
util.PrintFileContent(DOCKERD_OUTPUT_FILE_PATH)
158160
return err
159161
}
160162
log.Println("docker daemon started ", string(out))
161163
err = impl.waitForDockerDaemon(util.DOCKER_PS_START_WAIT_SECONDS)
162164
if err != nil {
165+
util.PrintFileContent(DOCKERD_OUTPUT_FILE_PATH)
163166
return err
164167
}
165-
return err
168+
return nil
166169
}
167170

168171
if err := util.ExecuteWithStageInfoLog(util.DOCKER_DAEMON, startDockerDaemon); err != nil {

ci-runner/util/Util.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"github.com/devtron-labs/common-lib/git-manager/util"
2424
"github.com/devtron-labs/common-lib/utils/workFlow"
25+
"io"
2526
"io/ioutil"
2627
"log"
2728
"math/rand"
@@ -264,3 +265,23 @@ func PopulateStageError(errorMessage string) {
264265
log.Println(util.DEVTRON, "failed to write error message: ", writeErr)
265266
}
266267
}
268+
269+
func PrintFileContent(filePath string) {
270+
// Open the file
271+
file, err := os.Open(filePath)
272+
if err != nil {
273+
log.Println(util.DEVTRON, "Error opening file:", err)
274+
return
275+
}
276+
defer file.Close()
277+
278+
// Read the entire content of the file
279+
content, err := io.ReadAll(file)
280+
if err != nil {
281+
log.Println(util.DEVTRON, "Error reading file:", err)
282+
return
283+
}
284+
285+
// Print the file content
286+
log.Println(util.DEVTRON, string(content))
287+
}

0 commit comments

Comments
 (0)