2023-01-16 15:31:13 +01:00
|
|
|
FROM ruby:2.7
|
2015-04-26 15:20:05 +02:00
|
|
|
|
2017-10-01 13:57:36 +02:00
|
|
|
RUN supercronicUrl=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 && \
|
|
|
|
supercronicBin=/usr/local/bin/supercronic && \
|
|
|
|
supercronicSha1sum=96960ba3207756bb01e6892c978264e5362e117e && \
|
|
|
|
curl -fsSL -o "$supercronicBin" "$supercronicUrl" && \
|
|
|
|
echo "$supercronicSha1sum $supercronicBin" | sha1sum -c - && \
|
|
|
|
chmod +x "$supercronicBin"
|
2015-04-26 15:20:05 +02:00
|
|
|
|
2017-10-01 13:57:36 +02:00
|
|
|
ENV PORT=3000 \
|
|
|
|
SMTP_SERVER_PORT=2525 \
|
|
|
|
RAILS_ENV=production \
|
|
|
|
RAILS_LOG_TO_STDOUT=true \
|
2017-08-03 14:36:17 +02:00
|
|
|
RAILS_SERVE_STATIC_FILES=true
|
2015-04-26 15:20:05 +02:00
|
|
|
|
2017-02-11 12:44:49 +01:00
|
|
|
WORKDIR /usr/src/app
|
2017-10-01 13:57:36 +02:00
|
|
|
|
2016-02-06 15:52:23 +01:00
|
|
|
COPY . ./
|
2017-08-02 21:02:39 +02:00
|
|
|
|
2017-10-01 13:57:36 +02:00
|
|
|
# install dependencies and generate crontab
|
2017-08-02 21:02:39 +02:00
|
|
|
RUN buildDeps='libmagic-dev' && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install --no-install-recommends -y $buildDeps && \
|
2017-10-01 13:57:36 +02:00
|
|
|
echo 'gem: --no-document' >> ~/.gemrc && \
|
2024-02-22 21:06:02 +01:00
|
|
|
gem install bundler -v 2.4.22 && \
|
2017-10-01 13:57:36 +02:00
|
|
|
bundle config build.nokogiri "--use-system-libraries" && \
|
|
|
|
bundle install --deployment --without development test -j 4 && \
|
2017-08-02 21:02:39 +02:00
|
|
|
apt-get purge -y --auto-remove $buildDeps && \
|
2017-10-01 13:57:36 +02:00
|
|
|
rm -Rf /var/lib/apt/lists/* /var/cache/apt/* ~/.gemrc ~/.bundle && \
|
|
|
|
\
|
|
|
|
bundle exec whenever >crontab
|
2015-04-26 15:20:05 +02:00
|
|
|
|
2017-10-01 13:57:36 +02:00
|
|
|
# compile assets with temporary mysql server
|
2018-12-18 15:19:55 +01:00
|
|
|
RUN export DATABASE_URL=mysql2://localhost/temp?encoding=utf8 && \
|
2017-10-01 13:57:36 +02:00
|
|
|
export SECRET_KEY_BASE=thisisnotimportantnow && \
|
2017-08-03 02:25:40 +02:00
|
|
|
export DEBIAN_FRONTEND=noninteractive && \
|
|
|
|
apt-get update && \
|
2022-02-20 04:13:36 +01:00
|
|
|
apt-get install -y mariadb-server nodejs && \
|
|
|
|
/etc/init.d/mariadb start && \
|
2020-08-01 00:20:42 +02:00
|
|
|
mariadb -e "CREATE DATABASE temp" && \
|
2017-08-03 02:25:40 +02:00
|
|
|
cp config/app_config.yml.SAMPLE config/app_config.yml && \
|
2018-12-18 15:19:55 +01:00
|
|
|
cp config/database.yml.MySQL_SAMPLE config/database.yml && \
|
2022-01-31 08:44:53 +01:00
|
|
|
cp config/storage.yml.SAMPLE config/storage.yml && \
|
2017-10-01 13:57:36 +02:00
|
|
|
bundle exec rake db:setup assets:precompile && \
|
2018-12-18 15:30:55 +01:00
|
|
|
rm -Rf tmp/* && \
|
2022-02-20 04:13:36 +01:00
|
|
|
/etc/init.d/mariadb stop && \
|
2017-10-01 13:57:36 +02:00
|
|
|
rm -Rf /run/mysqld /tmp/* /var/tmp/* /var/lib/mysql /var/log/mysql* && \
|
2019-10-28 09:39:32 +01:00
|
|
|
apt-get purge -y --auto-remove mariadb-server && \
|
2017-10-01 13:57:36 +02:00
|
|
|
rm -Rf /var/lib/apt/lists/* /var/cache/apt/*
|
|
|
|
|
2018-12-18 15:30:55 +01:00
|
|
|
# Make relevant dirs and files writable for app user
|
2023-08-04 10:52:30 +02:00
|
|
|
RUN mkdir -p tmp storage && \
|
2018-12-18 15:30:55 +01:00
|
|
|
chown nobody config/app_config.yml && \
|
2023-08-04 10:52:30 +02:00
|
|
|
chown nobody tmp && \
|
|
|
|
chown nobody storage
|
2017-10-01 13:57:36 +02:00
|
|
|
|
|
|
|
# Run app as unprivileged user
|
|
|
|
USER nobody
|
2017-08-03 02:25:40 +02:00
|
|
|
|
2015-04-26 15:20:05 +02:00
|
|
|
EXPOSE 3000
|
|
|
|
|
2022-01-31 08:44:53 +01:00
|
|
|
VOLUME /usr/src/app/storage
|
|
|
|
|
2017-10-01 13:57:36 +02:00
|
|
|
# cleanup, and by default start web process from Procfile
|
2017-02-11 12:44:49 +01:00
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|
2017-10-01 13:57:36 +02:00
|
|
|
CMD ["./proc-start", "web"]
|