docker build error on PHPIZE_DEPS in dockerfile - docker

I am trying to build my project from a dockerfile. It suddenly stopped working.
I am trying to use an alpine docker image to put my project and live in it.
FROM renokico/laravel-base:octane-latest-php8.0-alpine
COPY ./extra_files/JSON.php ./vendor/siftscience/sift-php/lib/Services_JSON-1.0.3/
COPY ./extra_files/DBSCAN.php ./vendor/php-ai/php-ml/src/Phpml/Clustering/
COPY ./extra_files/File.php ./vendor/kount/kount-ris-php-sdk/src/Kount/SimpleLogger/
COPY . /var/www/html
RUN apk add --update --no-cache libpq
RUN apk add --no-cache --virtual .build-deps
RUN apk add $PHPIZE_DEPS
RUN apk add postgresql-dev
RUN apk add g++ && \
docker-php-ext-install pdo_pgsql pgsql && \
apk del .build-deps
What could be causing this error below ?
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again
later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/community: temporary error (try
again later)
WARNING: Ignoring APKINDEX.40a3604f.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
dpkg (missing):
required by: world[dpkg]
dpkg-dev (missing):
required by: world[dpkg-dev]
re2c (missing):
required by: world[re2c]
The command '/bin/sh -c apk add $PHPIZE_DEPS' returned a non-zero code: 3

Related

unable to select packages liblzma-dev (no such package), libxml-dev (no such package) in golang:1.14.9-alpine docker

I have try to build docker image using golang:1.14.9-alpine, and i always getting below error for installing thus libraries , what i need to do install thus libraies ?
ERROR: unable to select packages:
liblzma-dev (no such package):
required by: world[liblzma-dev]
libxml-dev (no such package):
required by: world[libxml-dev]
below my docker file
FROM golang:1.14.9-alpine
RUN apk update && apk upgrade \
&& apk --no-cache --update add build-base
RUN apk add --no-cache \
alpine-sdk \
protobuf \
ca-certificates \
curl \
make \
libx11-dev \
libxslt-dev \
libxml2 \
gcc \
g++ \
ca-certificates \
libxml-dev \
liblzma-dev \
libxslt-dev
RUN go get github.com/golang/protobuf/proto#v1.4.3
RUN go get github.com/golang/protobuf/protoc-gen-go#v1.4.3
RUN go get github.com/micro/protoc-gen-micro/v2
RUN export GO111MODULE=on
COPY . .
RUN make build
RUN chmod 765 test-service
I think the package is xz-dev
You can try a multistage build and then copy the required executables to alpine version. It will optimize the build further.
You can try something like this:
# Build Stage
FROM golang:1.14.9 as build
...
# Build here
RUN make build
...
# Release stage
FROM alpine:3.13.5 as release
# Copy only the needed files
COPY --from=build <build output> <exec location>
CMD <exec>

What library contains cdefs.h on Alpine?

I am trying to compile some code on a Docker image running Alpine. However, gcc keeps terminating due to fatal error: sys/cdefs.h: No such file or directory. People on Google were saying to do
apt install libc6-dev-i386 gcc-multilib
Which I translated to apk add libc6-dev-i386 gcc-multilib. However, then I just get the error. ERROR: unsatisfiable constraints: for both of the libraries.
My Dockerfile is as follows:
FROM alpine
ADD . .
RUN apk update && apk add gcc make openssl libressl-dev musl-dev && make
ENTRYPOINT ./restrictions-crack "$hash" "$salt"
I ended up finding it, the library is bsd-compat-headers
You might use build-base - this is a meta-package that will install the GCC, libc-dev and binutils packages (amongst others).
Dockerfile:
FROM alpine
ADD . .
RUN apk update && apk add build-base && make
ENTRYPOINT ./restrictions-crack "$hash" "$salt"

Alpine unsatisfiable constraints: missing packages

I am trying to create a docker image based on alpine:3.7, but I get errors while installing some packages with apk add.
Example:
ERROR: unsatisfiable constraints:
apache2-suexec (missing):
required by: world[apache2-suexec-custom]
host (missing):
required by: world[host]
lpr (missing):
required by: world[lpr]
time (missing):
required by: world[time]
The cause is that these packages do not exist in alpine repositories yet. How can I solve these issues? Is there any repository from which I can download them?
I'm using this line
FROM alpine:3.7
RUN apk update \
&& apk upgrade \
&& apk --no-cache add --update tcl apache2 apache2-suexec ca-certificates \
apk-tools curl build-base supervisor lpr time dcron host rsync libxml2-utils libxslt
You have an issue with the following packages: apache2-suexec, host, lpr and time.
Alpine has some other package structure than main Linux OSs:
apache2-suexec is a part of apache2 package;
host is a part of bind-tools package;
lpr is a part of cups-client package;
time is already in alpine image. It uses busybox's time utility.
So, the final Dockerfile is:
FROM alpine:3.7
RUN apk update \
&& apk upgrade \
&& apk --no-cache add --update tcl apache2 ca-certificates \
apk-tools curl build-base supervisor cups-client dcron bind-tools rsync libxml2-utils libxslt

ERROR: unsatisfiable constraints using apk in dockerfile

