Skip to content

Commit c233dd5

Browse files
committed
Simplifying docker settings
Signed-off-by: Ko Nagase <[email protected]>
1 parent 9e05838 commit c233dd5

7 files changed

+93
-276
lines changed

.env.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Gemfile
2-
GEM_PG_VERSION=1.2.2
3-
4-
# docker-compose.yml - postgres
5-
POSTGRES_USER=gtt
6-
POSTGRES_PASSWORD=gtt
7-
POSTGRES_DB=gtt
1+
# docker-compose.yml - postgis
2+
# config/database.yml
3+
DB_HOST=postgis
4+
DB_NAME=gtt
5+
DB_USER=gtt
6+
DB_PASS=gtt
7+
DB_PORT=5432
88

99
# config/configuration.yml
1010
SMTP_ENABLE_STARTTLS_AUTO=true # (or false)

Dockerfile

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
FROM ruby:2.7-slim-buster
1+
FROM node:16-bullseye-slim as gtt-builder
2+
3+
WORKDIR /app
4+
5+
COPY plugins/redmine_gtt/ ./redmine_gtt/
6+
7+
RUN apt update; \
8+
apt install -y git; \
9+
cd redmine_gtt; \
10+
yarn; \
11+
yarn webpack
12+
13+
FROM ruby:3.1-slim-bullseye as base
214

315
# explicitly set uid/gid to guarantee that it won't change in the future
416
# the values 999:999 are identical to the current user/group id assigned
@@ -8,6 +20,7 @@ RUN set -eux; \
820
apt-get update; \
921
apt-get install -y --no-install-recommends \
1022
ca-certificates \
23+
curl \
1124
wget \
1225
\
1326
# bzr \
@@ -21,8 +34,6 @@ RUN set -eux; \
2134
ghostscript \
2235
gsfonts \
2336
imagemagick \
24-
# https://github.com/docker-library/ruby/issues/344
25-
shared-mime-info \
2637
# grab gosu for easy step-down from root
2738
gosu \
2839
# grab tini for signal processing and zombie killing
@@ -44,89 +55,57 @@ RUN set -eux; \
4455
chown redmine:redmine "$HOME"; \
4556
chmod 1777 "$HOME"
4657

47-
ARG REDMINE_VERSION="4.2.3"
48-
ARG REDMICA_VERSION=""
49-
# ENV REDMINE_DOWNLOAD_SHA256 ad4109c3425f1cfe4c8961f6ae6494c76e20d81ed946caa1e297d9eda13b41b4
58+
ENV REDMINE_VERSION="5.0.0"
59+
ENV REDMINE_DOWNLOAD_URL https://www.redmine.org/releases/redmine-5.0.0.tar.gz
60+
ENV REDMINE_DOWNLOAD_SHA256 7e840dec846646dae52fff5c631b135d1c915d6e03ea6f01ca8f12ad35803bef
5061

5162
RUN set -eux; \
52-
if [ -n "$REDMINE_VERSION" ]; then \
53-
wget -O redmine.tar.gz "https://www.redmine.org/releases/redmine-${REDMINE_VERSION}.tar.gz"; \
54-
# echo "$REDMINE_DOWNLOAD_SHA256 *redmine.tar.gz" | sha256sum -c -;
55-
elif [ -n "$REDMICA_VERSION" ]; then \
56-
wget -O redmine.tar.gz "https://github.com/redmica/redmica/archive/v${REDMICA_VERSION}.tar.gz"; \
57-
fi; \
63+
# if we use wget here, we get certificate issues (https://github.com/docker-library/redmine/pull/249#issuecomment-984176479)
64+
curl -fL -o redmine.tar.gz "$REDMINE_DOWNLOAD_URL"; \
65+
echo "$REDMINE_DOWNLOAD_SHA256 *redmine.tar.gz" | sha256sum -c -; \
5866
tar -xf redmine.tar.gz --strip-components=1; \
5967
rm redmine.tar.gz files/delete.me log/delete.me; \
60-
mkdir -p log public/plugin_assets sqlite tmp/pdf tmp/pids; \
68+
mkdir -p log public/plugin_assets tmp/pdf tmp/pids; \
6169
chown -R redmine:redmine ./; \
62-
# log to STDOUT (https://github.com/docker-library/redmine/issues/108)
63-
echo 'config.logger = Logger.new(STDOUT)' > config/additional_environment.rb; \
6470
# fix permissions for running as an arbitrary user
65-
chmod -R ugo=rwX config db sqlite; \
71+
chmod -R ugo=rwX config; \
6672
find log tmp -type d -exec chmod 1777 '{}' +
6773

