Skip to content

Commit 5a58837

Browse files
committed
Add 5.0.0
Given this is a major release, we're finally removing the passenger variant (it hasn't been well supported for quite some time).
1 parent 24906a7 commit 5a58837

File tree

6 files changed

+553
-6
lines changed

6 files changed

+553
-6
lines changed

5.0/Dockerfile

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
# fill up "database.yml" with bogus entries so the redmine Gemfile will pre-install all database adapter dependencies
81+
# https://github.com/redmine/redmine/blob/e9f9767089a4e3efbd73c35fc55c5c7eb85dd7d3/Gemfile#L50-L79
82+
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; \
83+
for adapter in mysql2 postgresql sqlserver sqlite3; do \
84+
echo "$adapter:" >> ./config/database.yml; \
85+
echo " adapter: $adapter" >> ./config/database.yml; \
86+
done; \
87+
gosu redmine bundle install --jobs "$(nproc)"; \
88+
rm ./config/database.yml; \
89+
# fix permissions for running as an arbitrary user
90+
chmod -R ugo=rwX Gemfile.lock "$GEM_HOME"; \
91+
rm -rf ~redmine/.bundle; \
92+
\
93+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
94+
apt-mark auto '.*' > /dev/null; \
95+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
96+
find /usr/local -type f -executable -exec ldd '{}' ';' \
97+
| awk '/=>/ { print $(NF-1) }' \
98+
| sort -u \
99+
| grep -v '^/usr/local/' \
100+
| xargs -r dpkg-query --search \
101+
| cut -d: -f1 \
102+
| sort -u \
103+
| xargs -r apt-mark manual \
104+
; \
105+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
106+
107+
VOLUME /usr/src/redmine/files
108+
109+
COPY docker-entrypoint.sh /
110+
ENTRYPOINT ["/docker-entrypoint.sh"]
111+
112+
EXPOSE 3000
113+
CMD ["rails", "server", "-b", "0.0.0.0"]

5.0/alpine/Dockerfile

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
FROM ruby:3.1-alpine3.15
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+
# alpine already has a gid 999, so we'll use the next id
6+
RUN addgroup -S -g 1000 redmine && adduser -S -H -G redmine -u 999 redmine
7+
8+
RUN set -eux; \
9+
apk add --no-cache \
10+
bash \
11+
ca-certificates \
12+
su-exec \
13+
tini \
14+
tzdata \
15+
wget \
16+
\
17+
breezy \
18+
git \
19+
mercurial \
20+
openssh-client \
21+
subversion \
22+
\
23+
# we need "gsfonts" for generating PNGs of Gantt charts
24+
# and "ghostscript" for creating PDF thumbnails (in 4.1+)
25+
ghostscript \
26+
ghostscript-fonts \
27+
imagemagick \
28+
;
29+
30+
ENV RAILS_ENV production
31+
WORKDIR /usr/src/redmine
32+
33+
# https://github.com/docker-library/redmine/issues/138#issuecomment-438834176
34+
# (bundler needs this for running as an arbitrary user)
35+
ENV HOME /home/redmine
36+
RUN set -eux; \
37+
[ ! -d "$HOME" ]; \
38+
mkdir -p "$HOME"; \
39+
chown redmine:redmine "$HOME"; \
40+
chmod 1777 "$HOME"
41+
42+
ENV REDMINE_VERSION 5.0.0
43+
ENV REDMINE_DOWNLOAD_URL https://www.redmine.org/releases/redmine-5.0.0.tar.gz
44+
ENV REDMINE_DOWNLOAD_SHA256 7e840dec846646dae52fff5c631b135d1c915d6e03ea6f01ca8f12ad35803bef
45+
46+
RUN set -eux; \
47+
wget -O redmine.tar.gz "$REDMINE_DOWNLOAD_URL"; \
48+
echo "$REDMINE_DOWNLOAD_SHA256 *redmine.tar.gz" | sha256sum -c -; \
49+
tar -xf redmine.tar.gz --strip-components=1; \
50+
rm redmine.tar.gz files/delete.me log/delete.me; \
51+
mkdir -p log public/plugin_assets sqlite tmp/pdf tmp/pids; \
52+
chown -R redmine:redmine ./; \
53+
# log to STDOUT (https://github.com/docker-library/redmine/issues/108)
54+
echo 'config.logger = Logger.new(STDOUT)' > config/additional_environment.rb; \
55+
# fix permissions for running as an arbitrary user
56+
chmod -R ugo=rwX config db sqlite; \
57+
find log tmp -type d -exec chmod 1777 '{}' +
58+
59+
# build for musl-libc, not glibc (see https://github.com/sparklemotion/nokogiri/issues/2075, https://github.com/rubygems/rubygems/issues/3174)
60+
ENV BUNDLE_FORCE_RUBY_PLATFORM 1
61+
RUN set -eux; \
62+
\
63+
apk add --no-cache --virtual .build-deps \
64+
coreutils \
65+
freetds-dev \
66+
gcc \
67+
make \
68+
mariadb-dev \
69+
musl-dev \
70+
patch \
71+
postgresql-dev \
72+
sqlite-dev \
73+
ttf2ufm \
74+
zlib-dev \
75+
; \
76+
\
77+
su-exec redmine bundle config --local without 'development test'; \
78+
# fill up "database.yml" with bogus entries so the redmine Gemfile will pre-install all database adapter dependencies
79+
# https://github.com/redmine/redmine/blob/e9f9767089a4e3efbd73c35fc55c5c7eb85dd7d3/Gemfile#L50-L79
80+
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; \
81+
for adapter in mysql2 postgresql sqlserver sqlite3; do \
82+
echo "$adapter:" >> ./config/database.yml; \
83+
echo " adapter: $adapter" >> ./config/database.yml; \
84+
done; \
85+
su-exec redmine bundle install --jobs "$(nproc)"; \
86+
rm ./config/database.yml; \
87+
# fix permissions for running as an arbitrary user
88+
chmod -R ugo=rwX Gemfile.lock "$GEM_HOME"; \
89+
# this requires coreutils because "chmod +X" in busybox will remove +x on files (and coreutils leaves files alone with +X)
90+
rm -rf ~redmine/.bundle; \
91+
\
92+
# https://github.com/naitoh/rbpdf/issues/31
93+
rm /usr/local/bundle/gems/rbpdf-font-1.19.*/lib/fonts/ttf2ufm/ttf2ufm; \
94+
\
95+
runDeps="$( \
96+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/bundle/gems \
97+
| tr ',' '\n' \
98+
| sort -u \
99+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
100+
)"; \
101+
apk add --no-network --virtual .redmine-rundeps $runDeps; \
102+
apk del --no-network .build-deps
103+
104+
VOLUME /usr/src/redmine/files
105+
106+
COPY docker-entrypoint.sh /
107+
ENTRYPOINT ["/docker-entrypoint.sh"]
108+
109+
EXPOSE 3000
110+
CMD ["rails", "server", "-b", "0.0.0.0"]

