How to set custom .dockerignore or enable DOCKER_BUILDKIT=1

I’m trying to enable DOCKER_BUILDKIT during builds. in gitpod.
I have a situation where I cannot set .dockerignore in the root of my repo as it impact sour production builds.
o, I have the .gitpod.yml file in root, that refers to the dockerfile in another folder. I need to somehow specify the context to gitpod docker build to ignore some of the folders in the repo without using .dockerignore/

So, my questions are -

  1. Is there a way to specify a custom dockerignore file?
    OR
  2. Is there a way to specify DOCKER_BUILDKIT=1 that actually reduces the size of build context

Anyone? Is buildkit supported? I haven’t been able to get it to work things such as : #

syntax=docker/dockerfile:1.2

FROM alpine

# shows secret from default secret location:
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret

# shows secret from custom secret location:
RUN --mount=type=secret,id=mysecret,dst=/foobar cat /foobar

Hi @kirthiss and @shism2! Welcome to the Gitpod community, and wow, sorry this seems to have slipped under our radar for a while :frowning: we’ll try to do better!

Would something like image.context help in this case? E.g.:

image:
  file: subdir/Dockerfile
  context: subdir

That way you can better control what should or shouldn’t be inside the build context, i.e. inside ./subdir.

Hmm, I know that you can use buildkit inside a running Gitpod workspace (by running docker commands in the terminal such as described in this issue), however I’m not sure whether you can enable buildkit for Gitpod’s own workspace image builds (e.g. for building a custom .gitpod.Dockerfile).

I think https://github.com/gitpod-io/gitpod/issues/5430 captures the second question well, and so I’ve added it to the “Inbox” of Gitpod’s “workspace engineering team” :slight_smile: thus, someone with better knowledge of Gitpod’s image builder should be able to reply within a few days if that’s possible or what it would take.

1 Like

Thank you the help. It would be ideal to implement the latest dockerfile format etc

1 Like