I'm trying to install postgis into a postgres container.
Dockerfile:
FROM postgres:9.6.4-alpine
RUN apk update \
&& apk add -u postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts \
&& rm -rf /var/lib/apt/lists/*
COPY ./scripts/postgis.sh /docker-entrypoint-initdb.d/postgis.sh
postgis.sh:
#!/bin/sh
for DB in $(psql -t -c "SELECT datname from pg_database where datname = 'backend'"); do
echo "Loading PostGIS extensions into $DB"
"${psql[#]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
EOSQL
done
I got this error:
ERROR: unsatisfiable constraints:
postgresql-9.6-postgis-2.4 (missing):
required by:
world[postgresql-9.6-postgis-2.4]
postgresql-9.6-postgis-2.4-scripts (missing):
required by:
world[postgresql-9.6-postgis-2.4-scripts]
The command '/bin/sh -c apk update && apk add -u postgresql-9.6-postgis-2.4 postgresql-9.6-postgis-2.4-scripts && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 2
I found similar questions such as :
ERROR: unsatisfiable constraints: while installing package in alpine
ERROR: unsatisfiable constraints - on php:7-fpm-alpine
But it doesn't solve my problem.How can I add postgis extension to my postgres container with apk?
Postgis package is only available in edge alpine repo, not in a stable one. That's why you are getting "unsatisfiable constraints" error.
But anyway you can install postgis from edge repo:
# echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
# apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
WARNING: This apk-tools is OLD! Some packages might not function properly.
v3.5.2-254-g9d4623dc57 [http://dl-cdn.alpinelinux.org/alpine/v3.5/main]
v3.5.2-247-gc85efb30e1 [http://dl-cdn.alpinelinux.org/alpine/v3.5/community]
v3.7.0-2163-ge03552fc58 [http://dl-cdn.alpinelinux.org/alpine/edge/testing]
OK: 10930 distinct packages available
# apk search --no-cache postgis
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
WARNING: This apk-tools is OLD! Some packages might not function properly.
postgis-dev-2.4.1-r1
postgis-2.4.1-r1
postgis-doc-2.4.1-r1
So, the final Dockerfile is:
FROM postgres:9.6.4-alpine
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update \
&& apk add -u postgis \
&& rm -rf /var/lib/apt/lists/*
COPY ./scripts/postgis.sh /docker-entrypoint-initdb.d/postgis.sh
UPDATED on January 23th 2020:
Postgis is available in main and community repositories starting from Alpine version 3.11:
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.3
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/ #
/ # apk search --no-cache postgis
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
postgis-3.0.0-r1
postgis-doc-3.0.0-r1
You don't need to use edge repo testing branch for Alpine version 3.11 and later.
Old:
apk add --no-cache curl jq python py-pip
New:
apk add --no-cache curl jq python3 py3-pip
It is weird but in my case solution was as simple as to run:
sudo systemctl restart docker
... on a machine where you running docker containers

ERROR: unsatisfiable constraints - on php:7-fpm-alpine

I'm looking at setting up laravel on an fpm-alpine container. Running into a snag where the below Dockerfile is producing some errors...
FROM php:7-fpm-alpine
# install extensions needed for Laravel
RUN apk --update add \
php7-mysqli \
php7-mcrypt \
php7-mbstring \
rm /var/cache/apk/*
Errors produced are:
Building fpm
Step 1 : FROM php:7-fpm-alpine
---> 9e6811cb8bac
Step 2 : RUN apk --update add php7-mysqli php7-mcrypt php7-mbstring rm /var/cache/apk/*
---> Running in 87364957eb57
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
/var/cache/apk/* (missing):
required by: world[/var/cache/apk/*]
php7-mbstring (missing):
required by: world[php7-mbstring]
php7-mcrypt (missing):
required by: world[php7-mcrypt]
php7-mysqli (missing):
required by: world[php7-mysqli]
rm (missing):
required by: world[rm]
ERROR: Service 'fpm' failed to build: The command '/bin/sh -c apk --update add php7-mysqli php7-mcrypt php7-mbstring rm /var/cache/apk/*' returned a non-zero code: 5
I can search for these package names and find them on the alpine linux web site. Any thoughts on how I can work around this? It's like it's not updating the apt cache... but adding an LS I can see contents there:
Building fpm
Step 1 : FROM php:7-fpm-alpine
---> 9e6811cb8bac
Step 2 : RUN apk update
---> Using cache
---> 9ef09f3aa2a2
Step 3 : RUN ls /var/cache/apk
---> Running in e126a083a306
APKINDEX.5a59b88b.tar.gz
APKINDEX.7c1f02d6.tar.gz
Any ideas on what I can do to resolve this?
Base Docker image probably references an incorrect repository.
Pass over the correct repositories to the apk add command like this:
RUN apk add --update \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
php7-mysqli php7-mcrypt php7-mbstring
I wasn't using docker-php-ext-install which is required when adding working within the container...
FROM php:7-fpm-alpine
# install extensions needed for Laravel
RUN apk update \
&& apk add libmcrypt-dev \
&& docker-php-ext-install mcrypt mysqli pdo_mysql \
&& rm /var/cache/apk/*
I met the same error. Solved it by removing the package version from its name:
https://github.com/docker-library/php/issues/225#issuecomment-220339154
I met the same error, and tried the solution here, found the apk update is crucial.

Resources