IzakMarais / reporter

Service that generates a PDF report from a Grafana dashboard
Apache License 2.0
946 stars 304 forks source link

Unable to build image using Dockerfile getting error: libswitch-perl (no such package) #322

Closed ChinmoyPadhi closed 2 years ago

ChinmoyPadhi commented 2 years ago

Hi, I'm trying to build image using Dockerfile in my VM. Following error I encountered:

$ docker build -t reporter-2.3.1 .
Sending build context to Docker daemon  18.48MB
Step 1/10 : FROM golang:1.14.7-alpine3.12 AS build
1.14.7-alpine3.12: Pulling from library/golang
df20fa9351a1: Pull complete
ed8968b2872e: Pull complete
a92cc7c5fd73: Pull complete
628f3eafb14e: Pull complete
4c45347fed5d: Pull complete
Digest: sha256:680a1ec90372b08a26c2bab408014fc4b5236a91dc701a1bf784d3c64f11d964
Status: Downloaded newer image for golang:1.14.7-alpine3.12
 ---> cf2ff089aa2c
Step 2/10 : WORKDIR /go/src/${owner:-github.com/IzakMarais}/reporter
 ---> Running in d1b1e370fc21
Removing intermediate container d1b1e370fc21
 ---> 24f0b0484f4c
Step 3/10 : RUN apk update && apk add make git
 ---> Running in 45f48ce57ae4
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
v3.12.12-1-g84af326f95 [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.10-17-g0c8862530f [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12775 distinct packages available
(1/6) Installing nghttp2-libs (1.41.0-r0)
(2/6) Installing libcurl (7.79.1-r0)
(3/6) Installing expat (2.2.10-r4)
(4/6) Installing pcre2 (10.35-r0)
(5/6) Installing git (2.26.3-r1)
(6/6) Installing make (4.3-r0)
Executing busybox-1.31.1-r16.trigger
OK: 22 MiB in 21 packages
Removing intermediate container 45f48ce57ae4
 ---> 3c182e883948
Step 4/10 : ADD . .
 ---> 5786bba357cd
Step 5/10 : RUN make build
 ---> Running in ec45ff839cf4
go install -v github.com/IzakMarais/reporter/cmd/grafana-reporter
github.com/IzakMarais/reporter/vendor/github.com/pborman/uuid
github.com/IzakMarais/reporter/grafana
github.com/IzakMarais/reporter/vendor/github.com/gorilla/mux
github.com/IzakMarais/reporter/report
github.com/IzakMarais/reporter/cmd/grafana-reporter
Removing intermediate container ec45ff839cf4
 ---> c2954b7506dd
Step 6/10 : FROM alpine:3.12
3.12: Pulling from library/alpine
1b7ca6aea1dd: Pull complete
Digest: sha256:c75ac27b49326926b803b9ed43bf088bc220d22556de1bc5f72d742c91398f69
Status: Downloaded newer image for alpine:3.12
 ---> 24c8ece58a1a
Step 7/10 : COPY util/texlive.profile /
 ---> 1fa92e50509f
Step 8/10 : RUN PACKAGES="wget libswitch-perl"         && apk update         && apk add $PACKAGES         && apk add ca-certificates         && wget -qO-           "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" |           sh -s - --admin --no-path         && mv ~/.TinyTeX /opt/TinyTeX         && /opt/TinyTeX/bin/*/tlmgr path add         && tlmgr path add         && chown -R root:adm /opt/TinyTeX         && chmod -R g+w /opt/TinyTeX         && chmod -R g+wx /opt/TinyTeX/bin         && tlmgr install epstopdf-pkg         && apk del --purge -qq $PACKAGES         && apk del --purge -qq         && rm -rf /var/lib/apt/lists/*
 ---> Running in f289cf796fd4
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
v3.12.12-1-g84af326f95 [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.10-17-g0c8862530f [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12763 distinct packages available
  libswitch-perl (no such package):
ERROR: unable to select packages:
    required by: world[libswitch-perl]
The command '/bin/sh -c PACKAGES="wget libswitch-perl"         && apk update         && apk add $PACKAGES         && apk add ca-certificates         && wget -qO-           "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" |           sh -s - --admin --no-path         && mv ~/.TinyTeX /opt/TinyTeX         && /opt/TinyTeX/bin/*/tlmgr path add         && tlmgr path add         && chown -R root:adm /opt/TinyTeX         && chmod -R g+w /opt/TinyTeX         && chmod -R g+wx /opt/TinyTeX/bin         && tlmgr install epstopdf-pkg         && apk del --purge -qq $PACKAGES         && apk del --purge -qq         && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1
OS: Linux
Variant: Redhat 7.7
$ docker version
Client: Docker Engine - Community
 Version:           19.03.4
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.10
 Git commit:        9013bf583a
 Built:             Fri Oct 18 15:52:22 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 03:47:25 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Please suggest how this error can be resolved.

ChinmoyPadhi commented 2 years ago

@AKhares: I tried to run the above command but its still failing. I made a small change instead of libswitch-perl which is from Debian package, I modified that to perl-switch which is from alpine package, it does got executed but getting the following error mv: can't rename '/root/.TinyTeX': No such file or directory also does this path https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh present in github any longer

$ docker build -t reporter-2.3.1 .
Sending build context to Docker daemon  18.48MB
Step 1/10 : FROM golang:1.14.7-alpine3.12 AS build
 ---> cf2ff089aa2c
Step 2/10 : WORKDIR /go/src/${owner:-github.com/IzakMarais}/reporter
 ---> Using cache
 ---> 24f0b0484f4c
Step 3/10 : RUN apk update && apk add make git
 ---> Using cache
 ---> 3c182e883948
Step 4/10 : ADD . .
 ---> e7f8399b7ea9
Step 5/10 : RUN make build
 ---> Running in bbf7fe28be76
go install -v github.com/IzakMarais/reporter/cmd/grafana-reporter
github.com/IzakMarais/reporter/vendor/github.com/pborman/uuid
github.com/IzakMarais/reporter/grafana
github.com/IzakMarais/reporter/vendor/github.com/gorilla/mux
github.com/IzakMarais/reporter/report
github.com/IzakMarais/reporter/cmd/grafana-reporter
Removing intermediate container bbf7fe28be76
 ---> c76a5ebf76d4
Step 6/10 : FROM alpine:3.12
 ---> 24c8ece58a1a
Step 7/10 : COPY util/texlive.profile /
 ---> Using cache
 ---> 1fa92e50509f
Step 8/10 : RUN PACKAGES="wget perl-switch"         && apk update         && apk add $PACKAGES         && apk add ca-certificates         && wget -qO-           "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" |           sh -s - --admin --no-path         && mv ~/.TinyTeX /opt/TinyTeX         && /opt/TinyTeX/bin/*/tlmgr path add         && tlmgr path add         && chown -R root:adm /opt/TinyTeX         && chmod -R g+w /opt/TinyTeX         && chmod -R g+wx /opt/TinyTeX/bin         && tlmgr install epstopdf-pkg         && apk del --purge -qq $PACKAGES         && apk del --purge -qq         && rm -rf /var/lib/apt/lists/*
 ---> Running in 9198cb7aec09
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
v3.12.12-12-ge5a8c3fe70 [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.10-17-g0c8862530f [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12763 distinct packages available
(1/6) Installing libbz2 (1.0.8-r1)
(2/6) Installing perl (5.30.3-r0)
(3/6) Installing perl-switch (2.17-r1)
(4/6) Installing libunistring (0.9.10-r0)
(5/6) Installing libidn2 (2.3.0-r0)
(6/6) Installing wget (1.20.3-r1)
Executing busybox-1.31.1-r22.trigger
OK: 45 MiB in 20 packages
(1/1) Installing ca-certificates (20211220-r0)
Executing busybox-1.31.1-r22.trigger
Executing ca-certificates-20211220-r0.trigger
OK: 45 MiB in 21 packages
mv: can't rename '/root/.TinyTeX': No such file or directory
The command '/bin/sh -c PACKAGES="wget perl-switch"         && apk update         && apk add $PACKAGES         && apk add ca-certificates         && wget -qO-           "https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" |           sh -s - --admin --no-path         && mv ~/.TinyTeX /opt/TinyTeX         && /opt/TinyTeX/bin/*/tlmgr path add         && tlmgr path add         && chown -R root:adm /opt/TinyTeX         && chmod -R g+w /opt/TinyTeX         && chmod -R g+wx /opt/TinyTeX/bin         && tlmgr install epstopdf-pkg         && apk del --purge -qq $PACKAGES         && apk del --purge -qq         && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1

Please help me to resolve the above issue

ChinmoyPadhi commented 2 years ago

The Dockerfile has been updated to build the image, I have added perl-switch, fontconfig alpine packages and also the github url has been updated to https://raw.githubusercontent.com/yihui/tinytex/main/tools/install-unx.sh. after these changes I'm able to build the image

# build
FROM golang:1.14.7-alpine3.12 AS build
WORKDIR /go/src/${owner:-github.com/IzakMarais}/reporter
RUN apk update && apk add make git
ADD . .
RUN make build

# create image
FROM alpine:3.12
COPY util/texlive.profile /

RUN PACKAGES="wget perl-switch" \
        && apk update \
        && apk add $PACKAGES \
        && apk add fontconfig \
        && apk add ca-certificates \
        && wget -qO- \
          "https://raw.githubusercontent.com/yihui/tinytex/main/tools/install-unx.sh" | \
          sh -s - --admin --no-path \
        && mv ~/.TinyTeX /opt/TinyTeX \
        && /opt/TinyTeX/bin/*/tlmgr path add \
        && tlmgr path add \
        && chown -R root:adm /opt/TinyTeX \
        && chmod -R g+w /opt/TinyTeX \
        && chmod -R g+wx /opt/TinyTeX/bin \
        && tlmgr install epstopdf-pkg \
        # Cleanup
        && apk del --purge -qq $PACKAGES \
        && apk del --purge -qq \
        && rm -rf /var/lib/apt/lists/*

COPY --from=build /go/bin/grafana-reporter /usr/local/bin
ENTRYPOINT [ "/usr/local/bin/grafana-reporter" ]
AKhares commented 2 years ago

Thanks @ChinmoyPadhi for looking into it. Can you please raise a PR to @IzakMarais and get it merged.

perezale commented 2 years ago

Verified! it's working for me. Thanks!!!. I see this repo has no movement. Still, it would be nice to have to contribution added.