无法在Bitbucket管道中构建docker映像

时间:2019-04-23 15:00:55

标签: docker bitbucket bitbucket-pipelines

当我尝试为应用程序构建映像时,该映像依赖于buildkit,我收到错误消息:failed to dial gRPC: unable to upgrade to h2c, received 403

我可以构建标准的docker映像,但是如果它依赖Buildkit,则会出错

具体地说,失败的命令是:

docker build --ssh default --no-cache -t worker $BITBUCKET_CLONE_DIR/worker

我的bitbucket-pipelines.yml如下所示,前两个docker build命令起作用,并且生成了映像,但是第三个依赖buildkit的映像不起作用。

image: docker:stable

pipelines:
  default:
    - step:
      name: build
      size: 2x
      script:
         - docker build -t alpine-base $BITBUCKET_CLONE_DIR/supporting/alpine-base
         - docker build -t composer-xv:latest $BITBUCKET_CLONE_DIR/supporting/composer-xv
         - apk add openssh-client
         - eval `ssh-agent`
         - export DOCKER_BUILDKIT=1
         - docker build --ssh default --no-cache -t worker $BITBUCKET_CLONE_DIR/worker
         - docker images

      services:
       - docker
      caches:
       - docker

我的Dockerfile如下:

# syntax=docker/dockerfile:1.0.0-experimental
FROM composer:1.7 as phpdep

COPY application/database/ database/

COPY application/composer.json composer.json
COPY application/composer.lock composer.lock

# Install PHP dependencies in 'vendor'
RUN --mount=type=ssh composer install \
    --ignore-platform-reqs \
    --no-dev \
    --no-interaction \
    --no-plugins \
    --no-scripts \
    --prefer-dist

#
# Final image build stage
#
FROM alpine-base:latest as final

ADD application /app/application
COPY --from=phpdep /app/vendor/ /app/application/vendor/
ADD entrypoint.sh /entrypoint.sh

RUN \
    apk update && \
    apk upgrade && \
    apk add \
        php7 php7-mysqli php7-mcrypt php7-gd \
        php7-curl php7-xml php7-bcmath php7-mbstring \
        php7-zip php7-bz2 ca-certificates php7-openssl php7-zlib \
        php7-bcmath php7-dom php7-json php7-phar php7-pdo_mysql php7-ctype \
        php7-session php7-fileinfo php7-xmlwriter php7-tokenizer php7-soap \
        php7-simplexml && \
    cd /app/application && \
    cp .env.example .env && \
    chown nobody:nobody /app/application/.env && \
    sed -i 's/;openssl.capath=/openssl.capath=\/etc\/ssl\/certs/' /etc/php7/php.ini && \
    sed -i 's/memory_limit = 128M/memory_limit = 1024M/' /etc/php7/php.ini && \
    apk del --purge curl wget && \
    mkdir -p /var/log/workers && \
    mkdir -p /run/php && \
    echo "export PS1='WORKER \h:\w\$ '" >> /etc/profile

COPY files/logrotate.d/ /etc/logrotate.d/

CMD ["/entrypoint.sh"]

0 个答案:

没有答案