Skip to content
Dockerfile 4.11 KiB
Newer Older
Timothee Gosselin's avatar
Timothee Gosselin committed
FROM ruby:2.7.5
Pierre Ozoux's avatar
Pierre Ozoux committed

ARG DISCOURSE_VERSION
Pierre Ozoux's avatar
Pierre Ozoux committed

Timothee Gosselin's avatar
Timothee Gosselin committed
    DEBIAN_VERSION=bullseye \
Pierre Ozoux's avatar
Pierre Ozoux committed
    DISCOURSE_DB_HOST=postgres \
    DISCOURSE_REDIS_HOST=redis \
Pierre Ozoux's avatar
Pierre Ozoux committed
    DISCOURSE_SERVE_STATIC_ASSETS=true \
Pierre Ozoux's avatar
Pierre Ozoux committed
    DISCOURSE_VERSION=${DISCOURSE_VERSION} \
unteem's avatar
unteem committed
    EMBER_CLI_PROD_ASSETS=1 \
Pierre Ozoux's avatar
Pierre Ozoux committed
    JEMALLOC_NEW=3.6.0 \
Pierre Ozoux's avatar
Pierre Ozoux committed
    JEMALLOC_STABLE=5.2.1 \
Timothee Gosselin's avatar
Timothee Gosselin committed
    NODE_MAJOR=16 \
Pierre Ozoux's avatar
Pierre Ozoux committed
    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 \
Pierre Ozoux's avatar
Pierre Ozoux committed
    BUILD_DEPS="\
Pierre Ozoux's avatar
Pierre Ozoux committed
      autoconf \
      advancecomp \
Pierre Ozoux's avatar
Pierre Ozoux committed
      libbz2-dev \
      libfreetype6-dev \
      libjpeg-dev \
      libjpeg-turbo-progs \
Pierre Ozoux's avatar
Pierre Ozoux committed
      libtiff-dev \
      pkg-config"
Pierre Ozoux's avatar
Pierre Ozoux committed
COPY install /tmp/install

RUN ls /tmp/ && ls /tmp/install
Pierre Ozoux's avatar
Pierre Ozoux committed
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 - \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && apt-get update && apt-get install -y --no-install-recommends \
      ${BUILD_DEPS} \
Pierre Ozoux's avatar
Pierre Ozoux committed
      ca-certificates \
Pierre Ozoux's avatar
Pierre Ozoux committed
      brotli \
Pierre Ozoux's avatar
Pierre Ozoux committed
      ghostscript \
      gsfonts \
Pierre Ozoux's avatar
Pierre Ozoux committed
      jpegoptim \
Pierre Ozoux's avatar
Pierre Ozoux committed
      liblqr-1-0 \
Pierre Ozoux's avatar
Pierre Ozoux committed
      libxml2 \
      nodejs \
      optipng \
      pngcrush \
      pngquant \
      postgresql-client-${PG_MAJOR} \
Pierre Ozoux's avatar
Pierre Ozoux committed
      postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && npm install svgo uglify-js -g \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && 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 }" \
 && 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 \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && git clone --branch ${DISCOURSE_VERSION} https://github.com/discourse/discourse.git \
 && chown -R discourse:discourse . \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && cd /home/discourse/discourse \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && git remote set-branches --add origin tests-passed \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && sed -i 's/daemonize true/daemonize false/g' ./config/puma.rb \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && sed -i "s/msgpack (1.4.1)/msgpack (1.4.2)/" Gemfile.lock \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && bundle config build.nokogiri --use-system-libraries \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && 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 {} + \
Pierre Ozoux's avatar
Pierre Ozoux committed
 #&& apt-get remove -y --purge ${BUILD_DEPS} \
Pierre Ozoux's avatar
Pierre Ozoux committed
 #&& apt-get autoremove -y \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && rm -rf /var/lib/apt/lists/*
Timothee Gosselin's avatar
Timothee Gosselin committed
RUN mkdir /oxipng-install && cd /oxipng-install &&\
      wget https://github.com/shssoichiro/oxipng/releases/download/v5.0.0/oxipng-5.0.0-x86_64-unknown-linux-musl.tar.gz &&\
      tar -xzf oxipng-5.0.0-x86_64-unknown-linux-musl.tar.gz && cd oxipng-5.0.0-x86_64-unknown-linux-musl &&\
      cp oxipng /usr/local/bin &&\
      cd / && rm -rf /oxipng-install

Pierre Ozoux's avatar
Pierre Ozoux committed
RUN cd /home/discourse/discourse/plugins \
 && for plugin in $(cat /tmp/install/plugin-list); do \
      git clone $plugin; \
Pierre Ozoux's avatar
Pierre Ozoux committed
    done \
Pierre Ozoux's avatar
Pierre Ozoux committed
 && chown -R discourse:discourse .
Pierre Ozoux's avatar
Pierre Ozoux committed

Pierre Ozoux's avatar
Pierre Ozoux committed
WORKDIR /home/discourse/discourse
Pierre Ozoux's avatar
Pierre Ozoux committed
USER discourse
Pierre Ozoux's avatar
Pierre Ozoux committed

CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]