Docker Alpine Error: possibly undefined macro: AC_PROG_LIBTOOL - docker

I am trying to create a custom image for building React based project using Alpine as base image.
FROM python:3.6-alpine3.6
ENV NODE_VERSION 8.11.4
RUN addgroup -g 1000 node \
&& adduser -u 1000 -G node -s /bin/sh -D node \
&& apk add --no-cache \
libstdc++ \
&& apk add --no-cache --virtual .build-deps \
binutils-gold \
curl \
g++ \
gcc \
autoconf \
automake \
gnupg \
libtool \ # Was added later based on suggestions I saw online
#libltdl-dev \
libgcc \
libc-dev \
libpng-dev \
linux-headers \
make \
python \
# gpg keys listed at https://github.com/nodejs/node#release-team
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
56730D5401028683275BD23C23EFEFE93C4CFFFE \
77984A986EBC2AA786BC0F66B01FBB92821C587A \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
; do \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
#&& apk del .build-deps \ # Had to disable this otherwise Node project compilation was failing
&& ln -s /usr/share/aclocal /usr/local/share/aclocal \ # Tried linking but seems it's not working
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
ENV YARN_VERSION 1.6.0
RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& mkdir -p /opt \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& apk del .build-deps-yarn
# RUN Install some more tools in one layer
USER node # Had to use this otherwise Node project compilation was failing when running with root user
Now when i build this image and use in my Bitbucket pipeline, i get the following error:
> node lib/install.js
⚠ spawn /opt/atlassian/pipelines/agent/build/node_modules/mozjpeg/vendor/cjpeg ENOENT
⚠ mozjpeg pre-build test failed
ℹ compiling from source
✖ Error: autoreconf -fiv && ./configure --disable-shared --disable-dependency-tracking --with-jpeg8 --prefix="/opt/atlassian/pipelines/agent/build/node_modules/mozjpeg/vendor" --bindir="/opt/atlassian/pipelines/agent/build/node_modules/mozjpeg/vendor" --libdir="/opt/atlassian/pipelines/agent/build/node_modules/mozjpeg/vendor" && make -j8 && make install -j8
Command failed: autoreconf -fiv
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:23: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
Checking online gave me clue that libtool was needed so i added that to the Dockerfile (as you can see above) but i am still getting the same error.
Bitbucket pipeline:
image: my_custom_image
pipelines:
branches:
some_branch:
- step:
name: Deploy
script:
- chmod u+x build.sh && bash ./build.sh
I thought of listing the packages that are installed in the image.
$ cat build.sh
#!/bin/bash
apk info -v | sort
ls -laR /usr/share/aclocal
npm install
npm run build
Output of above command:
g++-6.3.0-r4
gcc-6.3.0-r4
gdbm-1.12-r0
git-2.13.7-r0
gmp-6.1.2-r0
gnupg-2.1.20-r1
isl-0.17.1-r0
libassuan-2.4.3-r0
libatomic-6.3.0-r4
libbz2-1.0.6-r5
libc-dev-0.7.1-r0
libc-utils-0.7.1-r0
libcap-2.25-r1
libcurl-7.61.0-r0
libffi-3.2.1-r3
libgcc-6.3.0-r4
libgcrypt-1.7.10-r0
libgomp-6.3.0-r4
libgpg-error-1.27-r0
libksba-1.3.4-r0
libldap-2.4.44-r5
libpng-1.6.29-r1
libpng-dev-1.6.29-r1
libressl2.5-libcrypto-2.5.5-r2
libressl2.5-libssl-2.5.5-r2
libressl2.5-libtls-2.5.5-r2
libsasl-2.1.26-r10
libssh2-1.8.0-r1
libstdc++-6.3.0-r4
linux-headers-4.4.6-r2
m4-1.4.18-r0
make-4.2.1-r0
mpc1-1.0.3-r0
mpfr3-3.1.5-r0
musl-1.1.16-r14
musl-dev-1.1.16-r14
musl-utils-1.1.16-r14
ncurses-libs-6.0_p20171125-r1
ncurses-terminfo-6.0_p20171125-r1
ncurses-terminfo-base-6.0_p20171125-r1
npth-1.2-r0
openssh-7.5_p1-r2
openssh-client-7.5_p1-r2
openssh-keygen-7.5_p1-r2
openssh-server-7.5_p1-r2
openssh-sftp-server-7.5_p1-r2
pcre-8.41-r0
perl-5.24.4-r1
pinentry-1.0.0-r0
pkgconf-1.3.7-r0
python2-2.7.15-r0
readline-6.3.008-r5
scanelf-1.2.2-r0
sqlite-libs-3.20.1-r2
ssl_client-1.26.2-r11
xz-libs-5.2.3-r0
zlib-1.2.11-r0
zlib-dev-1.2.11-r0
/usr/share/aclocal:
total 32
drwxr-xr-x 2 root root 4096 Sep 3 08:37 .
drwxr-xr-x 1 root root 4096 Sep 3 09:04 ..
-rw-r--r-- 1 root root 368 Oct 19 2017 README
-rw-r--r-- 1 root root 12670 May 20 2017 pkg.m4
I could not find libtool in the package list above. Am i missing something?
Note: Using jessie instead of alpine as base image works but the image size is more. I want to keep it as small as possible.

