telerik / docs-seed

Telerik Documentation Infrastructure
https://docs.telerik.com
Apache License 2.0
7 stars 21 forks source link

Dockerfile needs some love #267

Open LanceMcCarthy opened 1 year ago

LanceMcCarthy commented 1 year ago

If you try to deploy the docs-seed (with a target documentation) using Docker, there are problems out-of-the-box.

For example, one Gem bundler says it uses v1, while the Gemfile.lock requires v2 or later. I was able to fix this by installing 2.0 or later in the Dockerfile's commands and setting the environment variable.

RUN gem update --system --quiet && gem install bundler -v '~> 2.1'

ENV BUNDLER_VERSION 2.1

Another issue was around the Docker build context failing to satisfy some apt commands. I've haven't gotten to the bottom of which packages are to blame. I just put the --force-yes sledgehammer on all of them to workaround it for now.

Here is the combination that was successful for me locally from WSL (WSL2 Ubuntu). I don't know if it will be useful for the wider scope of folks/environments, but I thought I'd share anyways.

Dockerfile

# LINE 17 

ENV APP_ROOT /app_root

# WORKAROUND 1 - Install the bundler v2+
RUN \
  gem update --system --quiet && \
  gem install bundler -v '~> 2.1'

ENV BUNDLER_VERSION 2.1

# By adding Gemfiles and invoke bundle install before copy all files we are using container cache for gems.
ADD Gemfile ${APP_ROOT}/
ADD Gemfile.lock ${APP_ROOT}/

WORKDIR ${APP_ROOT}
RUN bundle check || bundle install

# Continue ...

Gemfile.lock

GEM
...

PLATFORMS
...

DEPENDENCIES
...

# WORKAROUND 2 - Downgrade this
BUNDLED WITH
   1.16.0
RickHellwege commented 1 year ago

I was able to resolve the issue by changing the version of Bundler in Gemfile.lock from 2 to 1.

LanceMcCarthy commented 1 year ago

Yep, that problem comes from the docs-seed repo's Gemfile.lock has it set to v2 =>

https://github.com/telerik/docs-seed/blob/7f3a1c91947d2ea532792d0250b23bfa0e360bca/Gemfile.lock#L126-L127

If v2 is a requirement, this can be permanently handled by ensuring the Dockerfile installs the v2+ bundler.