Travis

Travis

Docker For Rails Developers - Chapter 2 Defining Our First Custom Image WORKDIR Correctoin

Dockerfile:

FROM ruby:2.6

RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs

COPY . /usr/src/app/

WORKDIR /usr/src/app/

RUN bundle install

The Dockerfile instructs us to copy the current directory into /usr/src/app/. Placing our directory myapp into /usr/src/app/.

Then the WORKDIR is defined as /usr/src/app/

And RUN bundle install.

This fails as bundle install should be run in the app directory. We’re in /usr/src/app/ but we should be in /usr/src/app/myapp.

The Dockerfile is corrected with

FROM ruby:2.6

RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs

COPY . /usr/src/app/

WORKDIR /usr/src/app/myapp

RUN bundle install

Most Liked

Travis

Travis

I ended up with a different solution and believe my original problem was a wrong file structure.

My Dockerfile is now located in the Rails app - myapp. The value of WORKDIR is /usr/src/app/.

Is that how you have yours now?

jetsondavis

jetsondavis

I made the change you suggest, now get this:
/usr/local/bundle/gems/webpacker-4.3.0/lib/webpacker/configuration.rb:95:in `rescue in load’: Webpacker configuration file not found /usr/src/app/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /usr/src/app/config/webpacker.yml (RuntimeError)

Can anyone help? Frustrating to pay so much for a book that is incorrect.

edruder

edruder

  • myapp should be your current directory. (cd myapp)
  • The Dockerfile should be created in the myapp directory–it looks like you created it one directory above.
  • docker build . will then succeed, I think.

Popular Pragmatic topics Top

belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1020 16971 374
New
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New

Latest in PragProg

View all threads ❯