From 0e1432f1a0267c10022932f0bbb21fd29d689746 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Thu, 2 Feb 2023 15:48:04 +0100 Subject: [PATCH] add Containerfile --- Containerfile | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Containerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 00000000..9fcc7ed0 --- /dev/null +++ b/Containerfile @@ -0,0 +1,77 @@ +# Container image for a production Retrospring setup + +FROM registry.opensuse.org/opensuse/leap:15.4 + +ARG RETROSPRING_VERSION=2023.0131.1 +ARG RUBY_VERSION=3.1.2 +ARG RUBY_INSTALL_VERSION=0.9.0 +ARG BUNDLER_VERSION=2.3.18 + +ENV RAILS_ENV=production + +# update and install dependencies +RUN zypper up -y \ + && zypper in -y \ + # build dependencies (ruby-install) + automake \ + gcc \ + gdbm-devel \ + gzip \ + libffi-devel \ + libopenssl-devel \ + libyaml-devel \ + make \ + ncurses-devel \ + readline-devel \ + tar \ + xz \ + zlib-devel \ + # build dependencies (app) + gcc-c++ \ + git \ + libidn-devel \ + nodejs14 \ + npm14 \ + 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 \ + && 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/refs/tags/${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 +ENV 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 +ENV SECRET_KEY_BASE= + +EXPOSE 3000