-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Containerfile
87 lines (74 loc) · 3.18 KB
/
Containerfile
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
# Container image for a production Retrospring setup
FROM registry.opensuse.org/opensuse/leap:15.5
LABEL org.opencontainers.image.title="Retrospring (production)"
LABEL org.opencontainers.image.description="Image containing everything to run Retrospring in production mode. Do not use this for development."
LABEL org.opencontainers.image.vendor="The Retrospring team"
LABEL org.opencontainers.image.url="https://github.com/Retrospring/retrospring"
ARG RETROSPRING_VERSION=2023.0131.1
ARG RUBY_VERSION=3.2.3
ARG RUBY_INSTALL_VERSION=0.9.3
ARG BUNDLER_VERSION=2.5.5
ENV RAILS_ENV=production
# update and install dependencies
RUN zypper addrepo https://download.opensuse.org/repositories/devel:languages:nodejs/15.5/devel:languages:nodejs.repo \
&& zypper --gpg-auto-import-keys up -y \
&& zypper in -y \
# build dependencies (ruby-install)
automake \
gcc \
gdbm-devel \
gzip \
libffi-devel \
libopenssl-devel \
libyaml-devel \
jemalloc-devel \
make \
ncurses-devel \
readline-devel \
tar \
xz \
zlib-devel \
curl \
# build dependencies (app)
gcc-c++ \
git \
libidn-devel \
nodejs16 \
npm16 \
postgresql-devel \
# runtime dependencies
ImageMagick \
# cleanup repos
&& zypper clean -a \
# install yarn as another build dependency
&& npm install -g yarn
# install Ruby via ruby-install
RUN curl -Lo ruby-install-${RUBY_INSTALL_VERSION}.tar.gz https://github.com/postmodern/ruby-install/archive/v${RUBY_INSTALL_VERSION}.tar.gz \
&& tar xvf ruby-install-${RUBY_INSTALL_VERSION}.tar.gz \
&& (cd ruby-install-${RUBY_INSTALL_VERSION} && make install) \
&& rm -rf ruby-install-${RUBY_INSTALL_VERSION} ruby-install-${RUBY_INSTALL_VERSION}.tar.gz \
&& ruby-install --no-install-deps --cleanup --system --jobs=$(nproc) ruby ${RUBY_VERSION} -- --disable-install-rdoc --with-jemalloc \
&& gem install bundler:${BUNDLER_VERSION}
# create user and dirs to run retrospring in
RUN useradd -m justask \
&& install -o justask -g users -m 0755 -d /opt/retrospring/app \
&& install -o justask -g users -m 0755 -d /opt/retrospring/bundle
WORKDIR /opt/retrospring/app
USER justask:users
# install the app
RUN curl -L https://github.com/Retrospring/retrospring/archive/${RETROSPRING_VERSION}.tar.gz | tar xz --strip-components=1
RUN bundle config set without 'development test' \
&& bundle config set path '/opt/retrospring/bundle' \
&& bundle install --jobs=$(nproc) \
&& yarn install --frozen-lockfile
# temporarily set a SECRET_KEY_BASE and copy config files so rake tasks can run
ARG SECRET_KEY_BASE=secret_for_build
RUN cp config/justask.yml.example config/justask.yml \
&& cp config/database.yml.postgres config/database.yml \
&& bundle exec rails locale:generate \
&& bundle exec i18n export \
&& bundle exec rails assets:precompile \
&& rm config/justask.yml config/database.yml
# set some defaults
ENV RAILS_LOG_TO_STDOUT=true
EXPOSE 3000