I was finally able to resolve it. Though i came across this link before, that time i just checked the Contents of package section. Today i again visited libtool's page and finally noticed that there is a Depends section on the right-hand side that mentions two packages as dependency (bash and libltdl) for libtool. Installing both the packages did the trick. :)
UPDATE:
Although my issue was resolved, i thought of cleaning up the script just to ensure i don't end up adding unnecessary packages to my image. That's when i found that my earlier assumption about explicitly adding bash and libltdl packages for fixing libtool dependency was wrong. I am going to write all the issues (and fixes) that i encountered while trying to build my docker image for building React project. It's more of a note for me and might still help someone.
Issues and Fixes:
1) npm WARN lifecycle <project_name>#3.6.0~preinstall: cannot run in wd %s %s (wd=%s) <project_name>#3.6.0 npm run npmcheckversion /opt/atlassian/pipelines/agent/build
Fix: Image was running with root user and not with node user. At the end of my Dockerfile, i added this line:
USER node
What this does is runs the image as the specified user and not as root user.
Ref: https://docs.docker.com/v17.09/engine/reference/builder/#user
2) Error: pngquant failed to build, make sure that libpng-dev is installed
Fix: As mentioned in the error message, i installed package libpng-dev
3) /bin/sh: autoreconf: not found
Fix: To fix this, i installed autoconf and libtool. Please note that libtool automatically installs its dependencies i.e., libltdl and bash.
I checked the list of installed packages and was able to confirm that libtool was actually installed but the build again failed, although with another error.
4) Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
Fix: automake was required to fix the issue. Still, one more error was about to come :)
5) configure: error: no nasm (Netwide Assembler) found
Fix: Installing nasm package fixed it.
That's it. I was ready with my final image. ;)

Related

Laradock how to add package using apk instead of apt-get

