Retrospring/Containerfile

85 lines
3.0 KiB
Plaintext
Raw Normal View History

2023-02-02 06:48:04 -08:00
# Container image for a production Retrospring setup
FROM registry.opensuse.org/opensuse/leap:15.4
2023-03-14 10:18:52 -07:00
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"
2023-02-02 06:48:04 -08:00
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/${RETROSPRING_VERSION}.tar.gz | tar xz --strip-components=1
2023-02-02 06:48:04 -08:00
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
2023-02-02 06:48:04 -08:00
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
2023-02-03 22:09:32 -08:00
# set some defaults
ENV RAILS_LOG_TO_STDOUT=true
2023-02-02 06:48:04 -08:00
EXPOSE 3000