Docker: Alpine linux community package not found - docker

I am trying to create a container with the following Dockerfile:
FROM python:3.6-alpine
RUN apk add --update alpine-sdk make gcc python3-dev python-dev libxslt-dev \
libxml2-dev libc-dev openssl-dev libffi-dev zlib-dev py-pip openssh \
py3-lxml#main py3-numpy#community \
mariadb-dev libjpeg-dev zlib1g-dev && rm -rf /var/cache/apk/*
I added py3-lxml#main and py3-numpy#community based on this advice as building wheel for numpy and lxml takes ages.
I have used the package names as specified on the official Alpine repo page, but I get the following error:
WARNING: The repository tag for world dependency 'py3-lxml#main' does not exist
WARNING: The repository tag for world dependency 'py3-numpy#community' does not exist*
Why is that and how can I get those packages?

In order to fix this problem in specific:
WARNING: The repository tag for world dependency 'py3-lxml#main' does not exist
WARNING: The repository tag for world dependency 'py3-numpy#community' does not exist
You need to update the repositories file which is in here /etc/apk/repositories
to the following unless you want to remove the #community and #main tags from the apk add command as they are not written by default in the repositories file:
#main http://dl-cdn.alpinelinux.org/alpine/v3.9/main
#community http://dl-cdn.alpinelinux.org/alpine/v3.9/community
And don't forget to COPY it the content to /etc/apk/repositories

Related

Missing libkml required by gdal-3.3.0-r5

I have a Python project with Docker that uses gdal package. For pretty long time everything were ok, but now I get an error while building an image:
My Dockerfile:
FROM python:3.6.8-alpine3.10
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
ADD requirements.txt /app/
RUN apk update && \
apk add \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
geos gdal gdal-dev geos-dev proj-dev && \
apk add gcc linux-headers musl musl-dev postgresql-dev gdal gdal-dev \
geos-dev proj-dev zlib-dev jpeg-dev \
libpng libpng-dev uriparser-dev
RUN pip install -r requirements.txt
ADD . /app/
Do anyone know a solution to the problem?
I don't know the old status, but if you search gdal in official package system now, you will find nothing:
But, with alpine3.11, you could see next:
So, I guess gdal has been deleted from alpine3.10 official repo, you may have to build it from source code by yourself if you insist work on alpine3.10 or directly update your base to python:3.6-alpine3.11.

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>

Alpine ERROR: unsatisfiable constraints: py3-pandas (missing):

I have the following dockerfile:
FROM alpine:latest
ADD crontab.txt /crontab.txt
ADD script.sh /script.sh
COPY entry.sh /entry.sh
ADD app /app
RUN chmod 755 /script.sh /entry.sh
RUN /usr/bin/crontab /crontab.txt
# install dependencies
# the lapack package is only in the community repository
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk update \
&& apk add --no-cache python3 py-pip py3-setuptools python-dev py3-lxml py3-requests py3-numpy py3-cssselect py3-pandas
RUN apk --update add --no-cache \
lapack-dev \
gcc \
freetype-dev
# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
gfortran \
musl-dev \
g++
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
#RUN pip3 install cython
RUN pip3 install pymongo xlrd
CMD ["/entry.sh"]
when I try to build the dockerfile, I received the error saying that py3-pandas (missing).
I am wondering whether that's the Alpine package management issue.
I can reproduce your issue by doing just:
FROM alpine:latest
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk update \
&& apk add --no-cache py3-pandas
Some comments here:
If you are going to use the edge/testing packages repository already, then you would be better using the alpine:edge image, although I would not advise this for a production server, of course
Using another package repository than the default one on apk can be done on a one run basis using the option
-X, --repository REPO Use packages from REPO
From apk --help
The package python-dev does not exist in the edge/testing repository, you should use python3-dev
Important disclaimer: this solution does involve using the testing repository and the edge rolling release branch of Alpine, and is thus not recommended for production use.
So, in the end, all your dependencies can be installed doing:
FROM alpine:edge
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
py-pip \
py3-setuptools \
python3-dev \
py3-lxml \
py3-requests \
py3-numpy \
py3-cssselect \
py3-pandas \
lapack-dev \
gcc \
freetype-dev
Note that I didn't add the build dependancies there, as they don't seems to be related to your issue at hand
Don't use alpine images for python; there's too many issues. Use a something like python:slim-buster. You can then just install your requirements with:
FROM python:3.8.4-slim-buster
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

What package should I install instead of libpcre++-dev to use C code in Alpine Golang?

I have a Golang program inside a docker container (I use Ubuntu 18). Also I use github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre for regex in my Golang app. Before using this library I should install libpcre++-dev this way:
sudo apt-get install libpcre++-dev
But I use golang:alpine in my Dockerfile and this is no libpcre++-dev library in alpine packages.
What package should I install instead of libpcre++-dev?
p.s. I have tried to install libc6-compat, pcre pcre-dev, libpcrecpp but I see this error:
github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre
/go/pkg/mod/github.com/glenn-brown/golang-pkg-pcre#v0.0.0-20120522223659-48bb82a8b8ce/src/pkg/pcre/pcre.go:52:10:
fatal error: pcre.h: No such file or directory #include
^~~~~~~~ compilation terminated
My Dockerfile:
FROM golang:alpine
RUN apk update
RUN apk upgrade
RUN apk add --update --no-cache build-base gcc g++ pcre pcre-dev libc6-compat
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache curl git ca-certificates tzdata \
&& update-ca-certificates 2> /dev/null || true
I build my app this way:
- CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/backend ./cmd/backend/main.go
EDIT
I have change my Dockerfile (add line below)
RUN apk add --update --no-cache build-base gcc g++ pcre pcre-dev libc6-compat
And now I have a new error:
Error loading shared library libpcre.so.1: No such file or directory
(needed by /bin/backend)
You can try one of these, as both package
RUN apk add --virtual build-dependencies
RUn apk add --no-cache build-base gcc
build-essential is a metapackage (a package that installs many other
packages, like g++ and gcc: the GNU C & C++ compilers).
Or you can install the alpine sdk.
You can start with alpine-sdk, which is a "metapackage that pulls in
the most essential packages used to build new packages."
http://wiki.alpinelinux.org/wiki/Developer_Documentation has more
info.
RUN apk add --update alpine-sdk
docker-alpine-issues-24
Or you can use golang:latest which will work fine.
FROM golang:latest
RUN apt-get update
RUN apt-get install libpcre++-dev -y
You can use one of the Debian-based golang images instead. By the time you're installing GNU libc and a full C toolchain on top of this anyways, there's not really going to be much space savings over the Alpine base image. You can (and should) use a multi-stage build where the final image just contains your compiled binary, and that can use an Alpine base.
The result would look something like:
# Build-time image; just has the parts needed to run `go build`
FROM golang:1.12-buster AS build
# Install additional build-time tools
RUN apt-get update \
&& apt-get install --assume-yes \
build-essential ca-certificates git-core tzdata \
libpcre++-dev
# Build your application
WORKDIR /app
COPY . .
ENV GO111MODULE=on
RUN go build -o myapp ./cmd/myapp
# Runtime image; has only what we need to run the application
FROM alpine:3.10
# Note that you'll need the shared library for libpcre++
RUN apk add ca-certificates tzdata libpcrepp
COPY --from=build /app/myapp /usr/bin/myapp
CMD ["myapp"]

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"

Resources