I was able to follow these directions to set up a Rails application on my local machine:
But, I would prefer for my development environment to be on hardware that is more typical of the type of server it would run on in production. That is why in the past, when I’ve been using Vagrant, I used DigitalOcean as my provisioner. So, now I’m trying to reproduce the procedures outlined in the above article using DigitalOcean as the provisioner, but I’m running into problems and seem to be missing something.
First, I created the Dockerfile, Gemfile, Gemfile.lock, and docker-compose.yml files in a directory on my local machine by copying the code in the article, as follows:
FROM ruby:2.2.0 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs RUN mkdir /myapp WORKDIR /myapp ADD Gemfile /myapp/Gemfile ADD Gemfile.lock /myapp/Gemfile.lock RUN bundle install ADD . /myapp
source 'https://rubygems.org' gem 'rails', '4.2.0'
version: '2' services: db: image: postgres web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - .:/myapp ports: - "3000:3000" depends_on: - db
Gemfile.lock created by entering the following in my local machine’s iTerm2 CLI:
Next, from my local machine’s CLI in iTerm2 in the directory I stored the above files, I create a docker-machine using the following:
docker-machine create --driver digitalocean --digitalocean-access-token MyDigitalOceanToken --digitalocean-image docker --digitalocean-ssh-key-fingerprint "MySSHFingerPrint" docker-sandbox
After issuing the above command and then doing:
eval $(docker-machine env docker-sandbox)
when I enter the following in my local machine’s iTerm2:
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Stopped Unknown docker-sandbox * digitalocean Running tcp://IPofDOdroplet:2376 v1.11.2
So, I know there is a machine running, and I can see a Docker-Sandbox droplet has been created on my DigitalOcean dashboard.
Up to this point everything seems to be working as expected. But, the next step is where I run into trouble.
From my local machine’s iTerm2 CLI I run:
docker-compose run web rails new . --force --database=postgresql --skip-bundle
This appears to launch the build process and runs through all the steps in the Dockerfile. As far as I can tell these are being run on the container in the droplet. However, at the end of the procedure I get the following:
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. /myapp/Gemfile not found
From the droplet command line doing a:
shows there is a container running for the postgres database, but there is no container for the web application.
At first, I thought this was because the DO droplet doesn’t have the Gemfile on it. So, I tried to rsync it from my local machine to the droplet using:
rsync -av -e 'docker-machine ssh docker-sandbox' . :
But, I still got the same error even though I see the files when I ssh into the droplet using:
docker-machine ssh docker-sandbox
I’m confused. Am I putting the files in the wrong place on the DO droplet? Should I be running docker-compose from the command line on the droplet after I ssh to it instead of from my local machine’s iTerm2 CLI? Or, is there some other piece I’m missing that is needed to make this work on DO that is not required when doing this locally?
Any help you can offer is greatly appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.