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

Merge branch 'fix-pierre' into 'master'

Improves the docker build.

See merge request libre.sh/docker/discourse!11
parents daacd2df 810e17c5
No related branches found
No related tags found
1 merge request!11Improves the docker build.
Pipeline #271 passed with stage
in 20 minutes and 23 seconds
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 \ ENV RAILS_ENV=production \
DEBIAN_VERSION=buster \
DISCOURSE_DB_HOST=postgres \ DISCOURSE_DB_HOST=postgres \
DISCOURSE_REDIS_HOST=redis \ DISCOURSE_REDIS_HOST=redis \
DISCOURSE_SERVE_STATIC_ASSETS=true \ DISCOURSE_SERVE_STATIC_ASSETS=true \
GIFSICLE_VERSION=1.91 \ DISCOURSE_VERSION=${DISCOURSE_VERSION} \
PNGQUANT_VERSION=2.12.1 \ GIFSICLE_VERSION=1.92 \
PNGQUANT_VERSION=2.12.5 \
PNGCRUSH_VERSION=1.8.13 \ PNGCRUSH_VERSION=1.8.13 \
DISCOURSE_VERSION=2.2.0.beta4 \ JEMALLOC_NEW=3.6.0 \
JEMALLOC_STABLE=5.2.0 \
PG_MAJOR=10 \ 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="\ BUILD_DEPS="\
autoconf \ autoconf \
advancecomp \ advancecomp \
...@@ -19,87 +30,67 @@ ENV RAILS_ENV=production \ ...@@ -19,87 +30,67 @@ ENV RAILS_ENV=production \
libtiff-dev \ libtiff-dev \
pkg-config" pkg-config"
RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - COPY install /tmp/install
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | \
tee /etc/apt/sources.list.d/postgres.list 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 \ && apt-get update && apt-get install -y --no-install-recommends \
${BUILD_DEPS} \ ${BUILD_DEPS} \
ghostscript \ ghostscript \
gsfonts \ gsfonts \
imagemagick \
jpegoptim \ jpegoptim \
libxml2 \ libxml2 \
nodejs \ nodejs \
optipng \ optipng \
jhead \ jhead \
postgresql-client-${PG_MAJOR} \ postgresql-client-${PG_MAJOR} \
postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev \
&& npm install svgo uglify-js@"<3" -g \
RUN 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 &&\
RUN mkdir /jemalloc-stable && cd /jemalloc-stable &&\ tar -xjf jemalloc-${JEMALLOC_STABLE}.tar.bz2 && cd jemalloc-${JEMALLOC_STABLE} && ./configure --prefix=/usr && make && make install &&\
wget https://github.com/jemalloc/jemalloc/releases/download/3.6.0/jemalloc-3.6.0.tar.bz2 &&\ cd / && rm -rf /jemalloc-stable \
tar -xjf jemalloc-3.6.0.tar.bz2 && cd jemalloc-3.6.0 && ./configure --prefix=/usr && make && make install &&\ && mkdir /jemalloc-new && cd /jemalloc-new &&\
cd / && rm -rf /jemalloc-stable 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 &&\
RUN mkdir /jemalloc-new && cd /jemalloc-new &&\ cd / && rm -rf /jemalloc-new \
wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2 &&\ && gem update --system \
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 &&\ && gem install bundler --force \
cd / && rm -rf /jemalloc-new && rm -rf /usr/local/share/ri/${RUBY_VERSION}/system \
&& /tmp/install/imagemagick \
# Validate install
RUN gem update --system && 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 \
RUN gem install bundler --force \ && /tmp/install/gifsicle \
&& rm -rf /usr/local/share/ri/2.5.2/system && /tmp/install/pngquant \
&& addgroup --gid 1000 discourse \
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 \
&& adduser --system --uid 1000 --ingroup discourse --shell /bin/bash discourse \ && adduser --system --uid 1000 --ingroup discourse --shell /bin/bash discourse \
&& cd /home/discourse \ && cd /home/discourse \
&& mkdir -p tmp/pids \ && mkdir -p tmp/pids \
&& mkdir -p ./tmp/sockets \ && 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 . \ && chown -R discourse:discourse . \
&& cd /home/discourse/discourse \ && cd /home/discourse/discourse \
&& git remote set-branches --add origin tests-passed \ && git remote set-branches --add origin tests-passed \
&& sed -i 's/daemonize true/daemonize false/g' ./config/puma.rb \ && sed -i 's/daemonize true/daemonize false/g' ./config/puma.rb \
&& bundle config build.nokogiri --use-system-libraries \ && bundle config build.nokogiri --use-system-libraries \
&& bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4 && 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 {} + \
RUN find /home/discourse/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + && apt-get remove -y --purge ${BUILD_DEPS} \
&& apt-get autoremove -y \
# RUN apt-get remove -y --purge ${BUILD_DEPS} \ && rm -rf /var/lib/apt/lists/*
# && 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 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 USER discourse
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] 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 #!/bin/bash
set -o errexit set -o errexit
# Install build deps IMAGE_MAGICK_VERSION="7.0.8-66"
apt-get -y -q remove imagemagick LIBPNG_VERSION="1.6.37"
PREFIX=/usr/local PREFIX=/usr/local
WDIR=/tmp/imagemagick WDIR=/tmp/imagemagick
mkdir -p $WDIR mkdir -p $WDIR
cd $WDIR
# Build and install libpng # Build and install libpng
git clone -b v1.6.34 https://github.com/glennrp/libpng.git $WDIR/libpng wget -O $WDIR/libpng.tar.gz https://prdownloads.sourceforge.net/libpng/libpng-$LIBPNG_VERSION.tar.gz?download
cd $WDIR/libpng
./autogen.sh tar -xzvf $WDIR/libpng.tar.gz
cd $WDIR/libpng-$LIBPNG_VERSION
./configure --prefix=$PREFIX ./configure --prefix=$PREFIX
make all && make install make all && make install
# Build and install ImageMagick # 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) IMDIR=$WDIR/$(tar tzf $WDIR/ImageMagick.tar.gz --wildcards "ImageMagick-*/configure" |cut -d/ -f1)
tar zxf $WDIR/ImageMagick.tar.gz -C $WDIR tar zxf $WDIR/ImageMagick.tar.gz -C $WDIR
cd $IMDIR cd $IMDIR
...@@ -43,4 +47,4 @@ make all && make install ...@@ -43,4 +47,4 @@ make all && make install
cd $HOME cd $HOME
rm -rf $WDIR 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 #!/bin/bash -e
set -e
PNGCRUSH_VERSION=1.8.13
cd /tmp cd /tmp
wget https://sourceforge.net/projects/pmt/files/pngcrush/$PNGCRUSH_VERSION/pngcrush-$PNGCRUSH_VERSION.tar.gz/download -O pngcrush-$PNGCRUSH_VERSION.tar.gz 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 tar zxf pngcrush-$PNGCRUSH_VERSION.tar.gz
......
#!/bin/bash #!/bin/bash
VERSION=2.12.1
cd /tmp 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 cd pngquant
make && make install make && make install
cd / 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