I am using Laradock to deploy a Laravel app.
I am facing a problem with generating a PDF file to attach it in an email in a queued job. The pending jobs are handle by the php-worker container.
The problem is that when you want to attach a PDF to an email, which is queued (therefore, handled by the php-worker container) I get the following error:
"sh: /usr/local/bin/wkhtmltopdf: not found
which means that the wkhtmltopdf is not installed in the php-worker container.
So, taking a look at either the php-fpm or workspace Dockerfile, I can see how to install the wkhtmltopdf like so:
#####################################
# wkhtmltopdf:
#####################################
USER root
ARG INSTALL_WKHTMLTOPDF=false
RUN if [ ${INSTALL_WKHTMLTOPDF} = true ]; then \
apt-get install -yqq \
libxrender1 \
libfontconfig1 \
libx11-dev \
libjpeg62 \
libxtst6 \
fontconfig \
libjpeg62-turbo \
xfonts-base \
xfonts-75dpi \
wget \
&& wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb \
&& dpkg -i wkhtmltox_0.12.6-1.stretch_amd64.deb \
&& apt -f install \
;fi
If I copy that installation code into the php-worker container, I get the following error
/bin/sh: apt-get: not found
So, searching further, it seems the php-worker container is Alpine based, and probably needs apk add because of Alpine.
I have tried the following:
#####################################
# wkhtmltopdf:
#####################################
USER root
ARG INSTALL_WKHTMLTOPDF=false
RUN if [ ${INSTALL_WKHTMLTOPDF} = true ]; then \
apk add --no-cache \
libxrender1 \
libfontconfig1 \
libx11-dev \
libjpeg62 \
libxtst6 \
fontconfig \
libjpeg62-turbo \
xfonts-base \
xfonts-75dpi \
wget \
wkhtmltopdf \
;fi
But I haven't got luck.
ERROR: unable to select packages: wkhtmltopdf (no such package): required by: world[wkhtmltopdf]
I have been editing the Dockerfile based on this link and this is what I've modified so far:
Dockerfile
#
#--------------------------------------------------------------------------
# Image Setup
#--------------------------------------------------------------------------
#
ARG LARADOCK_PHP_VERSION
FROM php:${LARADOCK_PHP_VERSION}-alpine3.14
LABEL maintainer="Mahmoud Zalt <mahmoud#zalt.me>"
ARG LARADOCK_PHP_VERSION
# If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
ARG CHANGE_SOURCE=false
RUN if [ ${CHANGE_SOURCE} = true ]; then \
# Change application source from dl-cdn.alpinelinux.org to aliyun source
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
;fi
RUN apk --update add wget \
curl \
git \
build-base \
libmcrypt-dev \
libxml2-dev \
linux-headers \
pcre-dev \
zlib-dev \
autoconf \
cyrus-sasl-dev \
libgsasl-dev \
oniguruma-dev \
libressl \
libressl-dev \
supervisor
# ...................
#####################################
# wkhtmltopdf:
#####################################
USER root
ARG INSTALL_WKHTMLTOPDF=false
RUN set -xe; \
if [ ${INSTALL_WKHTMLTOPDF} = true ]; then \
# Install dependencies for wkhtmltopdf
apk add --update --no-cache --wait 10 \
&& apk --no-cache upgrade \
&& apk add --no-cache \
bash \
libstdc++ \
libx11 \
libxrender \
libxext \
libssl1.1 \
ca-certificates \
fontconfig \
freetype \
ttf-dejavu \
ttf-droid \
ttf-freefont \
ttf-liberation \
xvfb \
#libQt5WebKit \ This throws error. Commented out.
#libQt5WebKitWidgets \ This throws error. Commented out.
#ttf-ubuntu-font-family \ This throws error. Commented out.
&& apk add --update --no-cache --virtual .build-deps \
msttcorefonts-installer \
vim \
\
# Install microsoft fonts
&& update-ms-fonts \
&& fc-cache -f \
\
# Clean up when done
&& rm -rf /tmp/* \
&& apk del .build-deps \
&& wget http://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/wkhtmltopdf-0.12.6-r0.apk \
&& apk add --allow-untrusted wkhtmltopdf-0.12.6-r0.apk \
&& echo 'WKHTMLTOPDF INSTALLED?' \
&& which wkhtmltopdf \
# && ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf \
&& cp /usr/bin/wkhtmltoimage /usr/local/bin/ \
&& cp /usr/bin/wkhtmltopdf /usr/local/bin/ \
&& chmod +x /usr/local/bin/wkhtmltoimage \
&& chmod +x /usr/local/bin/wkhtmltopdf \
&& echo 'wkhtmltopdf version: ' \
&& /usr/local/bin/wkhtmltopdf -V \
&& echo 'whoami & permissions' \
&& whoami \
&& ls -lah /usr/bin/ \
&& ls -lah /usr/local/bin/ \
;fi
#
#-----------------------------
# Set PHP memory_limit to infinity
#-------------------------------
#
RUN echo 'set php memory to -1:' \
&& sed -i 's/memory_limit = .*/memory_limit=-1 /' /usr/local/etc/php/php.ini-production \
&& sed -i 's/memory_limit = .*/memory_limit=-1 /' /usr/local/etc/php/php.ini-development \
&& cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
# ...
Finally, the wkhtmltopdf seems to be installed:
+ apk add --allow-untrusted wkhtmltopdf-0.12.6-r0.apk
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/43) Installing icu-libs (67.1-r2)
(2/43) Installing libpcre2-16 (10.36-r0)
(3/43) Installing qt5-qtbase (5.15.3_git20210406-r0)
(4/43) Installing hicolor-icon-theme (0.17-r1)
(5/43) Installing wayland-libs-server (1.19.0-r0)
(6/43) Installing mesa-gbm (21.1.2-r0)
(7/43) Installing wayland-libs-client (1.19.0-r0)
(8/43) Installing qt5-qtdeclarative (5.15.3_git20210531-r0)
(9/43) Installing libxcomposite (0.4.5-r0)
(10/43) Installing wayland-libs-cursor (1.19.0-r0)
(11/43) Installing wayland-libs-egl (1.19.0-r0)
(12/43) Installing libxkbcommon (1.2.1-r0)
(13/43) Installing qt5-qtwayland (5.15.3_git20210510-r0)
(14/43) Installing mesa-egl (21.1.2-r0)
(15/43) Installing libevdev (1.11.0-r1)
(16/43) Installing mtdev (1.1.6-r0)
(17/43) Installing eudev-libs (3.2.10-r0)
(18/43) Installing libinput-libs (1.18.0-r0)
(19/43) Installing xcb-util-wm (0.4.1-r1)
(20/43) Installing xcb-util (0.4.0-r3)
(21/43) Installing xcb-util-image (0.4.0-r1)
(22/43) Installing xcb-util-keysyms (0.4.0-r1)
(23/43) Installing xcb-util-renderutil (0.3.9-r1)
(24/43) Installing libxkbcommon-x11 (1.2.1-r0)
(25/43) Installing qt5-qtbase-x11 (5.15.3_git20210406-r0)
(26/43) Installing qt5-qtsvg (5.15.3_git20200406-r0)
(27/43) Installing qt5-qtlocation (5.15.3_git20201109-r0)
(28/43) Installing qt5-qtsensors (5.15.3_git20201028-r1)
(29/43) Installing qt5-qtwebchannel (5.15.3_git20201028-r0)
(30/43) Installing libxv (1.0.11-r2)
(31/43) Installing alsa-lib (1.2.5-r2)
(32/43) Installing cdparanoia-libs (10.2-r9)
(33/43) Installing gstreamer (1.18.4-r0)
(34/43) Installing libogg (1.3.5-r0)
(35/43) Installing opus (1.3.1-r1)
(36/43) Installing orc (0.4.32-r0)
(37/43) Installing libtheora (1.1.1-r16)
(38/43) Installing libvorbis (1.3.7-r0)
(39/43) Installing gst-plugins-base (1.18.4-r0)
(40/43) Installing hyphen (2.8.8-r1)
(41/43) Installing libxslt (1.1.35-r0)
(42/43) Installing qt5-qtwebkit (5.212.0_alpha4-r14)
(43/43) Installing wkhtmltopdf (0.12.6-r0)
Executing busybox-1.33.1-r7.trigger
OK: 877 MiB in 254 packages
WKHTMLTOPDF INSTALLED?
+ echo 'WKHTMLTOPDF INSTALLED?'
+ which wkhtmltopdf
/usr/bin/wkhtmltopdf
+ cp /usr/bin/wkhtmltoimage /usr/local/bin/
+ cp /usr/bin/wkhtmltopdf /usr/local/bin/
+ chmod +x /usr/local/bin/wkhtmltoimage
+ chmod +x /usr/local/bin/wkhtmltopdf
+ echo 'wkhtmltopdf version: '
+ /usr/local/bin/wkhtmltopdf -V
wkhtmltopdf version:
wkhtmltopdf 0.12.6
+ echo 'whoami & permissions'
+ whoami
whoami & permissions
root
+ ls -lah /usr/bin/
-rwxr-xr-x 1 root root 979 Jun 1 2021 supervisorctl
-rwxr-xr-x 1 root root 975 Jun 1 2021 supervisord
-rwxr-xr-x 1 root root 114.1K Jun 11 2020 wkhtmltoimage
-rwxr-xr-x 1 root root 162.1K Jun 11 2020 wkhtmltopdf
+ ls -lah /usr/local/bin/
-rwxr-xr-x 1 root root 114.1K May 25 16:37 wkhtmltoimage
-rwxr-xr-x 1 root root 162.1K May 25 16:37 wkhtmltopdf
Step 82/86 : COPY supervisord.conf /etc/supervisord.conf
---> de059f102569
Step 83/86 : ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
BUT when I try to execute the container to verify that the wkhtmltopdf is indeed installed,
❯ docker container exec php-worker /usr/local/bin/wkhtmltopdf -V ─╯
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "/usr/local/bin/wkhtmltopdf": stat /usr/local/bin/wkhtmltopdf: no such file or directory: unknown
turns out that it's not been installed! And therefore, I get the exact same error in my application:
"sh: /usr/local/bin/wkhtmltopdf: not found
And, on the other hand, for example, the supervisor does work:
❯ docker container exec php-worker supervisorctl ─╯
laravel-scheduler:laravel-scheduler_00 RUNNING pid 52576, uptime 18:27:24
laravel-worker:laravel-worker_00 RUNNING pid 52577, uptime 18:27:24
supervisor>
Does anybody know how to install wkhtmltopdf in Alpine Dockerfile for real?
The PHP images you're using are built on Alpine 3.15; it looks like wkhtmltopdf isn't package in that version of Alpine:
$ docker run --rm alpine:3.15 sh -c 'apk add --update wkhtmltopdf'
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
ERROR: unable to select packages:
wkhtmltopdf (no such package):
required by: world[wkhtmltopdf]
It looks like wkhtmltopdf is only available in 3.14 and earlier (I
checked 3.14 and 3.13):
$ docker run --rm alpine:3.14 sh -c 'apk add --update wkhtmltopdf'
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/103) Installing dbus-libs (1.12.20-r2)
(2/103) Installing libgcc (10.3.1_git20210424-r2)
[...]
(103/103) Installing wkhtmltopdf (0.12.6-r0)
Executing busybox-1.33.1-r7.trigger
OK: 196 MiB in 117 packages
This is noted in the release notes for 3.15, which say:
QtWebKit was removed due to lack of upstream support
qt5-qtwebkit, kdewebkit, wkhtmltopdf, and py3-pdfkit have been removed due to known vulnerabilities and lack of upstream support for qtwebkit. Other programs have been adjusted to use qt5-qtwebengine where appropriate. The most direct replacement for wkhtmltopdf is weasyprint, which is available in the Alpine Linux community repository. puppeteer and pandoc are also options, depending on your needs. See #12888 for more information.
You could dry building your own PHP base image on top of an older Alpine release using the upstream Dockerfile, or you could try starting with the vanilla alpine:3.14 image and installing php using apk.
Or just stick with an Ubuntu-based image, which still packages
wkhtmltopdf.

