-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
136 lines (130 loc) · 6.39 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
ARG RUBY_VERSION
FROM ruby:${RUBY_VERSION}-slim
ARG REDMINE_VERSION
RUN apt-get -y update \
&& apt-get -y install --no-install-recommends \
build-essential libsqlite3-dev git wget unzip \
lsb-release \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatspi2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxss1 \
libxtst6 \
xdg-utils \
ruby-rmagick \
libmagick++-dev \
gnupg2 \
mariadb-server \
libmariadb-dev \
libdrm2 \
libgbm1 \
libxcb-dri3-0 \
libxshmfence1
RUN apt-get -y install --no-install-recommends \
sudo \
curl \
ca-certificates \
gnupg \
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& apt-get -y update \
&& apt-get -y install postgresql-9.6 postgresql-server-dev-9.6 \
&& sh -c "sed s/#listen_addresses\ =\ \'localhost\'/listen_addresses\ =\ \'*\'/ -i /etc/postgresql/9.6/main/postgresql.conf"
RUN rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
RUN mkdir instchrome \
&& cd instchrome \
&& export CHROME_VER=`wget -q https://chromedriver.storage.googleapis.com/LATEST_RELEASE -O -` \
&& export CHROME_DL_URL=https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& export CHROMEDRV_DL_URL=https://chromedriver.storage.googleapis.com/${CHROME_VER}/chromedriver_linux64.zip \
&& wget -q -c -nc --retry-connrefused --tries=0 ${CHROME_DL_URL} \
&& dpkg -i google-chrome-stable_current_amd64.deb \
&& wget -q -c -nc --retry-connrefused --tries=0 https://dl.google.com/linux/linux_signing_key.pub \
&& apt-key add linux_signing_key.pub \
&& wget -q -c -nc --retry-connrefused --tries=0 ${CHROMEDRV_DL_URL} \
&& unzip chromedriver_linux64.zip \
&& mv chromedriver /usr/bin/ \
&& chmod +x /usr/bin/chromedriver \
&& cd .. \
&& rm -rf instchrome
ENV REDMINE_GIT_REPO=https://github.com/redmine/redmine.git
ENV PATH_TO_REDMINE=/var/lib/redmine
ENV REDMINE_DB=${PATH_TO_REDMINE}/config/database.yml
ENV REDMINE_DB_SQLITE3=${PATH_TO_REDMINE}/config/database.yml.sqlite3
ENV REDMINE_DB_POSTGRESQL=${PATH_TO_REDMINE}/config/database.yml.postgresql
ENV REDMINE_DB_MYSQL=${PATH_TO_REDMINE}/config/database.yml.mysql
WORKDIR ${PATH_TO_REDMINE}
RUN git clone -b ${REDMINE_VERSION} --depth 1 ${REDMINE_GIT_REPO} ${PATH_TO_REDMINE} \
&& mkdir -p vendor/bundle
# for postgresql
RUN echo "development:" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " adapter: postgresql" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " database: redmine" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " host: localhost" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " username: redmine" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " password: ""redmine""" >> ${REDMINE_DB_POSTGRESQL} \
&& echo "test:" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " adapter: postgresql" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " database: redmine_test" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " host: localhost" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " username: redmine" >> ${REDMINE_DB_POSTGRESQL} \
&& echo " password: ""redmine""" >> ${REDMINE_DB_POSTGRESQL}
# for mysql
RUN if [ "${RUBY_VERSION%\.*}" = "2.3" ]; then export DB_ENCODING=utf8; else export DB_ENCODING=utf8mb4; fi \
&& echo "development:" >> ${REDMINE_DB_MYSQL} \
&& echo " adapter: mysql2" >> ${REDMINE_DB_MYSQL} \
&& echo " database: redmine" >> ${REDMINE_DB_MYSQL} \
&& echo " host: localhost" >> ${REDMINE_DB_MYSQL} \
&& echo " username: root" >> ${REDMINE_DB_MYSQL} \
&& echo " password: """"" >> ${REDMINE_DB_MYSQL} \
&& echo " encoding: ${DB_ENCODING}" >> ${REDMINE_DB_MYSQL} \
&& echo "test:" >> ${REDMINE_DB_MYSQL} \
&& echo " adapter: mysql2" >> ${REDMINE_DB_MYSQL} \
&& echo " database: redmine_test" >> ${REDMINE_DB_MYSQL} \
&& echo " host: localhost" >> ${REDMINE_DB_MYSQL} \
&& echo " username: root" >> ${REDMINE_DB_MYSQL} \
&& echo " password: """"" >> ${REDMINE_DB_MYSQL} \
&& echo " encoding: ${DB_ENCODING}" >> ${REDMINE_DB_MYSQL}
# for sqlite3
RUN echo "development:" >> ${REDMINE_DB_SQLITE3} \
&& echo " adapter: sqlite3" >> ${REDMINE_DB_SQLITE3} \
&& echo " database: db/redmine_dev.sqlite3" >> ${REDMINE_DB_SQLITE3} \
&& echo "test:" >> ${REDMINE_DB_SQLITE3} \
&& echo " adapter: sqlite3" >> ${REDMINE_DB_SQLITE3} \
&& echo " database: db/redmine_test.sqlite3" >> ${REDMINE_DB_SQLITE3}
# Prepare database for postgresql
RUN cp ${REDMINE_DB_POSTGRESQL} ${REDMINE_DB} \
&& bundle install --path vendor/bundle \
&& service postgresql start \
&& sudo -u postgres psql -q -U postgres -c "CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redmine' NOINHERIT VALID UNTIL 'infinity';" \
&& sudo -u postgres psql -q -U postgres -c "ALTER ROLE redmine WITH CREATEDB;" \
&& sudo -u postgres psql -q -U postgres -c "CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;" \
&& sudo -u postgres psql -q -U postgres -c "CREATE DATABASE redmine_test WITH ENCODING='UTF8' OWNER=redmine;" \
&& bundle exec rake db:migrate \
&& bundle exec rake redmine:load_default_data REDMINE_LANG=en \
&& bundle exec rake generate_secret_token
# Prepare database for mysql
RUN cp ${REDMINE_DB_MYSQL} ${REDMINE_DB} \
&& bundle install --path vendor/bundle \
&& service mysql start \
&& if [ "${RUBY_VERSION%\.*}" = "2.3" ]; then export DB_ENCODING=utf8; else export DB_ENCODING=utf8mb4; fi \
&& mysql -u root -e"CREATE DATABASE redmine CHARACTER SET ${DB_ENCODING};" \
&& mysql -u root -e"CREATE DATABASE redmine_test CHARACTER SET ${DB_ENCODING};" \
&& mysql -u root -e"CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine';" \
&& mysql -u root -e"GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';" \
&& mysql -u root -e"GRANT ALL PRIVILEGES ON redmine_test.* TO 'redmine'@'localhost';" \
&& bundle exec rake db:migrate \
&& bundle exec rake redmine:load_default_data REDMINE_LANG=en \
&& bundle exec rake generate_secret_token
# Prepare database for sqlites
RUN cp ${REDMINE_DB_SQLITE3} ${REDMINE_DB} \
&& bundle install --path vendor/bundle \
&& bundle exec rake db:migrate \
&& bundle exec rake redmine:load_default_data REDMINE_LANG=en \
&& bundle exec rake generate_secret_token