drone / drone-plugin-index

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

docker-plugin ssh-agent-key does not work #396

Closed thematrixdev closed 1 year ago

thematrixdev commented 1 year ago

drone.yaml

kind: pipeline
name: Test

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

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

BITBUCKET-KEY is stored on Drone UI, and added to Bitbucket.org:

-----BEGIN OPENSSH PRIVATE KEY-----
dummy
-----END OPENSSH PRIVATE 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');"

WORKDIR /var/www/html

COPY ./website .

RUN --mount=type=ssh \
    mkdir -p -m 0600 ~/.ssh  \
    && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts \
    && php composer.phar install \
    && php composer.phar require sendgrid/sendgrid

Drone build error:

latest: Pulling from plugins/docker
Digest: sha256:ea4e85abad2717e19427610186315f4a4628d5100ac3040e73febdb54442c497
Status: Image is up to date for plugins/docker:latest
+ /usr/local/bin/dockerd --data-root /var/lib/docker --host=unix:///var/run/docker.sock --experimental
Detected registry credentials
+ /usr/local/bin/docker version
Client:
 Version:           20.10.14
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 24 01:45:09 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          23.0.1
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.5
  Git commit:       bc3805a
  Built:            Thu Feb  9 19:47:01 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.18
  GitCommit:        2456e983eb9e37e47538f59ea18f2043c9a73640
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
+ /usr/local/bin/docker info
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 19
  Running: 16
  Paused: 0
  Stopped: 3
 Images: 23
 Server Version: 23.0.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2456e983eb9e37e47538f59ea18f2043c9a73640
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-1031-aws
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.892GiB
 Name: ip-10-28-81-52
 ID: 5efff943-3755-4155-887b-54d96648f25f
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

+ /usr/local/bin/docker build --rm=true -f dockerfile-php -t 5eaeb56cfa1d5b29fa007a2bb8fa5276544ac675 . --pull=true --label org.opencontainers.image.created=2023-03-03T04:34:14Z --label org.opencontainers.image.revision=5eaeb56cfa1d5b29fa007a2bb8fa5276544ac675 --label org.opencontainers.image.source=https://bitbucket.org/mydomain/myrepo.git --label org.opencontainers.image.url=https://bitbucket.org/mydomain/myrepo
#1 [internal] load .dockerignore
#1 sha256:2a80cbc0fa94fcf9da56503a9437f40150636cc6392181fde774d7457a869f37
#1 transferring context: 46B done
#1 DONE 0.0s

#2 [internal] load build definition from dockerfile-php
#2 sha256:a8747beeecde680de0fe4f64d3d570667f96d151d07a9386e4a4501ec4842b87
#2 transferring dockerfile: 815B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/php:7-fpm
#3 sha256:df5d13437b1e35f8b9a17144b21a319441fb838984976b6ffdc28394a3994182
#3 DONE 1.3s

#4 [stage-0 1/8] FROM docker.io/library/php:7-fpm@sha256:3ac7c8c74b2b047c7cb273469d74fc0d59b857aa44043e6ea6a0084372811d5b
#4 sha256:3750b19cfb28c3c20a95e9a365407148525e88f5ac696ba1900c620919ef5618
#4 DONE 0.0s

#11 [internal] load build context
#11 sha256:0a0dccc263b4dc040e0299deaadab6e3d44291f81d50d5f5dc26871fd5b4d5ee
#11 DONE 0.0s

#6 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
#6 sha256:7ce23b2be4e42b978d9718a76471522d6fefe5e722ac6d407347d388a335d6b5
#6 DONE 1.2s

#11 [internal] load build context
#11 sha256:0a0dccc263b4dc040e0299deaadab6e3d44291f81d50d5f5dc26871fd5b4d5ee
#11 transferring context: 46.27MB 0.9s done
#11 DONE 0.9s

#8 [stage-0 4/8] RUN chmod +x /usr/local/bin/install-php-extensions     && install-php-extensions curl exif gd gettext mbstring pdo_mysql xdebug zip
#8 sha256:dab097dbc0777c8a5dd19afbe87276dfaca2bdbd8f121d5027d8281669698901
#8 CACHED

#9 [stage-0 5/8] RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&      php composer-setup.php &&     php -r "unlink('composer-setup.php');"
#9 sha256:2d731be0ca200c061a3b8f781c68d4a6dc7c8278a03f1dab672f1bf3fe506398
#9 CACHED

#10 [stage-0 6/8] WORKDIR /var/www/html
#10 sha256:9ebc3c6cbe7011492f742ad14660ef68dbc5ec22f238bbf3e74771d689260844
#10 CACHED

#5 [stage-0 2/8] RUN apt-get update      && apt-get install -y      git      && rm -rf /var/lib/apt/lists/*
#5 sha256:43983f907b5b8e337a03d060cbf6c8c26e0ddfa43579aebac8705e928419bac5
#5 CACHED

