Skip to content

Commit

Permalink
Updated docker file to remove extra layers for ci-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
pawan-59 committed Jan 2, 2025
1 parent e1de4f1 commit 9049f64
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 31 deletions.
42 changes: 25 additions & 17 deletions ci-runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
####--------------
FROM golang:1.21-alpine3.18 AS build-env

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

WORKDIR /go/src/github.com/devtron-labs/cirunner
ADD . /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:20.10.24-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
RUN pip3 install awscli
RUN apk --purge -v del py-pip
RUN rm /var/cache/apk/*

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 && \
ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
apk -Uuv add groff less python3 py3-pip && \
pip3 install awscli && \
apk --purge -v del py-pip && \
rm /var/cache/apk/*

COPY --from=docker/compose:latest /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
COPY ./buildpack.json ./git-ask-pass.sh /
# COPY ./git-ask-pass.sh /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)
RUN chmod +x /git-ask-pass.sh && \
(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
RUN mkdir -p /etc/docker

RUN chmod 644 /root/.ssh/config && \
mkdir -p /etc/docker && \
mkdir -p /root/.docker/buildx

COPY docker-daemon.json /etc/docker/daemon.json
RUN mkdir -p /root/.docker/buildx


COPY buildkitd.default.toml /root/.docker/buildx/buildkitd.default.toml

# passing PARENT_MODE as argument to cirunner as default behavior
Expand Down
31 changes: 17 additions & 14 deletions ci-runner/Dockerfile-v27
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
####--------------
FROM golang:1.21-alpine3.18 AS build-env

RUN apk add --no-cache git gcc musl-dev
RUN apk add --update make
RUN apk add --no-cache git gcc musl-dev && \
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
Expand All @@ -14,24 +15,26 @@ RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -a -installsuffix cgo -o /
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 && pipx install awscli
RUN cp /root/.local/bin/aws* /usr/local/bin
RUN apk --purge -v del py-pip
RUN rm /var/cache/apk/*
ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
apk -Uuv add groff less python3 py3-pip pipx && \
pipx ensurepath && pipx install awscli && \
cp /root/.local/bin/aws* /usr/local/bin && \
apk --purge -v del py-pip && \
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
COPY ./buildpack.json /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 ./git-ask-pass.sh /git-ask-pass.sh
RUN chmod +x /git-ask-pass.sh && \
(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"]
ENTRYPOINT ["./cirunner", "PARENT_MODE"]

0 comments on commit 9049f64

Please # to comment.