moby / moby/buildkit

php build fails when cache is enabled

Open
#1,097 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status/needs-more-info
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

Adding --mount=type=cache,id=apk,sharing=locked,target=/var/cache/apk ln -vs /var/cache/apk /etc/apk/cache && \ to the following Dockerfile, makes it failt to build on linux
Funny enough works fine on macos

#32 9.570 checking for icu-config... no
#32 9.571 checking for location of ICU headers and libraries... not found
#32 9.571 configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
#32 [php70 13/15] RUN --mount=type=cache,id=apk,sharing=locked,target=/var/c...
#32 ERROR: executor failed running [/bin/sh -c apk add --update --virtual .build-deps 	$PHPIZE_DEPS 	&& docker-php-ext-configure bcmath --enable-bcmath 	&& docker-php-ext-configure intl --enable-intl 	&& docker-php-ext-configure pcntl --enable-pcntl 	&& docker-php-ext-configure pdo_mysql --with-pdo-mysql 	&& docker-php-ext-configure mbstring --enable-mbstring 	&& docker-php-ext-configure soap --enable-soap]: exit code: 1
#17 [nginx-base 5/5] RUN --mount=type=cache,id=wheel,sharing=locked,target=/...
#17 CANCELED
# syntax=docker/dockerfile:experimental

FROM php:7.0-fpm-alpine AS php70

WORKDIR /var/www
RUN adduser -DHSu 100 nginx -s /sbin/nologin

COPY ./opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY ./opcache.ini /usr/local/etc/php-fpm.d/opcache.ini

RUN --mount=type=cache,id=apk,sharing=locked,target=/var/cache/apk ln -vs /var/cache/apk /etc/apk/cache && \
	apk add --update --virtual build-dependencies \
	$PHPIZE_DEPS \
	autoconf \
	automake \
	build-base \
	cmake \
	curl-dev \
	file \
	g++ \
	gcc \
	gettext-dev \
	git \
	icu-dev \
	libc-dev \
	libmcrypt-dev \
	libpng-dev \
	libressl-dev \
	libtool \
	libxml2-dev \
	libxslt-dev \
	make \
	nasm \
	pcre-dev \
	pkgconf \
	re2c \
	sqlite-dev \
	wget \
	zlib-dev
# syntax=docker/dockerfile:experimental

FROM php:7.0-fpm-alpine AS php70

WORKDIR /var/www
RUN adduser -DHSu 100 nginx -s /sbin/nologin

COPY ./opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY ./opcache.ini /usr/local/etc/php-fpm.d/opcache.ini

RUN apk add --update --virtual build-dependencies \
	$PHPIZE_DEPS \
	autoconf \
	automake \
	build-base \
	cmake \
	curl-dev \
	file \
	g++ \
	gcc \
	gettext-dev \
	git \
	icu-dev \
	libc-dev \
	libmcrypt-dev \
	libpng-dev \
	libressl-dev \
	libtool \
	libxml2-dev \
	libxslt-dev \
	make \
	nasm \
	pcre-dev \
	pkgconf \
	re2c \
	sqlite-dev \
	wget \
	zlib-dev

macos

Client: Docker Engine - Community
 Version:           19.03.1
 API version:       1.40
 Go version:        go1.12.5
 Git commit:        74b1e89
 Built:             Thu Jul 25 21:18:17 2019
 OS/Arch:           darwin/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.1
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.5
  Git commit:       74b1e89
  Built:            Thu Jul 25 21:17:52 2019
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Ubuntu 19.04

Client: Docker Engine - Community
 Version:           19.03.1
 API version:       1.40
 Go version:        go1.12.5
 Git commit:        74b1e89
 Built:             Thu Jul 25 21:21:22 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.1
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.5
  Git commit:       74b1e89
  Built:            Thu Jul 25 21:19:53 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the provided PHP 7.0 Alpine Dockerfile, first comparing the cache-mounted RUN command with the working command and the listed Docker Engine experimental settings. Investigate the cache-mount handling around apk and ICU detection; done means the Linux build succeeds with the cache enabled without breaking the existing macOS behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, php
Domain
build-system, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.