5.0/alpine/docker-entrypoint.sh

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#!/usr/bin/env bash
2+
set -Eeo pipefail
3+
# TODO add "-u"
4+
5+
# usage: file_env VAR [DEFAULT]
6+
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
7+
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
8+
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
9+
file_env() {
10+
local var="$1"
11+
local fileVar="${var}_FILE"
12+
local def="${2:-}"
13+
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
14+
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
15+
exit 1
16+
fi
17+
local val="$def"
18+
if [ "${!var:-}" ]; then
19+
val="${!var}"
20+
elif [ "${!fileVar:-}" ]; then
21+
val="$(< "${!fileVar}")"
22+
fi
23+
export "$var"="$val"
24+
unset "$fileVar"
25+
}
26+
27+
isLikelyRedmine=
28+
case "$1" in
29+
rails | rake | passenger ) isLikelyRedmine=1 ;;
30+
esac
31+
32+
_fix_permissions() {
33+
# https://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-8-File-system-permissions
34+
if [ "$(id -u)" = '0' ]; then
35+
find config files log public/plugin_assets \! -user redmine -exec chown redmine:redmine '{}' +
36+
fi
37+
# directories 755, files 644:
38+
find config files log public/plugin_assets tmp -type d \! -perm 755 -exec chmod 755 '{}' + 2>/dev/null || :
39+
find config files log public/plugin_assets tmp -type f \! -perm 644 -exec chmod 644 '{}' + 2>/dev/null || :
40+
}
41+
42+
# allow the container to be started with `--user`
43+
if [ -n "$isLikelyRedmine" ] && [ "$(id -u)" = '0' ]; then
44+
_fix_permissions
45+
exec su-exec redmine "$BASH_SOURCE" "$@"
46+
fi
47+
48+
if [ -n "$isLikelyRedmine" ]; then
49+
_fix_permissions
50+
if [ ! -f './config/database.yml' ]; then
51+
file_env 'REDMINE_DB_MYSQL'
52+
file_env 'REDMINE_DB_POSTGRES'
53+
file_env 'REDMINE_DB_SQLSERVER'
54+
55+
if [ "$MYSQL_PORT_3306_TCP" ] && [ -z "$REDMINE_DB_MYSQL" ]; then
56+
export REDMINE_DB_MYSQL='mysql'
57+
elif [ "$POSTGRES_PORT_5432_TCP" ] && [ -z "$REDMINE_DB_POSTGRES" ]; then
58+
export REDMINE_DB_POSTGRES='postgres'
59+
fi
60+
61+
if [ "$REDMINE_DB_MYSQL" ]; then
62+
adapter='mysql2'
63+
host="$REDMINE_DB_MYSQL"
64+
file_env 'REDMINE_DB_PORT' '3306'
65+
file_env 'REDMINE_DB_USERNAME' "${MYSQL_ENV_MYSQL_USER:-root}"
66+
file_env 'REDMINE_DB_PASSWORD' "${MYSQL_ENV_MYSQL_PASSWORD:-${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
67+
file_env 'REDMINE_DB_DATABASE' "${MYSQL_ENV_MYSQL_DATABASE:-${MYSQL_ENV_MYSQL_USER:-redmine}}"
68+
file_env 'REDMINE_DB_ENCODING' ''
69+
elif [ "$REDMINE_DB_POSTGRES" ]; then
70+
adapter='postgresql'
71+
host="$REDMINE_DB_POSTGRES"
72+
file_env 'REDMINE_DB_PORT' '5432'
73+
file_env 'REDMINE_DB_USERNAME' "${POSTGRES_ENV_POSTGRES_USER:-postgres}"
74+
file_env 'REDMINE_DB_PASSWORD' "${POSTGRES_ENV_POSTGRES_PASSWORD}"
75+
file_env 'REDMINE_DB_DATABASE' "${POSTGRES_ENV_POSTGRES_DB:-${REDMINE_DB_USERNAME:-}}"
76+
file_env 'REDMINE_DB_ENCODING' 'utf8'
77+
elif [ "$REDMINE_DB_SQLSERVER" ]; then
78+
adapter='sqlserver'
79+
host="$REDMINE_DB_SQLSERVER"
80+
file_env 'REDMINE_DB_PORT' '1433'
81+
file_env 'REDMINE_DB_USERNAME' ''
82+
file_env 'REDMINE_DB_PASSWORD' ''
83+
file_env 'REDMINE_DB_DATABASE' ''
84+
file_env 'REDMINE_DB_ENCODING' ''
85+
else
86+
echo >&2
87+
echo >&2 'warning: missing REDMINE_DB_MYSQL, REDMINE_DB_POSTGRES, or REDMINE_DB_SQLSERVER environment variables'
88+
echo >&2
89+
echo >&2 '*** Using sqlite3 as fallback. ***'
90+
echo >&2
91+
92+
adapter='sqlite3'
93+
host='localhost'
94+
file_env 'REDMINE_DB_PORT' ''
95+
file_env 'REDMINE_DB_USERNAME' 'redmine'
96+
file_env 'REDMINE_DB_PASSWORD' ''
97+
file_env 'REDMINE_DB_DATABASE' 'sqlite/redmine.db'
98+
file_env 'REDMINE_DB_ENCODING' 'utf8'
99+
100+
mkdir -p "$(dirname "$REDMINE_DB_DATABASE")"
101+
if [ "$(id -u)" = '0' ]; then
102+
find "$(dirname "$REDMINE_DB_DATABASE")" \! -user redmine -exec chown redmine '{}' +
103+
fi
104+
fi
105+
106+
REDMINE_DB_ADAPTER="$adapter"
107+
REDMINE_DB_HOST="$host"
108+
echo "$RAILS_ENV:" > config/database.yml
109+
for var in \
110+
adapter \
111+
host \
112+
port \
113+
username \
114+
password \
115+
database \
116+
encoding \
117+
; do
118+
env="REDMINE_DB_${var^^}"
119+
val="${!env}"
120+
[ -n "$val" ] || continue
121+
echo " $var: \"$val\"" >> config/database.yml
122+
done
123+
fi
124+
125+
# install additional gems for Gemfile.local and plugins
126+
bundle check || bundle install
127+
128+
if [ ! -s config/secrets.yml ]; then
129+
file_env 'REDMINE_SECRET_KEY_BASE'
130+
if [ -n "$REDMINE_SECRET_KEY_BASE" ]; then
131+
cat > 'config/secrets.yml' <<-YML
132+
$RAILS_ENV:
133+
secret_key_base: "$REDMINE_SECRET_KEY_BASE"
134+
YML
135+
elif [ ! -f config/initializers/secret_token.rb ]; then
136+
rake generate_secret_token
137+
fi
138+
fi
139+
if [ "$1" != 'rake' -a -z "$REDMINE_NO_DB_MIGRATE" ]; then
140+
rake db:migrate
141+
fi
142+
143+
if [ "$1" != 'rake' -a -n "$REDMINE_PLUGINS_MIGRATE" ]; then
144+
rake redmine:plugins:migrate
145+
fi
146+
147+
# remove PID file to enable restarting the container
148+
rm -f tmp/pids/server.pid
149+
150+
if [ "$1" = 'passenger' ]; then
151+
# Don't fear the reaper.
152+
set -- tini -- "$@"
153+
fi
154+
fi
155+
156+
exec "$@"

0 commit comments

Comments
 (0)