I have a problem with compilation Thrift in docker container with alpine 3.8
FROM alpine:3.8
RUN apk add --update --no-cache \
libstdc++ \
libgcc \
libevent \
composer \
tar \
git \
bash \
nginx
RUN apk add --update --no-cache php7-dev boost-dev autoconf openssl-dev automake make libtool bison flex g++ && \
cd /tmp && wget https://github.com/apache/thrift/archive/0.11.0.zip -O thrift.zip && unzip thrift.zip && cd thrift-0.11.0 && \
./bootstrap.sh && ./configure --with-openssl=/usr/include/openssl --without-ruby --disable-tests --without-php_extension --without-python --without-haskell --without-java --without-perl --without-php --without-py3 --without-erlang && make && make install && \
cd /tmp/thrift-0.11.0/lib/php/src/ext/thrift_protocol && phpize && ./configure && make && \
echo 'extension=thrift_protocol.so' >> /etc/php7/conf.d/thrift_protocol.ini && \
apk del --update --no-cache php7-dev boost-dev autoconf openssl-dev automake make libtool bison flex g++ && \
rm -rf /tmp/*
after compile bin file has size around 50MB
-rwxr-xr-x 1 root root 55566368 Sep 5 10:05 thrift
for example bin file after compile on Mac OSX
4.2M Sep 4 17:37 thrift
By default, configure && make will cause Thrift to be built with debug symbols, which is the major reason for binary bloating.
For building a more compact and optimized thrift binary, replace:
configure
With:
configure CFLAGS="-s -O2" CXXFLAGS="-s -O2"
The -s compiler option will cause debug information to be stripped away from generated objects.
The -O2 compiler option will enable common compiler optimizations, which should improve thrift performance considerably.
More information:
https://thrift.apache.org/docs/BuildingFromSource
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Related
I currently have a project I'm working on where the version of pdftotext from poppler-utils is using the "testing" version (found here https://manpages.debian.org/testing/poppler-utils/pdftotext.1.en.html). Instead, I want to use the version "experimental" by updating the debian image in the dockerfile (trying to avoid conflicts with other items). Is there a simple way to do this or is this not feasible?
As usual, I figured out the solution. I got some data from this post that provided some good insight on the commands. I had to update to the version that would work with my bot base but got it all figured out.
Installing Poppler utils of version 0.82 in docker
Leaving this here in case someone else encounters something similar.
FROM python:3.8-slim-buster
RUN apt-get update && apt-get install wget build-essential cmake libfreetype6-dev
pkg-config libfontconfig-dev libjpeg-dev libopenjp2-7-dev -y
RUN wget https://poppler.freedesktop.org/poppler-data-0.4.9.tar.gz \
&& tar -xf poppler-data-0.4.9.tar.gz \
&& cd poppler-data-0.4.9 \
&& make install \
&& cd .. \
&& wget https://poppler.freedesktop.org/poppler-20.08.0.tar.xz \
&& tar -xf poppler-20.08.0.tar.xz \
&& cd poppler-20.08.0 \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make \
&& make install \
&& ldconfig
CMD tail -f /dev/null
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
I am getting a error: no include path in which to search for stdint.h error message when building a docker image from alpine:edge, that leads to other errors like unknown type name 'uint32_t' and failure when compiling a program.
As far as I understand, stdint.h is part of the C++ standard library and should be present, unless there is something broken within alpine:edge, which I don't think will be the case.
My docker image is the following:
FROM alpine:edge
RUN apk update && apk add \
git \
make \
gcc \
python3 \
ldc \
&& git clone --recursive https://github.com/lomereiter/sambamba.git \
&& cd sambamba \
&& make \
&& mv sambamba /usr/local/bin/ \
&& cd ../.. \
&& rm -r sambamba
WORKDIR /wd
ENTRYPOINT ["/usr/local/bin/sambamba"]
Note that the image alpine:edge is necessary, because the ldc package is only available on it. How to fix this? Why isn't stdint.h found?
To successfully compile Sambamba, you need some additional packages:
g++ (for the C++ compiler and includes)
zlib
zlib-dev (for the zlib Header files)
Overall, this modified Dockerfile should do the trick:
FROM alpine:edge
RUN apk update && apk add \
git \
make \
gcc \
g++ \
zlib \
zlib-dev \
python3 \
ldc \
&& git clone --recursive https://github.com/lomereiter/sambamba.git \
&& cd sambamba \
&& make \
&& mv sambamba /usr/local/bin/ \
&& cd ../.. \
&& rm -r sambamba
WORKDIR /wd
ENTRYPOINT ["/usr/local/bin/sambamba"]
I have such a gulp task
gulp.task('images', () => {
return gulp.src('assets/images/**/*')
.pipe($.cache($.imagemin()))
.pipe(gulp.dest('public/build/images'));
});
and it throwing error in this line .pipe($.cache($.imagemin())) for me:
events.js:167
throw er; // Unhandled 'error' event
^
Error: write callback called multiple times
at DestroyableTransform.afterTransform (/var/www/vhosts/devgenix/node_modules/readable-stream/lib/_stream_transform.js:84:31)
at EventEmitter.signals.on.err (/var/www/vhosts/devgenix/node_modules/gulp-cache/lib/index.js:451:7)
at EventEmitter.emit (events.js:182:13)
at DestroyableTransform.onError (/var/www/vhosts/devgenix/node_modules/gulp-cache/lib/index.js:288:15)
at Object.onceWrapper (events.js:273:13)
at DestroyableTransform.emit (events.js:187:15)
at Immediate.<anonymous> (/var/www/vhosts/devgenix/node_modules/through2-concurrent/through2-concurrent.js:37:14)
at runCallback (timers.js:706:11)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
but for other developers on their machines, all works fine.
I'm running all the code under the custom alpine docker container with preinstalled node (other devs no), so maybe it's an issue and I just need to install some missing dependency but I can't figure out what is wrong.
My docker file is actually for PHP with the node, here is the docker file content:
FROM php:7.1-fpm-alpine
ENV ZMQ_VERSION 4.3.1
ENV BUILD_DEPS autoconf file gcc libc-dev make g++ pkgconf re2c git
RUN apk add --update --no-cache --virtual .build-deps $BUILD_DEPS
# Error code: 127
RUN apk add --no-cache --virtual .php-build-deps \
nasm \
libsodium \
freetype-dev \
libmcrypt-dev \
postgresql-dev \
libxml2-dev \
zlib-dev cyrus-sasl-dev libmemcached-dev \
# the next line is for node and npm packages (node-sass requires python/make/g++ to build something)
python \
&& apk add --update nodejs nodejs-npm \
# for GD
bash \
freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev \
# just good to have installed
ca-certificates wget \
## Install git (we'll never delete it)
#&& apk add --no-cache git \
&& docker-php-ext-configure gd \
--with-gd \
--with-freetype-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
&& NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \
## Installable modules
&& docker-php-ext-install -j${NPROC} iconv mcrypt bcmath pdo_mysql opcache pgsql pdo_pgsql soap pcntl exif zip gd \
&& apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev \
## Memcached
&& git clone https://github.com/php-memcached-dev/php-memcached.git \
&& cd php-memcached \
&& git checkout php7 \
&& phpize \
&& ./configure --disable-memcached-sasl \
&& make \
&& cp modules/memcached.so $(php-config --extension-dir) \
&& docker-php-ext-enable memcached \
## Composer
&& cd ~ \
&& curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
## Gulp
&& npm install -g gulp \
## Cleanup
&& rm -rf /var/cache/apk/*
RUN docker-php-ext-configure calendar && docker-php-ext-install calendar
ADD www.conf /usr/local/etc/php-fpm.d
ADD php-fpm.conf /usr/local/etc
ADD php.ini /usr/local/etc/php/
WORKDIR /var/www/vhosts/devgenix/
#EXPOSE 22
CMD ["php-fpm", "--fpm-config", "/usr/local/etc/php-fpm.conf"]
Maybe someone has any ideas why it's not working for me? Thanks!
updated
npm version: 6.4.1
gulp version: 3.9.1
gulp-imagemin version: 4.1.0
I solve the issue by adding libjpeg-turbo libjpeg-turbo-dev libpng libpng-dev automake dependencies to my docker file
I am trying to build a lean alpine docker container for unit testing Lua in Google Cloud Build.
It runs fine, but takes about 30 - 50 seconds to build. When I run busted and luacheck, it only takes a few seconds for each. Any thoughts on how I could optimize this build process?
I was using wget and then switched to git. I added curl and unzip since luarocks expects it and openssl for one of luacheck's dependencies. Are there different dependencies I could/should use?
FROM alpine
ENV LUA_VERSION 5.1
RUN apk update
RUN apk add lua${LUA_VERSION}
RUN apk add lua${LUA_VERSION}-dev
RUN apk add bash build-base curl git openssl unzip
RUN cd /tmp && \
git clone https://github.com/keplerproject/luarocks.git && \
cd luarocks && \
sh ./configure && \
make build install && \
cd && \
rm -rf /tmp/luarocks
RUN luarocks install busted
RUN luarocks install luacheck
RUN luarocks install luacov
You can try this
Dockerfile
FROM alpine:3.12
# Set environment
ENV LUA_VERSION=5.1.5 \
LUAROCKS_VERSION=3.4.0
# Install dependency packages
RUN set -xe && \
apk add --no-cache --virtual .build-deps \
curl \
gcc \
g++ \
libc-dev \
make \
readline-dev \
&& \
apk add --no-cache \
readline \
&& \
# Install Lua
wget http://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz && \
tar zxf lua-${LUA_VERSION}.tar.gz && rm -f lua-${LUA_VERSION}.tar.gz && \
cd lua-${LUA_VERSION} && \
make -j $(getconf _NPROCESSORS_ONLN) linux && make install && \
cd / && rm -rf lua-${LUA_VERSION} && \
# Install LuaRocks
wget https://luarocks.org/releases/luarocks-${LUAROCKS_VERSION}.tar.gz && \
tar zxf luarocks-${LUAROCKS_VERSION}.tar.gz && rm -f luarocks-${LUAROCKS_VERSION}.tar.gz && \
cd luarocks-${LUAROCKS_VERSION} && \
./configure && \
make -j $(getconf _NPROCESSORS_ONLN) build && make install && \
cd / && rm -rf luarocks-${LUAROCKS_VERSION} && \
# Remove all build deps
apk del .build-deps && \
# Test
lua -v && luarocks
COPY docker-entrypoint.sh /usr/local/bin
docker-entrypoint.sh
#!/bin/sh
set -e
buildDepsApk="
curl
libc-dev
gcc
wget
"
pm='unknown'
if [ -e /lib/apk/db/installed ]; then
pm='apk'
fi
if [ "$pm" = 'apk' ]; then
apk add --no-cache ${buildDepsApk}
fi
luarocks install $#
if [ "$pm" = 'apk' ]; then
apk del ${buildDepsApk}
fi
You don't have to build luarocks. You can just install the package using,
RUN apk add luarocks