#7 [stage-0 3/8] ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
#7 sha256:d908b71be7ae8a969ea7cbaa129d5276776f7ac4e144cb5e883063da4c63750d
#7 CACHED

#12 [stage-0 7/8] COPY ./website .
#12 sha256:89eb3de9f2b55863ac1ee9cee409774cb0f44336321db06e4c234f36660bcd6e
#12 CACHED

#13 [stage-0 8/8] RUN --mount=type=ssh     mkdir -p -m 0600 ~/.ssh      && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts     && php composer.phar install     && php composer.phar require sendgrid/sendgrid
#13 sha256:9f7a0f8708272b18ceff9d25efe0d66d41ced536b25cfe255a22e800bdd57408
#13 0.712 # bitbucket.org:22 SSH-2.0-conker_2627e95aa5 6022d4905084
#13 0.906 # bitbucket.org:22 SSH-2.0-conker_2627e95aa5 1078a409f439
#13 1.290 # bitbucket.org:22 SSH-2.0-conker_2627e95aa5 2f067cf45f15
#13 1.481 # bitbucket.org:22 SSH-2.0-conker_2627e95aa5 8d2e73e8ec9d
#13 1.671 # bitbucket.org:22 SSH-2.0-conker_2627e95aa5 236960224ea9
#13 2.074 Composer plugins have been disabled for safety in this non-interactive session. Set COMPOSER_ALLOW_SUPERUSER=1 if you want to allow plugins to run as root/super user.
#13 2.074 Do not run Composer as root/super user! See https://getcomposer.org/root for details
#13 2.199 Installing dependencies from lock file (including require-dev)
#13 2.207 Verifying lock file contents can be installed on current platform.
#13 2.235 Package operations: 137 installs, 0 updates, 0 removals
#13 2.236 As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.
#13 2.236 This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
#13 2.236 Installing 'unzip' or '7z' (21.01+) may remediate them.
#13 2.237   - Downloading yandex/translate-api (1.5.2)
#13 2.238   - Downloading symfony/deprecation-contracts (v2.5.2)
#13 2.239   - Downloading psr/http-message (1.0.1)
#13 2.239   - Downloading psr/http-client (1.0.1)
#13 2.239   - Downloading ralouphie/getallheaders (3.0.3)
#13 2.240   - Downloading psr/http-factory (1.0.1)
#13 2.240   - Downloading guzzlehttp/psr7 (2.4.3)
#13 2.241   - Downloading guzzlehttp/promises (1.5.2)
#13 2.241   - Downloading guzzlehttp/guzzle (7.5.0)
#13 2.242   - Downloading symfony/polyfill-mbstring (v1.27.0)
#13 2.242   - Downloading stichoza/google-translate-php (v4.1.7)
#13 2.242   - Downloading symfony/polyfill-ctype (v1.27.0)
#13 2.243   - Downloading phpoption/phpoption (1.9.0)
#13 2.243   - Downloading vlucas/phpdotenv (v3.6.10)
#13 2.243   - Downloading symfony/polyfill-php80 (v1.27.0)
#13 2.244   - Downloading symfony/css-selector (v5.4.11)
#13 2.244   - Downloading tijsverkoyen/css-to-inline-styles (2.2.5)
#13 2.244   - Downloading symfony/polyfill-php72 (v1.27.0)
#13 2.244   - Downloading symfony/var-dumper (v4.4.47)
#13 2.245   - Downloading symfony/routing (v4.4.44)
#13 2.245   - Downloading symfony/process (v4.4.44)
#13 2.245   - Downloading symfony/polyfill-php73 (v1.27.0)
#13 2.245   - Downloading symfony/polyfill-intl-normalizer (v1.27.0)
#13 2.246   - Downloading symfony/polyfill-intl-idn (v1.27.0)
#13 2.246   - Downloading symfony/mime (v5.4.16)
#13 2.246   - Downloading symfony/http-foundation (v4.4.49)
#13 2.247   - Downloading symfony/http-client-contracts (v2.5.2)
#13 2.247   - Downloading symfony/event-dispatcher-contracts (v1.1.13)
#13 2.247   - Downloading symfony/event-dispatcher (v4.4.44)
#13 2.248   - Downloading psr/log (1.1.4)
#13 2.248   - Downloading symfony/debug (v4.4.44)
#13 2.248   - Downloading symfony/error-handler (v4.4.44)
#13 2.248   - Downloading symfony/http-kernel (v4.4.49)
#13 2.249   - Downloading symfony/finder (v4.4.44)
#13 2.249   - Downloading psr/container (1.1.2)
#13 2.249   - Downloading symfony/service-contracts (v2.5.2)
#13 2.250   - Downloading symfony/console (v4.4.49)
#13 2.250   - Downloading symfony/polyfill-iconv (v1.27.0)
#13 2.250   - Downloading doctrine/lexer (1.2.3)
#13 2.250   - Downloading egulias/email-validator (2.1.25)
#13 2.251   - Downloading swiftmailer/swiftmailer (v6.3.0)
#13 2.251   - Downloading paragonie/random_compat (v9.99.100)
#13 2.251   - Downloading ramsey/uuid (3.9.6)
#13 2.252   - Downloading psr/simple-cache (1.0.1)
#13 2.252   - Downloading opis/closure (3.6.3)
#13 2.252   - Downloading symfony/translation-contracts (v2.5.2)
#13 2.253   - Downloading symfony/translation (v4.4.47)
#13 2.253   - Downloading nesbot/carbon (2.64.0)
#13 2.253   - Downloading monolog/monolog (1.27.1)
#13 2.254   - Downloading league/mime-type-detection (1.11.0)
#13 2.254   - Downloading league/flysystem (1.1.10)
#13 2.254   - Downloading erusev/parsedown (1.7.4)
#13 2.255   - Downloading dragonmantank/cron-expression (v2.3.1)
#13 2.255   - Downloading doctrine/inflector (1.4.4)
#13 2.255   - Downloading laravel/framework (v5.8.38)
#13 2.256   - Downloading grpc/grpc (1.42.0)
#13 2.256   - Downloading google/protobuf (v3.21.12)
#13 2.256   - Downloading google/longrunning (v0.2.2)
#13 2.257   - Downloading psr/cache (1.0.1)
#13 2.257   - Downloading firebase/php-jwt (v6.3.1)
#13 2.257   - Downloading google/auth (v1.24.0)
#13 2.258   - Downloading google/grpc-gcp (v0.2.1)
#13 2.258   - Downloading google/common-protos (v3.1.0)
#13 2.258   - Downloading google/gax (v1.18.1)
#13 2.258   - Downloading rize/uri-template (0.3.5)
#13 2.259   - Downloading google/cloud-core (v1.48.1)
#13 2.259   - Downloading google/cloud-translate (v1.12.10)
#13 2.259   - Downloading tanmuhittin/laravel-google-translate (2.1.0)
#13 2.260   - Downloading barryvdh/laravel-translation-manager (v0.5.10)
#13 2.260   - Downloading beyondcode/laravel-dump-server (1.3.0)
#13 2.260   - Downloading patchwork/utf8 (v1.3.3)
#13 2.261   - Downloading anahkiasen/underscore-php (2.0.0)
#13 2.261   - Downloading spatie/string (2.2.3)
#13 2.261   - Downloading spatie/laravel-activitylog (3.9.1)
#13 2.261   - Downloading laravelcollective/html (v5.8.1)
#13 2.262   - Downloading appzcoder/crud-generator (v3.3.1)
#13 2.262   - Syncing mydomain/laravel-admin-smartui (dev-master 248a0e3) into cache
#13 6.912 
#13 6.916 In Git.php line 471:
#13 6.916                                                                                
#13 6.917   Failed to execute git clone --mirror -- 'git@bitbucket.org:mydomain/lar  
#13 6.917   avel-admin-smartui.git' '/root/.composer/cache/vcs/git-bitbucket.org-dtw-ap  
#13 6.917   ac-php-laravel-admin-smartui.git/'                                           
#13 6.917                                                                                
#13 6.917   Cloning into bare repository '/root/.composer/cache/vcs/git-bitbucket.org-d  
#13 6.917   tw-apac-php-laravel-admin-smartui.git'...                                    
#13 6.917   Warning: Permanently added the RSA host key for IP address '104.192.141.1'   
#13 6.917   to the list of known hosts.                                                  
#13 6.917   git@bitbucket.org: Permission denied (publickey).                            
#13 6.917   fatal: Could not read from remote repository.                                
#13 6.917                                                                                
#13 6.917   Please make sure you have the correct access rights                          
#13 6.917   and the repository exists.                                                   
#13 6.917                                                                                
#13 6.917 
#13 6.917 install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
#13 6.917 
#13 ERROR: process "/bin/sh -c mkdir -p -m 0600 ~/.ssh      && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts     && php composer.phar install     && php composer.phar require sendgrid/sendgrid" did not complete successfully: exit code: 1
------
 > [stage-0 8/8] RUN --mount=type=ssh     mkdir -p -m 0600 ~/.ssh      && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts     && php composer.phar install     && php composer.phar require sendgrid/sendgrid:
------
process "/bin/sh -c mkdir -p -m 0600 ~/.ssh      && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts     && php composer.phar install     && php composer.phar require sendgrid/sendgrid" did not complete successfully: exit code: 1
exit status 1
thematrixdev commented 1 year ago

It seems there is no --ssh on the build command. Is it a bug?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.