From c376747b0de2c3822c09e6eb3641c8ad0be758b2 Mon Sep 17 00:00:00 2001 From: Victor Romero Date: Tue, 12 Oct 2021 17:37:58 -0500 Subject: [PATCH] Fixing the Docker build --- Dockerfile.production | 28 +++++++++++++++------------ docker-compose.yml.production-example | 2 ++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Dockerfile.production b/Dockerfile.production index a6af1e8d..af9d6ba8 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -1,20 +1,24 @@ -FROM registry.opensuse.org/opensuse/infrastructure/osem/containers/osem/base +FROM registry.opensuse.org/opensuse/infrastructure/dale/containers/osem/base:latest +ARG CONTAINER_USERID -# Install bundler & foreman -RUN gem install bundler:1.17.3 foreman +# Configure our user +RUN usermod -u $CONTAINER_USERID osem + +# We copy the Gemfiles into this intermediate build stage so it's checksum +# changes and all the subsequent stages (a.k.a. the bundle install call below) +# have to be rebuild. Otherwise, after the first build of this image, +# docker would use it's cache for this and the following stages. +COPY Gemfile /osem/ +COPY Gemfile.lock /osem/ +RUN chown -R osem /osem # Add our files -COPY --chown=1000:1000 . /osem/ - USER osem WORKDIR /osem/ +# Install bundler & foreman +RUN sudo gem install bundler:1.17.3 foreman # Install our bundle -RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 --without test development +RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 -# Generate assets -RUN export RAILS_ENV=production; bundle exec rake assets:precompile - -ENV RAILS_ENV=production - -CMD ["foreman", "start"] +CMD ["foreman", "start"] \ No newline at end of file diff --git a/docker-compose.yml.production-example b/docker-compose.yml.production-example index a11ce641..d417a083 100644 --- a/docker-compose.yml.production-example +++ b/docker-compose.yml.production-example @@ -11,6 +11,8 @@ services: production_web: build: context: . + args: + CONTAINER_USERID: 1000 dockerfile: Dockerfile.production depends_on: - production_database