68-
# for Redmine patches
69-
ARG PATCH_STRIP=1
70-
ARG PATCH_DIRS=""
71-
COPY patches/ ./patches/
74+
# GTT plugin
75+
COPY --from=gtt-builder --chown=redmine:redmine /app/ ./plugins/
76+
77+
COPY --chown=redmine:redmine config/ ./config/
7278

73-
# for GTT gem native extensions
74-
ARG GEM_PG_VERSION="1.2.3"
75-
COPY Gemfile.local ./
76-
COPY plugins/ ./plugins/
79+
COPY --chown=redmine:redmine Gemfile.local ./
80+
81+
# Other plugins
82+
COPY --chown=redmine:redmine plugins/redmine_gtt_smash/ ./plugins/redmine_gtt_smash/
83+
COPY --chown=redmine:redmine plugins/redmine_text_blocks/ ./plugins/redmine_text_blocks/
84+
85+
# Themes (if exists)
86+
COPY --chown=redmine:redmine public/themes/ ./public/themes/
87+
88+
FROM base
7789

7890
RUN set -eux; \
7991
\
8092
savedAptMark="$(apt-mark showmanual)"; \
8193
apt-get update; \
8294
apt-get install -y --no-install-recommends \
95+
# default-libmysqlclient-dev \
8396
# freetds-dev \
8497
gcc \
85-
# libmariadbclient-dev \
8698
libpq-dev \
8799
# libsqlite3-dev \
88100
make \
89101
patch \
90-
# in 4.1+, libmagickcore-dev and libmagickwand-dev are no longer necessary/used: https://www.redmine.org/issues/30492
91-
libmagickcore-dev libmagickwand-dev \
92102
# for GTT dependencies
93-
g++ \
94103
libgeos-dev \
95-
curl \
96104
; \
97105
rm -rf /var/lib/apt/lists/*; \
98106
\
99-
if [ -n "$PATCH_DIRS" ]; then \
100-
for dir in $(echo $PATCH_DIRS | sed "s/,/ /g"); do \
101-
for file in ./patches/"$dir"/*; do \
102-
patch -p"$PATCH_STRIP" < $file; \
103-
done; \
104-
done; \
105-
rm -rf ./patches/*; \
106-
fi; \
107-
curl -sL https://deb.nodesource.com/setup_14.x | bash -; \
108-
apt-get install -y --no-install-recommends nodejs; \
109-
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \
110-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \
111-
apt-get update; \
112-
apt-get install -y --no-install-recommends yarn; \
113-
for plugin in ./plugins/*; do \
114-
if [ -f "$plugin/webpack.config.js" ]; then \
115-
cd "$plugin" && yarn && npx webpack && rm -rf node_modules && cd ../..; \
116-
fi; \
117-
done; \
118-
export GEM_PG_VERSION="$GEM_PG_VERSION"; \
119107
gosu redmine bundle config --local without 'development test'; \
120-
# fill up "database.yml" with bogus entries so the redmine Gemfile will pre-install all database adapter dependencies
121-
# https://github.com/redmine/redmine/blob/e9f9767089a4e3efbd73c35fc55c5c7eb85dd7d3/Gemfile#L50-L79
122-
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; \
123-
# for adapter in mysql2 postgresql sqlserver sqlite3; do \
124-
for adapter in postgis; do \
125-
echo "$adapter:" >> ./config/database.yml; \
126-
echo " adapter: $adapter" >> ./config/database.yml; \
127-
done; \
128108
gosu redmine bundle install --jobs "$(nproc)"; \
129-
rm ./config/database.yml; \
130109
# fix permissions for running as an arbitrary user
131110
chmod -R ugo=rwX Gemfile.lock "$GEM_HOME"; \
132111
rm -rf ~redmine/.bundle; \
@@ -145,7 +124,6 @@ RUN set -eux; \
145124
; \
146125
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
147126

148-
COPY config/ ./config/
149127
VOLUME /usr/src/redmine/files
150128

151129
COPY docker-entrypoint.sh /

Gemfile.local

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
source 'https://rubygems.org'
2-
3-
# each plugin's native extensions should be added to here
4-
gem "rgeo"
5-
gem "pg", (ENV['GEM_PG_VERSION'] ? "~> #{ENV['GEM_PG_VERSION']}" : "~> 1.2.3")
1+
gem 'puma'

config/additional_environment.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copy this file to additional_environment.rb and add any statements
2+
# that need to be passed to the Rails::Initializer. `config` is
3+
# available in this context.
4+
#
5+
# Example:
6+
#
7+
# config.log_level = :debug
8+
# ...
9+
#
10+
11+
config.logger = Logger.new(STDOUT)

config/database.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
default: &default
2+
adapter: postgis
3+
database: <%= ENV['DB_NAME'] %>
4+
host: <%= ENV['DB_HOST'] %>
5+
username: <%= ENV['DB_USER'] %>
6+
password: <%= ENV['DB_PASS'] %>
7+
port: <%= ENV['DB_PORT'] || 5432 %>
8+
encoding: utf8
9+
10+
production:
11+
<<: *default
12+
13+
test:
14+
<<: *default
15+
16+
development:
17+
<<: *default

docker-compose.yml

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,28 @@
11
version: "3"
22

33
services:
4+
postgis:
5+
image: postgis/postgis:14-3.2
6+
environment:
7+
POSTGRES_PASSWORD: ${DB_PASS}
8+
POSTGRES_USER: ${DB_USER}
9+
POSTGRES_DB: ${DB_NAME}
10+
volumes:
11+
- postgis:/var/lib/postgresql/data
412

5-
gtt:
13+
redmine:
614
build:
7-
context: ./
8-
dockerfile: ./Dockerfile
9-
args:
10-
REDMINE_VERSION: 4.2.3
11-
REDMICA_VERSION: ""
12-
GEM_PG_VERSION: ${GEM_PG_VERSION}
13-
PATCH_STRIP: 1
14-
PATCH_DIRS: ""
15+
context: .
1516
ports:
1617
- 3000:3000
17-
environment:
18-
REDMINE_DB_POSTGRES: postgres
19-
REDMINE_DB_USERNAME: ${POSTGRES_USER}
20-
REDMINE_DB_PASSWORD: ${POSTGRES_PASSWORD}
21-
REDMINE_DB_DATABASE: ${POSTGRES_DB}
22-
REDMINE_PLUGINS_MIGRATE: 1
23-
# Gemfile
24-
GEM_PG_VERSION: ${GEM_PG_VERSION}
25-
# config/configuration.yml
26-
SMTP_ENABLE_STARTTLS_AUTO: ${SMTP_ENABLE_STARTTLS_AUTO}
27-
SMTP_ADDRESS: ${SMTP_ADDRESS}
28-
SMTP_PORT: ${SMTP_PORT}
29-
SMTP_DOMAIN: ${SMTP_DOMAIN}
30-
SMTP_AUTHENTICATION: ${SMTP_AUTHENTICATION}
31-
SMTP_USER_NAME: ${SMTP_USER_NAME}
32-
SMTP_PASSWORD: ${SMTP_PASSWORD}
18+
env_file:
19+
- .env
3320
volumes:
3421
- ./files:/usr/src/redmine/files
3522
- ./plugins:/usr/src/redmine/plugins
3623
- ./public/themes:/usr/src/redmine/public/themes
37-
# Exclude node package and webpack contents folders
38-
- /usr/src/redmine/plugins/redmine_gtt/node_modules
39-
- /usr/src/redmine/plugins/redmine_gtt/assets/javascripts
4024
depends_on:
41-
- postgres
42-
- mapfish-print
43-
restart: always
44-
45-
postgres:
46-
image: postgis/postgis:13-3.1
47-
environment:
48-
POSTGRES_USER: ${POSTGRES_USER}
49-
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
50-
POSTGRES_DB: ${POSTGRES_DB}
51-
volumes:
52-
- postgres:/var/lib/postgresql/data
53-
restart: always
54-
55-
mapfish-print:
56-
image: camptocamp/mapfish_print:3.28
57-
ports:
58-
- 8080:8080
59-
environment:
60-
EXTRA_JARS: /usr/local/tomcat/webapps/ROOT/print-apps/lib
61-
volumes:
62-
- ./mapfish-print-apps:/usr/local/tomcat/webapps/ROOT/print-apps
63-
restart: always
25+
- postgis
6426

6527
volumes:
66-
gtt:
67-
postgres:
68-
mapfish-print:
28+
postgis:

0 commit comments

Comments
 (0)