drone / drone-plugin-index

Public index of Drone plugins
http://plugins.drone.io
73 stars 173 forks source link

how to enable builtkit on docker plugin? #395

Closed thematrixdev closed 1 year ago

thematrixdev commented 1 year ago

I am using this plugin: https://plugins.drone.io/plugins/docker

.drone.yaml

kind: pipeline
name: Test

steps:
  - name: build
    image: plugins/docker
    settings:
      environment:
        DOCKER_BUILDKIT: 1
      registry: harbor.mydomain.com
      username:
        from_secret: HARBOR-USERNAME
      password:
        from_secret: HARBOR-SECRET
      repo: harbor.mydomain.com/project/php
      tags: latest
      dockerfile: dockerfile-php
      experimental: true
      ssh-agent-key:
        from_secret: BITBUCKET-KEY

dockerfile-php

FROM php:7-fpm

RUN apt-get update && apt-get install -y git \
    && rm -rf /var/lib/apt/lists/*

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
    && install-php-extensions curl exif gd gettext mbstring pdo_mysql xdebug zip

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&  \
    php composer-setup.php && \
    php -r "unlink('composer-setup.php');"

RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
RUN --mount=type=ssh

COPY ./website /var/www/html
WORKDIR /var/www/html
RUN php composer.phar install \
    && php composer.phar require sendgrid/sendgrid

Drone shows:

Step 7/14 : RUN --mount=type=ssh
the --mount option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/ to learn how to build images with BuildKit enabled
exit status 1

May I know how to enable buildkit?

Thanks.

thematrixdev commented 1 year ago

Solution: https://harnesscommunity.slack.com/archives/C028FPGCPF0/p1647157884303919?thread_ts=1646991684.781279&cid=C028FPGCPF0

---
kind: pipeline
type: docker
name: PR validation build docker image

platform:
  arch: amd64
  os: linux

trigger:
  event:
    include:
    - pull_request

volumes:
- name: dockersock
  host:
    path: /var/run/docker.sock

steps:
- name: Build ml_all docker image for pull request
  image: plugins/docker
  environment:
    DOCKER_BUILDKIT: 1
  volumes:
  - name: dockersock
    path: /var/run/docker.sock
  settings:
    dockerfile: docker/MlAllDockerfile
    context: docker/
    registry: quay.io
    repo: quay.io/personal/ml_all
    privileged: true
    purge: false
    build_args:
       - BUILDKIT_INLINE_CACHE=1
    cache_from: quay.io/personal/ml_all:latest
    tags:
      - ${DRONE_PULL_REQUEST}
    username:
      from_secret: DOCKER_QUAY_USERNAME
    password:
      from_secret: DOCKER_QUAY_PASSWORD