|
1 | 1 | FROM ruby:2.6-stretch
|
| 2 | +MAINTAINER operations@openproject.com |
2 | 3 |
|
3 |
| -ENV NODE_VERSION="10.15.0" |
4 |
| -ENV BUNDLER_VERSION="2.0.1" |
| 4 | +ENV NODE_VERSION "10.15.0" |
| 5 | +ENV BUNDLER_VERSION "2.0.1" |
5 | 6 | ENV APP_USER app
|
6 |
| -ENV APP_PATH /usr/src/app |
7 |
| -ENV APP_DATA /var/db/openproject |
8 |
| -ENV ATTACHMENTS_STORAGE_PATH /var/db/openproject/files |
| 7 | +ENV APP_PATH /app |
| 8 | +ENV APP_DATA_PATH /var/openproject/assets |
| 9 | +ENV APP_DATA_PATH_LEGACY /var/db/openproject |
| 10 | +ENV PGDATA /var/openproject/pgdata |
| 11 | +ENV PGDATA_LEGACY /var/lib/postgresql/9.6/main |
| 12 | + |
| 13 | +ENV DATABASE_URL postgres://openproject:openproject@127.0.0.1/openproject |
| 14 | +ENV RAILS_ENV production |
| 15 | +ENV HEROKU true |
| 16 | +ENV RAILS_CACHE_STORE memcache |
| 17 | +ENV OPENPROJECT_INSTALLATION__TYPE docker |
| 18 | +ENV NEW_RELIC_AGENT_ENABLED false |
| 19 | +ENV ATTACHMENTS_STORAGE_PATH $APP_DATA_PATH/files |
9 | 20 |
|
10 | 21 | # Set a default key base, ensure to provide a secure value in production environments!
|
11 |
| -ENV SECRET_KEY_BASE=OVERWRITE_ME |
| 22 | +ENV SECRET_KEY_BASE OVERWRITE_ME |
12 | 23 |
|
13 | 24 | # install node + npm
|
14 | 25 | RUN curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz | tar xzf - -C /usr/local --strip-components=1
|
15 | 26 |
|
16 | 27 | RUN apt-get update -qq && \
|
17 |
| - DEBIAN_FRONTEND=noninteractive apt-get install -y \ |
18 |
| - postgresql-client \ |
19 |
| - mysql-client \ |
20 |
| - sqlite \ |
21 |
| - poppler-utils \ |
22 |
| - unrtf \ |
23 |
| - tesseract-ocr \ |
24 |
| - catdoc && \ |
25 |
| - apt-get clean && rm -rf /var/lib/apt/lists/* |
| 28 | + DEBIAN_FRONTEND=noninteractive apt-get install -y \ |
| 29 | + postgresql-client \ |
| 30 | + poppler-utils \ |
| 31 | + unrtf \ |
| 32 | + tesseract-ocr \ |
| 33 | + catdoc \ |
| 34 | + memcached \ |
| 35 | + postfix \ |
| 36 | + postgresql \ |
| 37 | + apache2 \ |
| 38 | + supervisor && \ |
| 39 | + apt-get clean && rm -rf /var/lib/apt/lists/* |
| 40 | + |
| 41 | +# Set up pg defaults |
| 42 | +RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.6/main/pg_hba.conf |
| 43 | +RUN echo "listen_addresses='*'" >> /etc/postgresql/9.6/main/postgresql.conf |
| 44 | +RUN echo "data_directory='$PGDATA'" >> /etc/postgresql/9.6/main/postgresql.conf |
| 45 | +RUN rm -rf "$PGDATA_LEGACY" && rm -rf "$PGDATA" && mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" |
| 46 | +RUN a2enmod proxy proxy_http && rm -f /etc/apache2/sites-enabled/000-default.conf |
26 | 47 |
|
27 | 48 | # using /home/app since npm cache and other stuff will be put there when running npm install
|
28 | 49 | # we don't want to pollute any locally-mounted directory
|
29 | 50 | RUN useradd -d /home/$APP_USER -m $APP_USER
|
30 |
| -RUN mkdir -p $APP_PATH $APP_DATA |
31 |
| -RUN gem install bundler --version "${bundler_version}" --no-document |
32 | 51 |
|
33 | 52 | WORKDIR $APP_PATH
|
| 53 | +RUN gem install bundler --version "${bundler_version}" --no-document |
34 | 54 |
|
35 | 55 | COPY Gemfile ./Gemfile
|
36 | 56 | COPY Gemfile.* ./
|
37 | 57 | COPY modules ./modules
|
38 | 58 | # OpenProject::Version is required by module versions in gemspecs
|
39 | 59 | RUN mkdir -p lib/open_project
|
40 | 60 | COPY lib/open_project/version.rb ./lib/open_project/
|
41 |
| -RUN bundle install --deployment --with="docker opf_plugins" --without="test development" --jobs=8 --retry=3 |
42 |
| - |
43 |
| -# Then, npm install node modules |
44 |
| -COPY package.json /tmp/npm/package.json |
45 |
| -COPY frontend/*.json /tmp/npm/frontend/ |
46 |
| -RUN cd /tmp/npm/frontend/ && RAILS_ENV=production npm install && mv /tmp/npm/frontend /usr/src/app/ |
| 61 | +RUN bundle install --deployment --with="docker opf_plugins" --without="test development mysql2" --jobs=8 --retry=3 |
47 | 62 |
|
48 | 63 | # Finally, copy over the whole thing
|
49 |
| -COPY . /usr/src/app |
50 |
| -RUN mkdir $APP_PATH/tmp |
51 |
| -RUN chown -R $APP_USER:$APP_USER $APP_PATH |
52 |
| -RUN cp docker/Procfile . |
53 |
| -RUN cp packaging/conf/database.yml config/ |
| 64 | +COPY . $APP_PATH |
| 65 | + |
54 | 66 | RUN sed -i "s|Rails.groups(:opf_plugins)|Rails.groups(:opf_plugins, :docker)|" config/application.rb
|
55 | 67 |
|
56 | 68 | # Ensure we can write in /tmp/op_uploaded_files (cf. #29112)
|
57 |
| -RUN mkdir -p /tmp/op_uploaded_files/ |
58 |
| -RUN chown -R $APP_USER:$APP_USER /tmp/op_uploaded_files/ |
59 |
| - |
60 |
| -# Allow uploading avatars w/ postgres |
61 |
| -RUN chown -R $APP_USER:$APP_USER $APP_DATA |
| 69 | +RUN mkdir -p /tmp/op_uploaded_files/ && chown -R $APP_USER:$APP_USER /tmp/op_uploaded_files/ |
62 | 70 |
|
63 | 71 | # Re-use packager database.yml
|
64 | 72 | COPY packaging/conf/database.yml ./config/database.yml
|
65 | 73 |
|
66 | 74 | # Run the npm postinstall manually after it was copied
|
67 |
| -RUN DATABASE_URL=sqlite3:///tmp/db.sqlite3 RAILS_ENV=production bundle exec rake assets:precompile |
| 75 | +# Then, npm install node modules |
| 76 | +RUN bash docker/precompile-assets.sh |
68 | 77 |
|
69 |
| -# Include pandoc |
70 |
| -RUN DATABASE_URL=sqlite3:///tmp/db.sqlite3 RAILS_ENV=production bundle exec rails runner "puts ::OpenProject::TextFormatting::Formats::Markdown::PandocDownloader.check_or_download!" |
| 78 | +# ports |
| 79 | +EXPOSE 80 5432 |
71 | 80 |
|
72 |
| -CMD ["./docker/web"] |
| 81 | +# volumes to export |
| 82 | +VOLUME ["$PGDATA", "$APP_DATA_PATH"] |
73 | 83 | ENTRYPOINT ["./docker/entrypoint.sh"]
|
74 |
| -VOLUME ["$APP_DATA"] |
| 84 | +CMD ["./docker/supervisord"] |
| 85 | + |
0 commit comments