sama213
(Sam)
April 3, 2022, 5:37pm
1
Hello,
In our Ruby application Dockerfile, we have a layer to install all gems. It appears that although this does not change, that the layer produced in docker build is not cached anywhere. Locally on my laptop, subsequent docker builds skip that layer since it did not change. In Qovery however, this is run every on very single deploy which results in our build taking much longer time than when built locally or in Heroku. Any ideas for us?
Thanks!!!
Here is the relevant section from our Dockerfile.
WORKDIR /mydir
COPY Gemfile* /mydir
RUN bundle install -j4
rophilogene
(Romaric Philogene)
April 3, 2022, 6:06pm
2
Hi @sama213 , can you show the whole Dockerfile? It’s possible that something like env vars/secrets invalid cache.
sama213
(Sam)
April 3, 2022, 6:19pm
4
FROM ruby:2.6.9-bullseye AS builder
ENV BUNDLE_WITHOUT='development:test'
ENV BUNDLE_PATH=vendor/bundle
ENV BUNDLE_BIN=vendor/bundle/bin
ENV BUNDLE_DEPLOYMENT=1
ENV BUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE=1
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client && \
apt-get install ca-certificates && \
git config --global url."https://github.com/".insteadOf git://github.com/ && \
bundle config github.https true
WORKDIR /myorg
COPY Gemfile* /myorg
RUN bundle install -j4
WORKDIR /myorg
COPY . /myorg
RUN bundle exec rake assets:precompile
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "./config/puma.rb"]
rophilogene
(Romaric Philogene)
April 3, 2022, 7:37pm
5
Is it the complete dockerfile?
sama213
(Sam)
April 3, 2022, 7:38pm
6
yes, it is the complete docker file
rophilogene
(Romaric Philogene)
April 3, 2022, 8:16pm
7
sama213:
In our Ruby application Dockerfile, we have a layer to install all gems. It appears that although this does not change, that the layer produced in docker build is not cached anywhere. Locally on my laptop, subsequent docker builds skip that layer since it did not change. In Qovery however, this is run every on very single deploy which results in our build taking much longer time than when built locally or in Heroku. Any ideas for us?
Can you give more details on:
How long the build takes on your local machine?
How long the build takes on Qovery?
For Qovery, you can know how long it takes by subtracting the end time from the start time (we’re working to make it simpler).
E.g
End time
Start time
Note you can also know how long each Docker build step takes
sama213
(Sam)
April 3, 2022, 11:34pm
8
Local MacBook (81 seconds)
docker build -t l-puma . -f Dockerfile.puma
[+] Building 81.9s (15/15) FINISHED
sama213
(Sam)
April 3, 2022, 11:45pm
9
Qovery - about 195 seconds (about 3 minutes from build start to container ready in ECR).
03 Apr, 19:39:57.075 - Build started.
03 Apr, 19:43:12.647. - container ready in ECR
03 Apr, 19:44:26.883 - Deployed container
rophilogene
(Romaric Philogene)
April 4, 2022, 5:51am
10
And when you manually redeploy with Qovery (Actions → redeploy) ? (I want to check if the cache is well used without any code change)
1 Like
sama213
(Sam)
April 4, 2022, 12:45pm
11
If I do a redeploy with no code changes, I get a message that container already exists and the entire build process gets skipped. If any code changes, then re-build takes place.
sama213
(Sam)
April 4, 2022, 1:03pm
12
However,
It appears that build process is not caching base ruby image. The following keeps running for redeploys if code changed. I would assume that our base image for linux ruby would be cached.
#5 [1/9] FROM docker.io/library/ruby:2.6.9-bullseye@sha256:c40edb661be87f7067f506e2f5c1717c8766f822c996f1b35320cc30459c65dd
04 Apr, 08:57:29.773
DEPLOYMENT_IN_PROGRESS
#5 sha256:ae6053300e08f05928b5514b26258dc4a24ffdc0a1195916801012a496b7ab5a 175B / 175B 0.2s
04 Apr, 08:57:29.773
DEPLOYMENT_IN_PROGRESS
#5 sha256:cbfac96e475838046bddd6b562586b511bf2aa4cd050b0e0edba58c0683b8ae1 147.46kB / 21.68MB 0.2s
04 Apr, 08:57:29.774
DEPLOYMENT_IN_PROGRESS
#5 sha256:26e7ceebb0b46999ab07630803680603213e4d63c622a1c2ff6efaf4cf86cbc6 0B / 200B 0.2s
04 Apr, 08:57:29.782
DEPLOYMENT_IN_PROGRESS
#5 sha256:cbfac96e475838046bddd6b562586b511bf2aa4cd050b0e0edba58c0683b8ae1 5.14MB / 21.68MB 0.3s
04 Apr, 08:57:29.782
DEPLOYMENT_IN_PROGRESS
#5 sha256:b19a994f6d4cdbb620339bd2e4ad47b229f14276b542060622ae447649294e5d 0B / 54.58MB 0.2s
04 Apr, 08:57:29.782
DEPLOYMENT_IN_PROGRESS
#5 sha256:cbfac96e475838046bddd6b562586b511bf2aa4cd050b0e0edba58c0683b8ae1 11.53MB / 21.68MB 0.5s
04 Apr, 08:57:29.783
DEPLOYMENT_IN_PROGRESS
#5 sha256:26e7ceebb0b46999ab07630803680603213e4d63c622a1c2ff6efaf4cf86cbc6 200B / 200B 0.3s
04 Apr, 08:57:29.783
DEPLOYMENT_IN_PROGRESS
#5 sha256:b19a994f6d4cdbb620339bd2e4ad47b229f14276b542060622ae447649294e5d 5.93MB / 54.58MB 0.5s
04 Apr, 08:57:29.783
DEPLOYMENT_IN_PROGRESS
#5 sha256:cbfac96e475838046bddd6b562586b511bf2aa4cd050b0e0edba58c0683b8ae1 17.83MB / 21.68MB 0.6s
rophilogene
(Romaric Philogene)
April 5, 2022, 6:01pm
13
If the cache is invalidated, it means that something is changing from your image at a higher level. Can you please show me the complete Dockerfile (it’s important - otherwise I can’t troubleshoot correctly)
sama213
(Sam)
April 5, 2022, 6:13pm
14
sama213:
FROM ruby:2.6.9-bullseye AS builder
ENV BUNDLE_WITHOUT='development:test'
ENV BUNDLE_PATH=vendor/bundle
ENV BUNDLE_BIN=vendor/bundle/bin
ENV BUNDLE_DEPLOYMENT=1
ENV BUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE=1
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client && \
apt-get install ca-certificates && \
git config --global url."https://github.com/".insteadOf git://github.com/ && \
bundle config github.https true
WORKDIR /myorg
COPY Gemfile* /myorg
RUN bundle install -j4
WORKDIR /myorg
COPY . /myorg
RUN bundle exec rake assets:precompile
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "./config/puma.rb"]
@rophilogene , that is our ENTIRE file