Failed to get jdk (jdk-8u301-linux-x64.tar.gz) on alpine:3.8

I'm trying to build the image which was built in the past but failing this time as it is failing to download Oracle JDK, it downloads the tar with just a 4 KB file.
I have referred this Docker alpine + oracle java: cannot find java already and tried with the latest version of glibc but no luck.
I'm though able to install the lower version than jdk-8u201.
Any suggestion is appreciated! I have to go with alpine:3.8 only.
FROM alpine:3.8
RUN apk upgrade --update && \
apk add --update curl ca-certificates bash && \
for pkg in glibc-2.23-r1 glibc-bin-2.23-r1 glibc-i18n-2.23-r1; do curl -sSL https://github.com/andyshinn/alpine-pkg-glibc/releases/download/2.23-r1/${pkg}.apk -o /tmp/${pkg}.apk; done && \
apk add --allow-untrusted /tmp/*.apk && \
rm -v /tmp/*.apk && \
mkdir -p /opt/springboot/apps/ && \
( /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true ) && \
echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/java.tar.gz \
https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz && \
gunzip /tmp/java.tar.gz

Docker: Error: Unable to access jarfile lib/sonar-application-7.6.jar

Upon creating a container using docker-run after creating an image using Dockerfile for SonarQube-7.6, I am getting this error after running docker logs <container-name>
Error: Unable to access jarfile lib/sonar-application-7.6.jar
I think the user permission is incorrect but not sure where am I going wrong.
My Dockerfile:
FROM openjdk:8
ENV SONAR_VERSION=7.6 \
SONARQUBE_HOME=/opt/sonarqube \
# Database configuration
# Defaults to using H2
# DEPRECATED. Use -v sonar.jdbc.username=... instead
# Drop these in the next release, also in the run script
SONARQUBE_JDBC_USERNAME=sonar \
SONARQUBE_JDBC_PASSWORD=sonar \
SONARQUBE_JDBC_URL=
# Http port
EXPOSE 9000
RUN groupadd -r sonarqube && useradd -r -g sonarqube sonarqube
# grab gosu for easy step-down from root
RUN set -x \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
|| gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4) \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
RUN set -x \
# pub 2048R/D26468DE 2015-05-25
# Key fingerprint = F118 2E81 C792 9289 21DB CAB4 CFCA 4A29 D264 68DE
# uid sonarsource_deployer (Sonarsource Deployer) <infra#sonarsource.com>
# sub 2048R/06855C1D 2015-05-25
&& (gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE \
|| gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys F1182E81C792928921DBCAB4CFCA4A29D26468DE) \
&& cd /opt \
&& curl -o sonarqube.zip -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip \
&& curl -o sonarqube.zip.asc -fSL https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip.asc \
&& gpg --batch --verify sonarqube.zip.asc sonarqube.zip \
&& unzip sonarqube.zip \
&& mv sonarqube-$SONAR_VERSION sonarqube \
&& chown -R sonarqube:sonarqube sonarqube \
&& rm sonarqube.zip* \
&& rm -rf $SONARQUBE_HOME/bin/*
VOLUME "$SONARQUBE_HOME/data"
WORKDIR $SONARQUBE_HOME
COPY run.sh $SONARQUBE_HOME/bin/
USER sonarqube
ENTRYPOINT ["./bin/run.sh"]
I solved this problem, it was a user permission error, in line:
chown -R sonarqube:sonarqube sonarqube
Used a different home path, SONARQUBE_HOME= /xyz
for setting the user permission, I used:
chown -R sonarqube:sonarqube xyz
Replaced this with,
chown -R sonarqube:sonarqube /xyz
It worked for me!!!!!

Unable to install vscode-ripgrep on Docker: Unexpected token "..." in "...url.parse(_url)"

I need to setup a theia environment on Docker (ubuntu 18.04 container). During the installation using the docker file, I need to install vscode-ripgrep since it is a dependency for 2 theia modules:
#theia/file-search
#theia/search-in-workspace
However, I get the following error:
I went through multiple issues on GitHub and StackOverflow, but cannot find one that will fix my problem.
I also tried to install vscode-ripgrep on my host machine (also ubuntu) and it worked. I guess I am missing some dependencies in the Dockerfile. However, I went through theia's GitHub page and installed all the common dependencies (https://github.com/theia-ide/theia-apps/blob/master/theia-full-docker/Dockerfile).
The previous OS kernel lab teacher used the exact Dockerfile and it did work about 3-4 months ago. I guess that dependencies changes made a breaking change.
Here is the Dockerfile that I have:
FROM ubuntu:18.04
RUN rm /etc/dpkg/dpkg.cfg.d/excludes
RUN apt-get update
RUN apt-get install -y curl binutils python make build-essential \
man manpages-posix manpages-posix-dev glibc-doc \
python3 less locales libx11-dev libxkbfile-dev snapd
RUN apt-get update && apt-get -y install curl xz-utils wget gpg
#Install node and yarn
#From: https://github.com/nodejs/docker-node/blob/6b8d86d6ad59e0d1e7a94cec2e909cad137a028f/8/Dockerfile
# gpg keys listed at https://github.com/nodejs/node#release-keys
RUN set -ex \
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
B9E2F5981AA6E0CD28160D9FF13993A75599653C \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
77984A986EBC2AA786BC0F66B01FBB92821C587A \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
; do \
gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --batch --keyserver pool.sks-keyservers.net --recv-keys "$key" || \
gpg --batch --keyserver pgp.mit.edu --recv-keys "$key" || \
gpg --batch --keyserver keyserver.pgp.com --recv-keys "$key" || \
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \
done
ARG NODE_VERSION=8.0.0
ENV NODE_VERSION $NODE_VERSION
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv7l';; \
i386) ARCH='x86';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
ENV YARN_VERSION 1.13.0
RUN set -ex \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --batch --keyserver pool.sks-keyservers.net --recv-keys "$key" || \
gpg --batch --keyserver pgp.mit.edu --recv-keys "$key" || \
gpg --batch --keyserver keyserver.pgp.com --recv-keys "$key" || \
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \
done \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& mkdir -p /opt/yarn \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz
#Developer tools
## Git and sudo (sudo needed for user override)
RUN apt-get -y install git sudo
RUN locale-gen fr_CA.UTF-8
RUN update-locale LANG=fr_CA.UTF-8
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 8.0.0
SHELL ["/bin/bash", "-c"]
ENV SHELL /bin/bash
ENV PAGER less
# Install nvm with node and npm
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash \
&& source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
RUN npm install -g yarn
# Create fake clangd
RUN ln -s /bin/false /usr/bin/clangd
# Create user directory
RUN useradd -u 3000 --create-home student
RUN npm install vscode-ripgrep
COPY package.json package.json
# Switch to new user
WORKDIR /home/student
USER student
# Build Theia
RUN yarn install
RUN yarn && yarn theia build
# Create Theia directory and change cd alias
RUN echo "alias cd='HOME=~/workspace cd'" >> .bashrc
# Let's try to reduce memory footprint...
CMD yarn theia start workspace --hostname 0.0.0.0 --port 3000
Thanks for the help and have a nice day!
Vittorio

Using PGP to verify GDB in an Alpine container

I have compiled information from GNU.org, blogs and other SO posts, but I am missing a key component to properly validate the version of GDB I'm downloading into my container.
# Install GNU GDB
RUN ["/bin/ash","-c","\
mkdir gdb-build \
&& cd gdb-build \
&& wget https://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz \
&& wget https://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz.sig \
&& gpg --import https://ftp.gnu.org/gnu/gnu-keyring.gpg \
&& gpg --verify --keyring ./gnu-keyring.gpg gdb-8.1.tar.xz.sig \
&& tar -xvf gdb-8.1.tar.xz \
&& cd gdb-8.1 \
&& ./configure --prefix=/usr \
&& make \
&& make -C gdb install \
&& cd .. \
&& rm -rf gdb-build/ \
"]
The output looks like this:
...
2018-03-10 18:04:52 (5.92 MB/s) - 'gdb-8.1.tar.xz' saved [20095080/20095080]
--2018-03-10 18:04:52-- https://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz.sig
Resolving ftp.gnu.org... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org|208.118.235.20|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 72 [application/pgp-signature]
Saving to: 'gdb-8.1.tar.xz.sig'
0K 100% 1.27M=0s
2018-03-10 18:04:52 (1.27 MB/s) - 'gdb-8.1.tar.xz.sig' saved [72/72]
gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: can't open 'https://ftp.gnu.org/gnu/gnu-keyring.gpg': No such file or directory
gpg: Total number processed: 0
What step am I missing? How do appropriately configure GnuPG to access the keys?
The correct syntax of gpg command is:
Syntax: gpg [options] [files]
Sign, check, encrypt or decrypt
Default operation depends on the input data
A command gpg --import requires file, not a link, so gnu-keyring.gpg should be downloaded before the gpg command.
The correct part of Dockerfile is:
RUN ["/bin/ash","-c","\
mkdir gdb-build \
&& cd gdb-build \
&& wget https://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz \
&& wget https://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz.sig \
&& wget https://ftp.gnu.org/gnu/gnu-keyring.gpg \
&& gpg --import ./gnu-keyring.gpg \
&& gpg --verify --keyring ./gnu-keyring.gpg gdb-8.1.tar.xz.sig \
&& tar -xvf gdb-8.1.tar.xz \
&& cd gdb-8.1 \
&& ./configure --prefix=/usr \
&& make \
&& make -C gdb install \
&& cd .. \
&& rm -rf gdb-build/ \
"]

Resources