Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35593 - Use CentOS 8 Stream for container #9604

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Base container that is used for both building and running the app
FROM registry.fedoraproject.org/fedora-minimal:33 as base
FROM quay.io/centos/centos:stream8 as base
ARG RUBY_VERSION="2.7"
ARG NODEJS_VERSION="12"
ENV FOREMAN_FQDN=foreman.example.com
ENV FOREMAN_DOMAIN=example.com

RUN \
echo -e "[nodejs]\nname=nodejs\nstream=${NODEJS_VERSION}\nprofiles=\nstate=enabled\n" > /etc/dnf/modules.d/nodejs.module && \
echo -e "[ruby]\nname=ruby\nstream=${RUBY_VERSION}\nprofiles=\nstate=enabled\n" > /etc/dnf/modules.d/ruby.module && \
microdnf install -y postgresql-libs ruby{,gems} rubygem-{rake,bundler} npm nc hostname \
# needed for VNC/SPICE websockets
python2-numpy && \
microdnf clean all
dnf module enable ruby:${RUBY_VERSION} nodejs:${NODEJS_VERSION} -y && \
dnf install -y postgresql-libs ruby{,gems} rubygem-{rake,bundler} npm nc hostname && \
dnf clean all

ARG HOME=/home/foreman
WORKDIR $HOME
Expand All @@ -33,22 +30,25 @@ ENV FOREMAN_APIPIE_LANGS=en
ENV BUNDLER_SKIPPED_GROUPS="test development openid libvirt journald facter console"

RUN \
microdnf install -y redhat-rpm-config git \
dnf install -y redhat-rpm-config git-core \
gcc-c++ make bzip2 gettext tar \
libxml2-devel libcurl-devel ruby-devel \
postgresql-devel && \
microdnf clean all
dnf clean all

ENV DATABASE_URL=nulldb://nohost

ARG HOME=/home/foreman
USER 1001
WORKDIR $HOME
COPY --chown=1001:0 . ${HOME}/
# Adding missing gems, for tzdata see https://bugzilla.redhat.com/show_bug.cgi?id=1611117
RUN echo gem '"tzinfo-data"' > bundler.d/container.rb
RUN bundle install --without "${BUNDLER_SKIPPED_GROUPS}" \
--binstubs --clean --path vendor --jobs=5 --retry=3 && \
RUN bundle config set --local without "${BUNDLER_SKIPPED_GROUPS}" && \
bundle config set --local clean true && \
bundle config set --local path vendor && \
bundle config set --local jobs 5 && \
bundle config set --local retry 3
RUN bundle install && \
bundle binstubs --all && \
rm -rf vendor/ruby/*/cache/*.gem && \
find vendor/ruby/*/gems -name "*.c" -delete && \
find vendor/ruby/*/gems -name "*.o" -delete
Expand All @@ -61,7 +61,8 @@ RUN npm install --no-optional && \
./node_modules/webpack/bin/webpack.js --config config/webpack.config.js && npm run analyze && \
# cleanups
rm -rf public/webpack/stats.json ./node_modules vendor/ruby/*/cache vendor/ruby/*/gems/*/node_modules bundler.d/nulldb.rb db/schema.rb && \
bundle install --without "${BUNDLER_SKIPPED_GROUPS}" assets
bundle config without "${BUNDLER_SKIPPED_GROUPS} assets" && \
bundle install

USER 0
RUN chgrp -R 0 ${HOME} && \
Expand All @@ -84,7 +85,7 @@ COPY --from=builder --chown=1001:0 ${HOME}/.bundle/config ${HOME}/.bundle/config
COPY --from=builder --chown=1001:0 ${HOME}/Gemfile.lock ${HOME}/Gemfile.lock
COPY --from=builder --chown=1001:0 ${HOME}/vendor/ruby ${HOME}/vendor/ruby
COPY --from=builder --chown=1001:0 ${HOME}/public ${HOME}/public
RUN echo gem '"tzinfo-data"' > bundler.d/container.rb && rm -rf bundler.d/nulldb.rb bin/spring
RUN rm -rf bundler.d/nulldb.rb bin/spring

RUN date -u > BUILD_TIME

Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# config.action_dispatch.rack_cache = true

# Disable Rails's static asset server (Apache or nginx will already do this).
config.public_file_server.enabled = false
config.public_file_server.enabled = ENV.fetch('RAILS_SERVE_STATIC_FILES', false) == 'true'

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ services:
- POSTGRES_DATABASE=foreman
- PGDATA=/var/lib/postgresql/data/pgdata
hostname: db.example.com
image: postgres:10
image: postgres:12
ports:
- 5432
- '5432'
restart: always
healthcheck:
test: ["CMD-SHELL", "nc -z 127.0.0.1 5432 || exit 1"]
Expand Down