forked from opf/openproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
96 lines (78 loc) · 3.32 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
FROM ruby:2.6-stretch
MAINTAINER [email protected]
ENV NODE_VERSION "10.15.0"
ENV BUNDLER_VERSION "2.0.2"
ENV APP_USER app
ENV APP_PATH /app
ENV APP_DATA_PATH /var/openproject/assets
ENV APP_DATA_PATH_LEGACY /var/db/openproject
ENV PGDATA /var/openproject/pgdata
ENV PGDATA_LEGACY /var/lib/postgresql/9.6/main
ENV DATABASE_URL postgres://openproject:[email protected]/openproject
ENV RAILS_ENV production
ENV HEROKU true
ENV RAILS_CACHE_STORE memcache
ENV OPENPROJECT_INSTALLATION__TYPE docker
ENV NEW_RELIC_AGENT_ENABLED false
ENV ATTACHMENTS_STORAGE_PATH $APP_DATA_PATH/files
ENV BUNDLE_PATH__SYSTEM=false
ENV PGLOADER_DEPENDENCIES "libsqlite3-dev make curl gawk freetds-dev libzip-dev"
# Set a default key base, ensure to provide a secure value in production environments!
ENV SECRET_KEY_BASE OVERWRITE_ME
# install node + npm
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
RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
postgresql-client \
mysql-client \
poppler-utils \
unrtf \
tesseract-ocr \
catdoc \
memcached \
postfix \
postgresql \
$PGLOADER_DEPENDENCIES \
apache2 \
supervisor && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# pgloader
ENV CCL_DEFAULT_DIRECTORY /opt/ccl
COPY docker/mysql-to-postgres/bin/build /tmp/build-pgloader
RUN /tmp/build-pgloader && rm /tmp/build-pgloader
# Add MySQL-to-Postgres migration script to path (used in entrypoint.sh)
COPY docker/mysql-to-postgres/bin/migrate-mysql-to-postgres /usr/local/bin/
# Set up pg defaults
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.6/main/postgresql.conf
RUN echo "data_directory='$PGDATA'" >> /etc/postgresql/9.6/main/postgresql.conf
RUN rm -rf "$PGDATA_LEGACY" && rm -rf "$PGDATA" && mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"
RUN a2enmod proxy proxy_http && rm -f /etc/apache2/sites-enabled/000-default.conf
# using /home/app since npm cache and other stuff will be put there when running npm install
# we don't want to pollute any locally-mounted directory
RUN useradd -d /home/$APP_USER -m $APP_USER
WORKDIR $APP_PATH
RUN gem install bundler --version "${bundler_version}" --no-document
COPY Gemfile ./Gemfile
COPY Gemfile.* ./
COPY modules ./modules
# OpenProject::Version is required by module versions in gemspecs
RUN mkdir -p lib/open_project
COPY lib/open_project/version.rb ./lib/open_project/
RUN bundle install --deployment --path vendor/bundle --with="docker opf_plugins" --without="test development" --jobs=8 --retry=3
# Finally, copy over the whole thing
COPY . $APP_PATH
RUN sed -i "s|Rails.groups(:opf_plugins)|Rails.groups(:opf_plugins, :docker)|" config/application.rb
# Ensure we can write in /tmp/op_uploaded_files (cf. #29112)
RUN mkdir -p /tmp/op_uploaded_files/ && chown -R $APP_USER:$APP_USER /tmp/op_uploaded_files/
# Re-use packager database.yml
COPY packaging/conf/database.yml ./config/database.yml
# Run the npm postinstall manually after it was copied
# Then, npm install node modules
RUN bash docker/precompile-assets.sh
# ports
EXPOSE 80 5432
# volumes to export
VOLUME ["$PGDATA", "$APP_DATA_PATH"]
ENTRYPOINT ["./docker/entrypoint.sh"]
CMD ["./docker/supervisord"]