add workflow

This commit is contained in:
Tejal Desai
2021-01-29 00:16:47 -08:00
parent 6a506ebdaa
commit dd710f30b4
4 changed files with 59 additions and 21 deletions
+48
View File
@@ -0,0 +1,48 @@
name: Build images on push to master
on:
push:
branches:
- '**'
jobs:
build:
env:
IMAGE_NAME: gcr.io/kaniko-project/executor
HASH: $(git rev-parse --short "$GITHUB_SHA")
BRANCH: ${GITHUB_REF##*/}
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GCR_DEVOPS_SERVICE_ACCOUNT_KEY }}
project_id: kaniko-project
export_default_credentials: true
- name: Build and push image
run: |
gcloud auth configure-docker -q
SHORT_SHA1=$(git rev-parse --short HEAD)
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64"
echo "Building and pushing version ${SHORT_SHA1} of image ${IMAGE_NAME}"
docker buildx build --platform "${PLATFORMS}" -t "${IMAGE_NAME}:${SHORT_SHA1}-slim" -t "${IMAGE_NAME}:test-multi-slim" -f ./deploy/Dockerfile_slim \
--push .
+6 -7
View File
@@ -17,6 +17,7 @@
FROM golang:1.15
ARG GOARCH=amd64
WORKDIR /go/src/github.com/GoogleContainerTools/kaniko
RUN echo $GOARCH > /goarch
#This arg is passed by docker buildx & contains the platform info in the form linux/amd64, linux/ppc64le etc.
@@ -24,10 +25,9 @@ ARG TARGETPLATFORM
#Capture ARCH has write to /goarch
RUN [ ! "x" = "x$TARGETPLATFORM" ] && `echo $TARGETPLATFORM | awk '{split($0,a,"/"); print a[2]}' > /goarch` || echo "$GOARCH"
RUN echo "I am runninng $TARGETPLATFORM with with $(cat /goarch)"
# Get GCR credential helper
RUN GOARCH=$(cat /goarch) && \
RUN GOARCH=$(cat /goarch) && CGO_ENABLED=0 && \
(mkdir -p /go/src/github.com/GoogleCloudPlatform || true) && \
cd /go/src/github.com/GoogleCloudPlatform && \
git clone https://github.com/GoogleCloudPlatform/docker-credential-gcr.git && \
@@ -39,7 +39,7 @@ RUN GOARCH=$(cat /goarch) && \
RUN GOARCH=$(cat /goarch) && go get -u github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login && \
make -C /go/src/github.com/awslabs/amazon-ecr-credential-helper
# Azure docker credential helper
# ACR docker credential helper
COPY ./acr.patch /
RUN GOARCH=$(cat /goarch) && (mkdir -p /go/src/github.com/Azure || true) && \
cd /go/src/github.com/Azure && \
@@ -49,7 +49,7 @@ RUN GOARCH=$(cat /goarch) && (mkdir -p /go/src/github.com/Azure || true) && \
git apply < /acr.patch && \
make && cp -f bin/linux/${GOARCH}/docker-credential-acr-linux /usr/local/bin/docker-credential-acr-linux
# ACR docker env credential helper
#ACR docker env credential helper
RUN GOARCH=$(cat /goarch) && (mkdir -p /go/src/github.com/chrismellard || true) && \
cd /go/src/github.com/chrismellard && \
git clone https://github.com/chrismellard/docker-credential-acr-env && \
@@ -60,7 +60,7 @@ RUN GOARCH=$(cat /goarch) && (mkdir -p /go/src/github.com/chrismellard || true)
RUN mkdir -p /kaniko/.docker
COPY . .
RUN make GOARCH=$(cat /goarch)
RUN make GOARCH=$(cat /goarch.txt)
FROM scratch
COPY --from=0 /go/src/github.com/GoogleContainerTools/kaniko/out/executor /kaniko/executor
@@ -79,5 +79,4 @@ ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_co
WORKDIR /workspace
RUN ["docker-credential-gcr", "config", "--token-source=env"]
ENTRYPOINT ["/kaniko/executor"]
ENTRYPOINT ["/kaniko/executor"]
+3 -7
View File
@@ -15,7 +15,7 @@
# Builds the static Go image to execute in a Kubernetes job
# Stage 0: Build the executor binary and get credential helpers
FROM golang:1.15
FROM golang:1.14
ARG GOARCH=amd64
RUN echo $GOARCH > /goarch
@@ -30,12 +30,8 @@ RUN cat /goarch
WORKDIR /go/src/github.com/GoogleContainerTools/kaniko
# Get GCR credential helper
RUN GOARCH=$(cat /goarch) && \
(mkdir -p /go/src/github.com/GoogleCloudPlatform || true) && \
cd /go/src/github.com/GoogleCloudPlatform && \
git clone https://github.com/GoogleCloudPlatform/docker-credential-gcr.git && \
cd /go/src/github.com/GoogleCloudPlatform/docker-credential-gcr && \
make && cp bin/docker-credential-gcr /usr/local/bin/docker-credential-gcr
ADD https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.0.1/docker-credential-gcr_linux_$GOARCH-2.0.1.tar.gz /usr/local/bin/
RUN tar --no-same-owner -C /usr/local/bin/ -xvzf /usr/local/bin/docker-credential-gcr_linux_$GOARCH-2.0.1.tar.gz
# Get Amazon ECR credential helper
RUN GOARCH=$(cat /goarch) && go get -u github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login && \
+2 -7
View File
@@ -27,13 +27,8 @@ RUN [ ! "x" = "x$TARGETPLATFORM" ] && `echo $TARGETPLATFORM | awk '{split($0,a,
RUN echo "I am runninng $TARGETPLATFORM with $(cat /goarch)"
# Get GCR credential helper
RUN GOARCH=$(cat /goarch) && \
(mkdir -p /go/src/github.com/GoogleCloudPlatform || true) && \
cd /go/src/github.com/GoogleCloudPlatform && \
git clone https://github.com/GoogleCloudPlatform/docker-credential-gcr.git && \
cd /go/src/github.com/GoogleCloudPlatform/docker-credential-gcr && \
make deps OUT_DIR=/usr/local/bin && \
go build -ldflags "-linkmode external -extldflags -static" -i -o /usr/local/bin/docker-credential-gcr main.go
ADD ADD https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.0.1/docker-credential-gcr_linux_$GOARCH-2.0.1.tar.gz /usr/local/bin/
RUN tar --no-same-owner -C /usr/local/bin/ -xvzf /usr/local/bin/docker-credential-gcr_linux_$GOARCH-2.0.1.tar.gz
# Get Amazon ECR credential helper
RUN GOARCH=$(cat /goarch) && go get -u github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login && \