From fc3ce2a0ae254a44ced9ac68260d520a482974ff Mon Sep 17 00:00:00 2001 From: Benjamin Yolken Date: Mon, 25 Jan 2021 19:54:30 -0800 Subject: [PATCH 1/3] Push lambda image --- .circleci/config.yml | 6 ++++++ .dockerignore | 1 + Dockerfile | 3 --- Dockerfile.lambda | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 Dockerfile.lambda diff --git a/.circleci/config.yml b/.circleci/config.yml index 4161c42..c8c2e85 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,7 +60,13 @@ jobs: -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply:${SHORT_GIT_SHA} \ --build-arg VERSION_REF=${SHORT_GIT_SHA} \ . + docker build \ + -f Dockerfile.lambda \ + -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply-lambda:${SHORT_GIT_SHA} \ + --build-arg VERSION_REF=${SHORT_GIT_SHA} \ + . docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply:${SHORT_GIT_SHA} + docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply-lambda:${SHORT_GIT_SHA} workflows: version: 2 diff --git a/.dockerignore b/.dockerignore index 3b25dda..2b858b0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ Dockerfile +Dockerfile.lambda build deps *zip diff --git a/Dockerfile b/Dockerfile index c1203a6..c742d48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,6 @@ ENV SRC github.com/segmentio/kubeapply RUN apt-get update && apt-get install --yes \ curl \ - libbtrfs-dev \ - libdevmapper-dev \ wget COPY . /go/src/${SRC} @@ -29,7 +27,6 @@ FROM ubuntu:18.04 RUN apt-get update && apt-get install --yes \ curl \ git \ - libdevmapper-dev \ python3 \ python3-pip diff --git a/Dockerfile.lambda b/Dockerfile.lambda new file mode 100644 index 0000000..826c83f --- /dev/null +++ b/Dockerfile.lambda @@ -0,0 +1,41 @@ +# Fetch or build all required binaries +FROM golang:1.14 as builder + +ARG VERSION_REF +RUN test -n "${VERSION_REF}" + +ENV SRC github.com/segmentio/kubeapply + +RUN apt-get update && apt-get install --yes \ + curl \ + wget + +COPY . /go/src/${SRC} +RUN cd /usr/local/bin && /go/src/${SRC}/scripts/pull-deps.sh + +WORKDIR /go/src/${SRC} + +ENV CGO_ENABLED=1 +ENV GO111MODULE=on + +RUN make kubeapply VERSION_REF=${VERSION_REF} && \ + cp build/kubeapply /usr/local/bin +RUN make kubeapply-lambda VERSION_REF=${VERSION_REF} && \ + cp build/kubeapply-lambda /usr/local/bin + +# Copy into final image +FROM public.ecr.aws/lambda/go:1 + +RUN yum install -y git + +RUN curl -O https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py +RUN pip3 install awscli + +COPY --from=builder /usr/local/bin/aws-iam-authenticator /usr/local/bin +COPY --from=builder /usr/local/bin/helm /usr/local/bin +COPY --from=builder /usr/local/bin/kubeval /usr/local/bin +COPY --from=builder /usr/local/bin/kubectl /usr/local/bin +COPY --from=builder /usr/local/bin/kubeapply /usr/local/bin +COPY --from=builder /usr/local/bin/kubeapply-lambda /usr/local/bin + +CMD [ "/usr/local/bin/kubeapply-lambda" ] From 3887bdaf12bf2c4ed3064c9d93949526bd0ca26c Mon Sep 17 00:00:00 2001 From: Benjamin Yolken Date: Mon, 25 Jan 2021 20:04:33 -0800 Subject: [PATCH 2/3] Update circleci configs --- .circleci/config.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c8c2e85..e1e557a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,19 +53,23 @@ jobs: pip3 install awscli==1.16.292 $(aws ecr get-login --no-include-email --region ${AWS_REGION} --registry-ids ${AWS_ACCOUNT_ID}) - run: - name: Build and push image + name: Build and push main image command: | export SHORT_GIT_SHA=$(echo ${CIRCLE_SHA1} | cut -c -7) docker build \ -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply:${SHORT_GIT_SHA} \ --build-arg VERSION_REF=${SHORT_GIT_SHA} \ . + docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply:${SHORT_GIT_SHA} + - run: + name: Build and push lambda image + command: | + export SHORT_GIT_SHA=$(echo ${CIRCLE_SHA1} | cut -c -7) docker build \ -f Dockerfile.lambda \ -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply-lambda:${SHORT_GIT_SHA} \ --build-arg VERSION_REF=${SHORT_GIT_SHA} \ . - docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply:${SHORT_GIT_SHA} docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply-lambda:${SHORT_GIT_SHA} workflows: From af86236183b5bd1522ee56345aeeea63429527e3 Mon Sep 17 00:00:00 2001 From: Benjamin Yolken Date: Mon, 25 Jan 2021 20:39:29 -0800 Subject: [PATCH 3/3] Update data --- data/data.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/data.go b/data/data.go index 6b8dbe6..b689801 100644 --- a/data/data.go +++ b/data/data.go @@ -95,7 +95,7 @@ func pkgPullreqTemplatesApply_commentGotpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/pullreq/templates/apply_comment.gotpl", size: 1052, mode: os.FileMode(0644), modTime: time.Unix(1611627862, 0)} + info := bindataFileInfo{name: "pkg/pullreq/templates/apply_comment.gotpl", size: 1052, mode: os.FileMode(0644), modTime: time.Unix(1611631812, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x39, 0x98, 0xb8, 0x81, 0x9e, 0xbb, 0x97, 0xdd, 0x58, 0x91, 0x82, 0x55, 0x99, 0xef, 0x6c, 0xc3, 0x49, 0xe7, 0xe0, 0x9d, 0x4, 0x30, 0x35, 0x16, 0xb9, 0xa3, 0x44, 0x34, 0x84, 0x2e, 0x0, 0x1b}} return a, nil } @@ -255,7 +255,7 @@ func scriptsCreateLambdaBundleSh() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "scripts/create-lambda-bundle.sh", size: 819, mode: os.FileMode(0755), modTime: time.Unix(1611616180, 0)} + info := bindataFileInfo{name: "scripts/create-lambda-bundle.sh", size: 819, mode: os.FileMode(0755), modTime: time.Unix(1611633754, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x53, 0x3c, 0xc6, 0xbf, 0x2d, 0x5c, 0xb1, 0x3b, 0x37, 0x5, 0xa4, 0x16, 0x52, 0x5a, 0xd4, 0x49, 0xbb, 0xf8, 0x4, 0x83, 0x3c, 0xbf, 0x10, 0x39, 0xcf, 0x18, 0xbf, 0x52, 0x35, 0xee, 0xca, 0x3}} return a, nil }