Skaffold: Multi stage build not working in v0.32.0 but work fine in v0.31.0

Created on 21 Jun 2019  路  6Comments  路  Source: GoogleContainerTools/skaffold

Expected behavior

Kaniko (and possibly Docker) targets to work like in v0.31.0

Actual behavior

Kaniko targets don't work as expected when building and instead gives an error

Information

  • Skaffold version: 0.32.0
  • Operating system: Arch 5.1.11-arch1-1-ARCH
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1beta11
kind: Config

build:
  artifacts:
  - image: registry.gitlab.com/example/example/dump
    context: docker/aws
    kaniko:
      cache: {}
      target: dump
  - image: registry.gitlab.com/example/example/postgis
    context: docker/postgis
    kaniko:
      cache: {}
  - image: registry.gitlab.com/example/example/upload
    context: docker/aws
    kaniko:
      cache: {}
      target: upload
  cluster:
    dockerConfig:
      secretName: kaniko
    namespace: kaniko
    pullSecretName: gitlab-registry
  tagPolicy:
    envTemplate:
      template: "{{.IMAGE_NAME}}:latest"

deploy:
  kustomize:
    path: kustomize/overlays/prod

profiles:
- name: dev
  activation:
  - kubeContext: minikube
  build:
    artifacts:
    - image: example/dev/dump
      context: docker/aws
      docker:
        target: dump
    - image: example/dev/postgis
      context: docker/postgis
    - image: example/dev/upload
      context: docker/aws
      docker:
        target: upload
    local: {}
  deploy:
    kustomize:
      path: kustomize/overlays/dev

Dockerfile for context docker/aws:

FROM alpine AS aws
RUN apk add --no-cache \
    python
RUN wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip \
&& unzip awscli-bundle.zip \
&& ./awscli-bundle/install \
    -b /usr/local/bin/aws \
    -i /usr/local/aws \
&& rm -r awscli-bundle*

FROM aws AS dump
RUN apk add --no-cache \
    jq \
    postgresql-client
COPY --chown=root:root files/dump.sh /scripts/
CMD ["/scripts/dump.sh"]

FROM aws AS upload
COPY --chown=root:root files/upload.sh /scripts/
CMD ["/scripts/upload.sh"]

Steps to reproduce the behavior

  1. Run the following file on skaffold v0.32.0
  2. Get the following error:
skaffold build
Generating tags...
 - registry.gitlab.com/example/example/dump -> registry.gitlab.com/example/example/dump:latest
 - registry.gitlab.com/example/example/postgis -> registry.gitlab.com/example/example/postgis:latest
 - registry.gitlab.com/example/example/upload -> registry.gitlab.com/example/example/upload:latest
Tags generated in 242.837碌s
Starting build...
Creating kaniko secret [gitlab-registry]...
Creating docker config secret [kaniko]...
Building [registry.gitlab.com/example/example/dump]...

Complete in 8.165794902s
FATA[0008] build failed: building [registry.gitlab.com/example/example/dump]: kaniko build for [registry.gitlab.com/example/example/dump]: getting dependencies for registry.gitlab.com/example/example/dump: listing copied files: retrieving image config: getting image: UNAUTHORIZED: authentication required; [map[Type:repository Class: Name:library/aws Action:pull]]
prioritp0

Most helpful comment

Thanks. Curious if there will be a 0.32.1 release for this?

All 6 comments

I'm working on it. This is not specific to Kaniko. Something is broken with the way we handle multi stage builds.

@dgageot I was going to try it, but I can't seem to find instructions on how to build the binary from your PR branch. This may be trivial, but I am not a GO developer yet. If you could please point me out to the "build from source" instructions, I'll be more than happy to see if it fixes the current error on my end.

If you really want to do it (I would understand if you didn't!), you have to install go 1.11 or 1.12 and run make install at the root of skaffold folder

Your PR #2340 works for my setup using multi-stage docker dockerfiles.

Thanks!

Thanks. Curious if there will be a 0.32.1 release for this?

Was this page helpful?
0 / 5 - 0 ratings