I have a working Dockerfile
that requires execution with BuildKit
support.
Question: how can I build the dockerfile from gitlab-ci
and set DOCKER_BUILDKIT=1
globally?
.gitlab-ci.yml
:
image: docker:20
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
build:
script:
- docker build .
Dockerfile
:
FROM maven:3.8.4-eclipse-temurin-11 as dependencies
COPY pom.xml .
COPY src src
RUN --mount=type=cache,target=/root/.m2 mvn package
2
Answers
Gitlab runs inside a linux (native or container), so I suggest you to change
.gitlab-ci.yml
as follow:An other way is to create an environment variable as such:
See https://docs.gitlab.com/ee/ci/variables/