|
| 1 | +FROM ruby:3.1-slim-bullseye |
| 2 | + |
| 3 | +# explicitly set uid/gid to guarantee that it won't change in the future |
| 4 | +# the values 999:999 are identical to the current user/group id assigned |
| 5 | +RUN groupadd -r -g 999 redmine && useradd -r -g redmine -u 999 redmine |
| 6 | + |
| 7 | +RUN set -eux; \ |
| 8 | + apt-get update; \ |
| 9 | + apt-get install -y --no-install-recommends \ |
| 10 | + ca-certificates \ |
| 11 | + curl \ |
| 12 | + wget \ |
| 13 | + \ |
| 14 | + bzr \ |
| 15 | + git \ |
| 16 | + mercurial \ |
| 17 | + openssh-client \ |
| 18 | + subversion \ |
| 19 | + \ |
| 20 | +# we need "gsfonts" for generating PNGs of Gantt charts |
| 21 | +# and "ghostscript" for creating PDF thumbnails (in 4.1+) |
| 22 | + ghostscript \ |
| 23 | + gsfonts \ |
| 24 | + imagemagick \ |
| 25 | +# grab gosu for easy step-down from root |
| 26 | + gosu \ |
| 27 | +# grab tini for signal processing and zombie killing |
| 28 | + tini \ |
| 29 | + ; \ |
| 30 | +# allow imagemagick to use ghostscript for PDF -> PNG thumbnail conversion (4.1+) |
| 31 | + sed -ri 's/(rights)="none" (pattern="PDF")/\1="read" \2/' /etc/ImageMagick-6/policy.xml; \ |
| 32 | + rm -rf /var/lib/apt/lists/* |
| 33 | + |
| 34 | +ENV RAILS_ENV production |
| 35 | +WORKDIR /usr/src/redmine |
| 36 | + |
| 37 | +# https://github.com/docker-library/redmine/issues/138#issuecomment-438834176 |
| 38 | +# (bundler needs this for running as an arbitrary user) |
| 39 | +ENV HOME /home/redmine |
| 40 | +RUN set -eux; \ |
| 41 | + [ ! -d "$HOME" ]; \ |
| 42 | + mkdir -p "$HOME"; \ |
| 43 | + chown redmine:redmine "$HOME"; \ |
| 44 | + chmod 1777 "$HOME" |
| 45 | + |
| 46 | +ENV REDMINE_VERSION 5.0.0 |
| 47 | +ENV REDMINE_DOWNLOAD_URL https://www.redmine.org/releases/redmine-5.0.0.tar.gz |
| 48 | +ENV REDMINE_DOWNLOAD_SHA256 7e840dec846646dae52fff5c631b135d1c915d6e03ea6f01ca8f12ad35803bef |
| 49 | + |
| 50 | +RUN set -eux; \ |
| 51 | +# if we use wget here, we get certificate issues (https://github.com/docker-library/redmine/pull/249#issuecomment-984176479) |
| 52 | + curl -fL -o redmine.tar.gz "$REDMINE_DOWNLOAD_URL"; \ |
| 53 | + echo "$REDMINE_DOWNLOAD_SHA256 *redmine.tar.gz" | sha256sum -c -; \ |
| 54 | + tar -xf redmine.tar.gz --strip-components=1; \ |
| 55 | + rm redmine.tar.gz files/delete.me log/delete.me; \ |
| 56 | + mkdir -p log public/plugin_assets sqlite tmp/pdf tmp/pids; \ |
| 57 | + chown -R redmine:redmine ./; \ |
| 58 | +# log to STDOUT (https://github.com/docker-library/redmine/issues/108) |
| 59 | + echo 'config.logger = Logger.new(STDOUT)' > config/additional_environment.rb; \ |
| 60 | +# fix permissions for running as an arbitrary user |
| 61 | + chmod -R ugo=rwX config db sqlite; \ |
| 62 | + find log tmp -type d -exec chmod 1777 '{}' + |
| 63 | + |
| 64 | +RUN set -eux; \ |
| 65 | + \ |
| 66 | + savedAptMark="$(apt-mark showmanual)"; \ |
| 67 | + apt-get update; \ |
| 68 | + apt-get install -y --no-install-recommends \ |
| 69 | + default-libmysqlclient-dev \ |
| 70 | + freetds-dev \ |
| 71 | + gcc \ |
| 72 | + libpq-dev \ |
| 73 | + libsqlite3-dev \ |
| 74 | + make \ |
| 75 | + patch \ |
| 76 | + ; \ |
| 77 | + rm -rf /var/lib/apt/lists/*; \ |
| 78 | + \ |
| 79 | + gosu redmine bundle config --local without 'development test'; \ |
| 80 | +# https://github.com/redmine/redmine/commit/23dc108e70a0794f444803ac827a690085dcd557 |
| 81 | +# https://rubygems.org/gems/puma/versions |
| 82 | + puma="$(grep -E "^[[:space:]]*gem [:'\"]puma['\",[:space:]].*\$" Gemfile)"; \ |
| 83 | + { echo; echo "$puma"; } | sed -re 's/^[[:space:]]+//' >> Gemfile; \ |
| 84 | +# ("gem puma" already exists in the Gemfile, but under "group :test" and we want it all the time) |
| 85 | +# fill up "database.yml" with bogus entries so the redmine Gemfile will pre-install all database adapter dependencies |
| 86 | +# https://github.com/redmine/redmine/blob/e9f9767089a4e3efbd73c35fc55c5c7eb85dd7d3/Gemfile#L50-L79 |
| 87 | + echo '# the following entries only exist to force `bundle install` to pre-install all database adapter dependencies -- they can be safely removed/ignored' > ./config/database.yml; \ |
| 88 | + for adapter in mysql2 postgresql sqlserver sqlite3; do \ |
| 89 | + echo "$adapter:" >> ./config/database.yml; \ |
| 90 | + echo " adapter: $adapter" >> ./config/database.yml; \ |
| 91 | + done; \ |
| 92 | + gosu redmine bundle install --jobs "$(nproc)"; \ |
| 93 | + rm ./config/database.yml; \ |
| 94 | +# fix permissions for running as an arbitrary user |
| 95 | + chmod -R ugo=rwX Gemfile.lock "$GEM_HOME"; \ |
| 96 | + rm -rf ~redmine/.bundle; \ |
| 97 | + \ |
| 98 | +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies |
| 99 | + apt-mark auto '.*' > /dev/null; \ |
| 100 | + [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \ |
| 101 | + find /usr/local -type f -executable -exec ldd '{}' ';' \ |
| 102 | + | awk '/=>/ { print $(NF-1) }' \ |
| 103 | + | sort -u \ |
| 104 | + | grep -v '^/usr/local/' \ |
| 105 | + | xargs -r dpkg-query --search \ |
| 106 | + | cut -d: -f1 \ |
| 107 | + | sort -u \ |
| 108 | + | xargs -r apt-mark manual \ |
| 109 | + ; \ |
| 110 | + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false |
| 111 | + |
| 112 | +VOLUME /usr/src/redmine/files |
| 113 | + |
| 114 | +COPY docker-entrypoint.sh / |
| 115 | +ENTRYPOINT ["/docker-entrypoint.sh"] |
| 116 | + |
| 117 | +EXPOSE 3000 |
| 118 | +CMD ["rails", "server", "-b", "0.0.0.0"] |
0 commit comments