Merge pull request #1042 from Retrospring/official-containers

add Containerfile to be used for running Retrospring
This commit is contained in:
Georg Gadinger 2023-02-03 23:52:40 +01:00 committed by GitHub
commit cb064e8acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 77 additions and 0 deletions

77
Containerfile Normal file
View File

@ -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