1
- FROM ruby:2.7
2
-
3
- RUN supercronicUrl=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 && \
4
- supercronicBin=/usr/local/bin/supercronic && \
5
- supercronicSha1sum=96960ba3207756bb01e6892c978264e5362e117e && \
6
- curl -fsSL -o "$supercronicBin" "$supercronicUrl" && \
7
- echo "$supercronicSha1sum $supercronicBin" | sha1sum -c - && \
8
- chmod +x "$supercronicBin"
1
+ FROM ruby:2.7 as base
9
2
10
3
ENV PORT=3000 \
11
4
SMTP_SERVER_PORT=2525 \
12
- RAILS_ENV=production \
13
5
RAILS_LOG_TO_STDOUT=true \
14
6
RAILS_SERVE_STATIC_FILES=true
15
7
16
8
WORKDIR /usr/src/app
17
9
18
- COPY . ./
19
-
20
10
# install dependencies and generate crontab
21
- RUN buildDeps='libmagic-dev' && \
11
+ RUN buildDeps='libmagic-dev nodejs chromium' && \
12
+ export DEBIAN_FRONTEND=noninteractive && \
22
13
apt-get update && \
23
14
apt-get install --no-install-recommends -y $buildDeps && \
24
15
echo 'gem: --no-document' >> ~/.gemrc && \
25
16
gem install bundler && \
26
- bundle config build.nokogiri "--use-system-libraries" && \
27
- bundle install --deployment --without development test -j 4 && \
28
- apt-get purge -y --auto-remove $buildDeps && \
29
- rm -Rf /var/lib/apt/lists/* /var/cache/apt/* ~/.gemrc ~/.bundle && \
30
- \
31
- bundle exec whenever >crontab
17
+ bundle config build.nokogiri "--use-system-libraries"
32
18
33
- # compile assets with temporary mysql server
34
- RUN export DATABASE_URL=mysql2://localhost/temp?encoding=utf8 && \
35
- export SECRET_KEY_BASE=thisisnotimportantnow && \
36
- export DEBIAN_FRONTEND=noninteractive && \
37
- apt-get update && \
38
- apt-get install -y mariadb-server nodejs && \
39
- /etc/init.d/mariadb start && \
40
- mariadb -e "CREATE DATABASE temp" && \
41
- cp config/app_config.yml.SAMPLE config/app_config.yml && \
19
+
20
+ COPY bin bin
21
+ COPY plugins plugins
22
+ COPY Gemfile Gemfile.lock docker-entrypoint.sh ./
23
+
24
+ # Development
25
+ FROM base as development
26
+ ENV RAILS_ENV=development \
27
+ CHROMIUM_FLAGS=--no-sandbox
28
+
29
+ RUN bundle install
30
+
31
+ COPY . ./
32
+
33
+ # generate api spec file using nulldb adapter
34
+ RUN cp config/database.yml.NULLDB_SAMPLE config/database.yml && \
35
+ RAILS_ENV=test DB_ADAPTER=nulldb bundle exec rake rswag:specs:swaggerize && \
36
+ rm config/database.yml
37
+
38
+ ENTRYPOINT ["./docker-entrypoint.sh" ]
39
+ CMD ["./proc-start" , "web" ]
40
+
41
+
42
+ # Production
43
+
44
+ FROM base as production
45
+
46
+ ENV RAILS_ENV=production
47
+
48
+ RUN supercronicUrl=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 && \
49
+ supercronicBin=/usr/local/bin/supercronic && \
50
+ supercronicSha1sum=96960ba3207756bb01e6892c978264e5362e117e && \
51
+ curl -fsSL -o "$supercronicBin" "$supercronicUrl" && \
52
+ echo "$supercronicSha1sum $supercronicBin" | sha1sum -c - && \
53
+ chmod +x "$supercronicBin"
54
+
55
+ RUN bundle config set deployment 'true' && \
56
+ bundle install --without development test
57
+
58
+ COPY . ./
59
+ COPY --from=development /usr/src/app/swagger/v1/swagger.yaml /usr/src/app/swagger/v1/swagger.yaml
60
+
61
+ # copy sample configs
62
+ RUN cp config/app_config.yml.SAMPLE config/app_config.yml && \
42
63
cp config/database.yml.MySQL_SAMPLE config/database.yml && \
43
- cp config/storage.yml.SAMPLE config/storage.yml && \
44
- bundle exec rake db:setup assets:precompile && \
45
- rm -Rf tmp/* && \
46
- /etc/init.d/mariadb stop && \
47
- rm -Rf /run/mysqld /tmp/* /var/tmp/* /var/lib/mysql /var/log/mysql* && \
48
- apt-get purge -y --auto-remove mariadb-server && \
49
- rm -Rf /var/lib/apt/lists/* /var/cache/apt/*
64
+ cp config/storage.yml.SAMPLE config/storage.yml
65
+
66
+ # precompile assets
67
+ RUN SECRET_KEY_BASE=42 bundle exec rake assets:precompile
68
+
69
+ # Cleanup
70
+ RUN apt-get purge -y --auto-remove $buildDeps && \
71
+ rm -Rf tmp/* /var/lib/apt/lists/* /var/cache/apt/* ~/.gemrc ~/.bundle && \
72
+ bundle exec whenever >crontab
50
73
51
74
# Make relevant dirs and files writable for app user
52
75
RUN mkdir -p tmp storage && \
@@ -61,6 +84,6 @@ EXPOSE 3000
61
84
62
85
VOLUME /usr/src/app/storage
63
86
64
- # cleanup, and by default start web process from Procfile
87
+ # by default start web process from Procfile
65
88
ENTRYPOINT ["./docker-entrypoint.sh" ]
66
89
CMD ["./proc-start" , "web" ]
0 commit comments