-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
155 lines (143 loc) · 5.21 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
FROM ruby:2.7-slim-buster
# explicitly set uid/gid to guarantee that it won't change in the future
# the values 999:999 are identical to the current user/group id assigned
RUN groupadd -r -g 999 redmine && useradd -r -g redmine -u 999 redmine
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
wget \
\
# bzr \
# git \
# mercurial \
openssh-client \
# subversion \
\
# we need "gsfonts" for generating PNGs of Gantt charts
# and "ghostscript" for creating PDF thumbnails (in 4.1+)
ghostscript \
gsfonts \
imagemagick \
# https://github.com/docker-library/ruby/issues/344
shared-mime-info \
# grab gosu for easy step-down from root
gosu \
# grab tini for signal processing and zombie killing
tini \
; \
# allow imagemagick to use ghostscript for PDF -> PNG thumbnail conversion (4.1+)
sed -ri 's/(rights)="none" (pattern="PDF")/\1="read" \2/' /etc/ImageMagick-6/policy.xml; \
rm -rf /var/lib/apt/lists/*
ENV RAILS_ENV production
WORKDIR /usr/src/redmine
# https://github.com/docker-library/redmine/issues/138#issuecomment-438834176
# (bundler needs this for running as an arbitrary user)
ENV HOME /home/redmine
RUN set -eux; \
[ ! -d "$HOME" ]; \
mkdir -p "$HOME"; \
chown redmine:redmine "$HOME"; \
chmod 1777 "$HOME"
ARG REDMINE_VERSION="4.2.3"
ARG REDMICA_VERSION=""
# ENV REDMINE_DOWNLOAD_SHA256 ad4109c3425f1cfe4c8961f6ae6494c76e20d81ed946caa1e297d9eda13b41b4
RUN set -eux; \
if [ -n "$REDMINE_VERSION" ]; then \
wget -O redmine.tar.gz "https://www.redmine.org/releases/redmine-${REDMINE_VERSION}.tar.gz"; \
# echo "$REDMINE_DOWNLOAD_SHA256 *redmine.tar.gz" | sha256sum -c -;
elif [ -n "$REDMICA_VERSION" ]; then \
wget -O redmine.tar.gz "https://github.com/redmica/redmica/archive/v${REDMICA_VERSION}.tar.gz"; \
fi; \
tar -xf redmine.tar.gz --strip-components=1; \
rm redmine.tar.gz files/delete.me log/delete.me; \
mkdir -p log public/plugin_assets sqlite tmp/pdf tmp/pids; \
chown -R redmine:redmine ./; \
# log to STDOUT (https://github.com/docker-library/redmine/issues/108)
echo 'config.logger = Logger.new(STDOUT)' > config/additional_environment.rb; \
# fix permissions for running as an arbitrary user
chmod -R ugo=rwX config db sqlite; \
find log tmp -type d -exec chmod 1777 '{}' +
# for Redmine patches
ARG PATCH_STRIP=1
ARG PATCH_DIRS=""
COPY patches/ ./patches/
# for GTT gem native extensions
ARG GEM_PG_VERSION="1.2.3"
COPY Gemfile.local ./
COPY plugins/ ./plugins/
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
# freetds-dev \
gcc \
# libmariadbclient-dev \
libpq-dev \
# libsqlite3-dev \
make \
patch \
# in 4.1+, libmagickcore-dev and libmagickwand-dev are no longer necessary/used: https://www.redmine.org/issues/30492
libmagickcore-dev libmagickwand-dev \
# for GTT dependencies
g++ \
libgeos-dev \
curl \
; \
rm -rf /var/lib/apt/lists/*; \
\
if [ -n "$PATCH_DIRS" ]; then \
for dir in $(echo $PATCH_DIRS | sed "s/,/ /g"); do \
for file in ./patches/"$dir"/*; do \
patch -p"$PATCH_STRIP" < $file; \
done; \
done; \
rm -rf ./patches/*; \
fi; \
curl -sL https://deb.nodesource.com/setup_14.x | bash -; \
apt-get install -y --no-install-recommends nodejs; \
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \
apt-get update; \
apt-get install -y --no-install-recommends yarn; \
for plugin in ./plugins/*; do \
if [ -f "$plugin/webpack.config.js" ]; then \
cd "$plugin" && yarn && npx webpack && rm -rf node_modules && cd ../..; \
fi; \
done; \
export GEM_PG_VERSION="$GEM_PG_VERSION"; \
gosu redmine bundle config --local without 'development test'; \
# fill up "database.yml" with bogus entries so the redmine Gemfile will pre-install all database adapter dependencies
# https://github.com/redmine/redmine/blob/e9f9767089a4e3efbd73c35fc55c5c7eb85dd7d3/Gemfile#L50-L79
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; \
# for adapter in mysql2 postgresql sqlserver sqlite3; do \
for adapter in postgis; do \
echo "$adapter:" >> ./config/database.yml; \
echo " adapter: $adapter" >> ./config/database.yml; \
done; \
gosu redmine bundle install --jobs "$(nproc)"; \
rm ./config/database.yml; \
# fix permissions for running as an arbitrary user
chmod -R ugo=rwX Gemfile.lock "$GEM_HOME"; \
rm -rf ~redmine/.bundle; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| grep -v '^/usr/local/' \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
COPY config/ ./config/
VOLUME /usr/src/redmine/files
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]