From a6d5963e4a12de4aabf76aed7c329bbed5e9cc4b Mon Sep 17 00:00:00 2001 From: Dominic Barnes Date: Sun, 29 Dec 2024 10:56:39 +0000 Subject: [PATCH 1/3] Dockerfile updates --- Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e236a8..4d4e5cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,10 @@ RUN bash -c "set -o pipefail && apt-get update \ USER ruby COPY --chown=ruby:ruby Gemfile* ./ -RUN bundle install +RUN bundle install --deployment --without development test -j4 --retry 3 --no-cache --no-clean \ + && rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git /usr/local/bundle/cache/*.gem +RUN mkdir .yarn public log tmp COPY --chown=ruby:ruby package.json *yarn* ./ RUN yarn install @@ -36,7 +38,9 @@ ENV RAILS_ENV="${RAILS_ENV}" \ COPY --chown=ruby:ruby . . RUN if [ "${RAILS_ENV}" != "development" ]; then \ - SECRET_KEY_BASE_DUMMY=1 rails assets:precompile; fi + SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile; fi + +# RUN bundle exec bootsnap precompile app/ lib/ && bundle exec bootsnap precompile --gemfile CMD ["bash"] @@ -51,8 +55,8 @@ ARG UID=1000 ARG GID=1000 RUN apt-get update \ - && apt-get install -y --no-install-recommends build-essential curl libpq-dev \ - && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ +&& apt-get install -y --no-install-recommends curl libpq-dev tzdata \ +&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ && apt-get clean \ && groupadd -g "${GID}" ruby \ && useradd --create-home --no-log-init -u "${UID}" -g "${GID}" ruby \ @@ -76,4 +80,4 @@ ENTRYPOINT ["/app/bin/docker-entrypoint-web"] EXPOSE 8000 -CMD ["rails", "s"] +CMD ["rails", "s"] \ No newline at end of file From 3ffcd09ec6e12db839093f7e288f2417acff4b7e Mon Sep 17 00:00:00 2001 From: Dominic Barnes Date: Sun, 29 Dec 2024 11:00:19 +0000 Subject: [PATCH 2/3] swap out libpq-dev --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4d4e5cc..a7c227a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,8 +40,6 @@ COPY --chown=ruby:ruby . . RUN if [ "${RAILS_ENV}" != "development" ]; then \ SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile; fi -# RUN bundle exec bootsnap precompile app/ lib/ && bundle exec bootsnap precompile --gemfile - CMD ["bash"] ############################################################################### @@ -55,7 +53,7 @@ ARG UID=1000 ARG GID=1000 RUN apt-get update \ -&& apt-get install -y --no-install-recommends curl libpq-dev tzdata \ +&& apt-get install -y --no-install-recommends curl postgresql-client tzdata \ && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ && apt-get clean \ && groupadd -g "${GID}" ruby \ From 26e31bcd9fbcb6974b4e08231a1f731430ca1e58 Mon Sep 17 00:00:00 2001 From: Dominic Barnes Date: Sun, 29 Dec 2024 18:30:24 +0000 Subject: [PATCH 3/3] bundle changes --- Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a7c227a..10bb724 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,14 +19,17 @@ RUN bash -c "set -o pipefail && apt-get update \ && mkdir /node_modules && chown ruby:ruby -R /node_modules /app" USER ruby +ARG BUNDLE_WITHOUT='development test' +ENV BUNDLE_PATH=/usr/local/bundle COPY --chown=ruby:ruby Gemfile* ./ -RUN bundle install --deployment --without development test -j4 --retry 3 --no-cache --no-clean \ - && rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git /usr/local/bundle/cache/*.gem +RUN bundle config set without $BUNDLE_WITHOUT && \ + bundle config set deployment true && \ + bundle install RUN mkdir .yarn public log tmp COPY --chown=ruby:ruby package.json *yarn* ./ -RUN yarn install +RUN yarn install --frozen-lockfile ARG RAILS_ENV="production" ARG NODE_ENV="production" @@ -68,7 +71,8 @@ RUN chmod 0755 bin/* ARG RAILS_ENV="production" ENV RAILS_ENV="${RAILS_ENV}" \ PATH="${PATH}:/home/ruby/.local/bin" \ - USER="ruby" + USER="ruby" \ + BUNDLE_PATH=/usr/local/bundle COPY --chown=ruby:ruby --from=assets /usr/local/bundle /usr/local/bundle COPY --chown=ruby:ruby --from=assets /app/public /public