Skip to content
Snippets Groups Projects
Commit 810e17c5 authored by Pierre Ozoux's avatar Pierre Ozoux
Browse files

Improves the docker build.

parent daacd2df
No related branches found
No related tags found
No related merge requests found
variables:
GIT_SUBMODULE_STRATEGY: recursive
DOCKER_HUB_REPO: libresh/discourse
test-beta:
tags:
- build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1`
- /kaniko/executor --context . --no-push --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION
except:
- master
test-stable:
tags:
- build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1`
- /kaniko/executor --context . --no-push --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION
except:
- master
build-beta:
tags:
- build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json
- export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1`
- export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-3`
- export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:beta"
- /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION
only:
- master
build-stable:
tags:
- build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json
- export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1`
- export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-2`
- export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:stable"
- /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION
only:
- master
FROM ruby:2.5.3
FROM ruby:2.6.5
ARG DISCOURSE_VERSION
ENV RAILS_ENV=production \
DEBIAN_VERSION=buster \
DISCOURSE_DB_HOST=postgres \
DISCOURSE_REDIS_HOST=redis \
DISCOURSE_SERVE_STATIC_ASSETS=true \
GIFSICLE_VERSION=1.91 \
PNGQUANT_VERSION=2.12.1 \
DISCOURSE_VERSION=${DISCOURSE_VERSION} \
GIFSICLE_VERSION=1.92 \
PNGQUANT_VERSION=2.12.5 \
PNGCRUSH_VERSION=1.8.13 \
DISCOURSE_VERSION=2.2.0.beta4 \
JEMALLOC_NEW=3.6.0 \
JEMALLOC_STABLE=5.2.0 \
PG_MAJOR=10 \
NODE_MAJOR=10 \
RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \
RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 \
RUBY_GC_HEAP_INIT_SLOTS=400000 \
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 \
RUBY_GC_MALLOC_LIMIT=90000000 \
BUILD_DEPS="\
autoconf \
advancecomp \
......@@ -19,87 +30,67 @@ ENV RAILS_ENV=production \
libtiff-dev \
pkg-config"
RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | \
tee /etc/apt/sources.list.d/postgres.list
COPY install /tmp/install
RUN ls /tmp/ && ls /tmp/install
RUN curl --silent --location https://deb.nodesource.com/setup_8.x | bash - \
RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_VERSION}-pgdg main" | \
tee /etc/apt/sources.list.d/postgres.list \
&& curl --silent --location https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \
&& apt-get update && apt-get install -y --no-install-recommends \
${BUILD_DEPS} \
ghostscript \
gsfonts \
imagemagick \
jpegoptim \
libxml2 \
nodejs \
optipng \
jhead \
postgresql-client-${PG_MAJOR} \
postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev
RUN npm install svgo uglify-js@"<3" -g
RUN mkdir /jemalloc-stable && cd /jemalloc-stable &&\
wget https://github.com/jemalloc/jemalloc/releases/download/3.6.0/jemalloc-3.6.0.tar.bz2 &&\
tar -xjf jemalloc-3.6.0.tar.bz2 && cd jemalloc-3.6.0 && ./configure --prefix=/usr && make && make install &&\
cd / && rm -rf /jemalloc-stable
RUN mkdir /jemalloc-new && cd /jemalloc-new &&\
wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2 &&\
tar -xjf jemalloc-5.1.0.tar.bz2 && cd jemalloc-5.1.0 && ./configure --prefix=/usr --with-install-suffix=5.1.0 && make build_lib && make install_lib &&\
cd / && rm -rf /jemalloc-new
RUN gem update --system
RUN gem install bundler --force \
&& rm -rf /usr/local/share/ri/2.5.2/system
ADD install-imagemagick /tmp/install-imagemagick
RUN /tmp/install-imagemagick
# Validate install
RUN ruby -Eutf-8 -e "v = \`convert -version\`; %w{png tiff jpeg freetype}.each { |f| unless v.include?(f); STDERR.puts('no ' + f + ' support in imagemagick'); exit(-1); end }"
ADD install-pngcrush /tmp/install-pngcrush
RUN /tmp/install-pngcrush
ADD install-gifsicle /tmp/install-gifsicle
RUN /tmp/install-gifsicle
ADD install-pngquant /tmp/install-pngquant
RUN /tmp/install-pngquant
RUN addgroup --gid 1000 discourse \
postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev \
&& npm install svgo uglify-js@"<3" -g \
&& mkdir /jemalloc-stable && cd /jemalloc-stable &&\
wget https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_STABLE}/jemalloc-${JEMALLOC_STABLE}.tar.bz2 &&\
tar -xjf jemalloc-${JEMALLOC_STABLE}.tar.bz2 && cd jemalloc-${JEMALLOC_STABLE} && ./configure --prefix=/usr && make && make install &&\
cd / && rm -rf /jemalloc-stable \
&& mkdir /jemalloc-new && cd /jemalloc-new &&\
wget https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_NEW}/jemalloc-${JEMALLOC_NEW}.tar.bz2 &&\
tar -xjf jemalloc-${JEMALLOC_NEW}.tar.bz2 && cd jemalloc-${JEMALLOC_NEW} && ./configure --prefix=/usr --with-install-suffix=${JEMALLOC_NEW} && make build_lib && make install_lib &&\
cd / && rm -rf /jemalloc-new \
&& gem update --system \
&& gem install bundler --force \
&& rm -rf /usr/local/share/ri/${RUBY_VERSION}/system \
&& /tmp/install/imagemagick \
# Validate install
&& ruby -Eutf-8 -e "v = \`convert -version\`; %w{png tiff jpeg freetype}.each { |f| unless v.include?(f); STDERR.puts('no ' + f + ' support in imagemagick'); exit(-1); end }" \
&& /tmp/install/pngcrush \
&& /tmp/install/gifsicle \
&& /tmp/install/pngquant \
&& addgroup --gid 1000 discourse \
&& adduser --system --uid 1000 --ingroup discourse --shell /bin/bash discourse \
&& cd /home/discourse \
&& mkdir -p tmp/pids \
&& mkdir -p ./tmp/sockets \
&& git clone --branch v${DISCOURSE_VERSION} https://github.com/discourse/discourse.git \
&& git clone --branch ${DISCOURSE_VERSION} https://github.com/discourse/discourse.git \
&& chown -R discourse:discourse . \
&& cd /home/discourse/discourse \
&& git remote set-branches --add origin tests-passed \
&& sed -i 's/daemonize true/daemonize false/g' ./config/puma.rb \
&& bundle config build.nokogiri --use-system-libraries \
&& bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4
RUN find /home/discourse/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
# RUN apt-get remove -y --purge ${BUILD_DEPS} \
# && apt-get autoremove -y \
# && rm -rf /var/lib/apt/lists/*
&& bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4 \
&& find /home/discourse/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + \
&& apt-get remove -y --purge ${BUILD_DEPS} \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
RUN rm -rf /var/lib/apt/lists/*
RUN cd /home/discourse/discourse/plugins \
&& for plugin in $(cat /tmp/install/plugin-list); do \
git clone $plugin; \
done;
WORKDIR /home/discourse/discourse
ENV RAILS_ENV=production \
RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \
RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 \
RUBY_GC_HEAP_INIT_SLOTS=400000 \
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 \
RUBY_GC_MALLOC_LIMIT=90000000
USER discourse
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
#!/bin/bash
set -e
VERSION=1.91
cd /tmp
curl -O http://www.lcdf.org/gifsicle/gifsicle-$VERSION.tar.gz
tar zxf gifsicle-$VERSION.tar.gz
cd gifsicle-$VERSION
./configure
make install
cd /
rm -fr /tmp/gifsicle*
#!/bin/bash -e
cd /tmp
curl -O http://www.lcdf.org/gifsicle/gifsicle-$GIFSICLE_VERSION.tar.gz
tar zxf gifsicle-$GIFSICLE_VERSION.tar.gz
cd gifsicle-$GIFSICLE_VERSION
./configure
make install
cd /
rm -fr /tmp/gifsicle*
#!/bin/bash
set -o errexit
# Install build deps
apt-get -y -q remove imagemagick
IMAGE_MAGICK_VERSION="7.0.8-66"
LIBPNG_VERSION="1.6.37"
PREFIX=/usr/local
WDIR=/tmp/imagemagick
mkdir -p $WDIR
cd $WDIR
# Build and install libpng
git clone -b v1.6.34 https://github.com/glennrp/libpng.git $WDIR/libpng
cd $WDIR/libpng
./autogen.sh
wget -O $WDIR/libpng.tar.gz https://prdownloads.sourceforge.net/libpng/libpng-$LIBPNG_VERSION.tar.gz?download
tar -xzvf $WDIR/libpng.tar.gz
cd $WDIR/libpng-$LIBPNG_VERSION
./configure --prefix=$PREFIX
make all && make install
# Build and install ImageMagick
wget -O $WDIR/ImageMagick.tar.gz "https://github.com/ImageMagick/ImageMagick/archive/7.0.8-6.tar.gz"
wget -O $WDIR/ImageMagick.tar.gz "https://github.com/ImageMagick/ImageMagick/archive/$IMAGE_MAGICK_VERSION.tar.gz"
IMDIR=$WDIR/$(tar tzf $WDIR/ImageMagick.tar.gz --wildcards "ImageMagick-*/configure" |cut -d/ -f1)
tar zxf $WDIR/ImageMagick.tar.gz -C $WDIR
cd $IMDIR
......@@ -43,4 +47,4 @@ make all && make install
cd $HOME
rm -rf $WDIR
ldconfig /usr/local/lib
ldconfig /usr/local/lib
\ No newline at end of file
https://github.com/discourse/discourse-checklist
https://github.com/discourse/discourse-math
https://github.com/discourse/discourse-openid-connect
https://github.com/discourse/discourse-solved
https://github.com/discourse/discourse-voting
\ No newline at end of file
#!/bin/bash
set -e
PNGCRUSH_VERSION=1.8.13
#!/bin/bash -e
cd /tmp
wget https://sourceforge.net/projects/pmt/files/pngcrush/$PNGCRUSH_VERSION/pngcrush-$PNGCRUSH_VERSION.tar.gz/download -O pngcrush-$PNGCRUSH_VERSION.tar.gz
tar zxf pngcrush-$PNGCRUSH_VERSION.tar.gz
......
#!/bin/bash
VERSION=2.12.1
cd /tmp
git clone -b $VERSION --single-branch https://github.com/pornel/pngquant
git clone -b PNGQUANT_VERSION --single-branch https://github.com/pornel/pngquant
cd pngquant
make && make install
cd /
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment