Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

FEATURE ADDED - Integrated Docker development environment, works cross platform (including Windows!) #1818

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

DavidGriswoldTeacher
Copy link

As a windows user, Ruby work is hard for me, so I decided to expand the already-existing docker component of this project into an optional self-contained dev environment that allows me to do everything, including the ruby and rails work itself, in docker. It was a bigger project than I expected, but it now works very smoothly on my Windows machine, and could provide a nice entryway to developing on this for both Windows users and users who simply don't want to deal with a native ruby install.

I will leave comments explaining the elements briefly.

@@ -13,6 +13,7 @@ vendor/bundle
!/log/.keep
/tmp
/coverage
yarn-error.log

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file came up in testing, and I realized it should be .gitignored.

Copy link
Author

@DavidGriswoldTeacher DavidGriswoldTeacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments for clarity.

@@ -0,0 +1,45 @@
FROM ruby:2.4.2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the docker file to build the docker image that will do the development. It starts with the base ruby image for the ruby version currently used in the project, but for easy forward compatibility it installs rbenv as well.

@@ -0,0 +1,2 @@
rails: ./bin/rails server -p 5000 -b 0.0.0.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to make a special procfile to get the binding right on rails. If there's a way to parse environment variables internally in the procfile we could do that here.

context: .
dockerfile: Dockerfile-sc
volumes:
- .:/usr/src/app

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bundle and vendor are copied into the docker image, then not mounted back onto the host box. That way dependencies we shouldn't be editing don't clutter up the filesystem.

- /usr/src/app/vendor
ports:
- "5000:5000"
entrypoint: bash

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the dev environment simply opens a shell. Users attach to it and run script/setup and script/server etc just as they would for a native installation.

@DavidGriswoldTeacher DavidGriswoldTeacher changed the title Integrade Docker development environment, works cross platform (including Windows!) Integrated Docker development environment, works cross platform (including Windows!) May 3, 2019
@DavidGriswoldTeacher DavidGriswoldTeacher changed the title Integrated Docker development environment, works cross platform (including Windows!) FEATURE ADDED - Integrated Docker development environment, works cross platform (including Windows!) May 7, 2019
@stale
Copy link

stale bot commented Jul 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Jul 20, 2019
@andrewbredow andrewbredow added this to In progress in GitHub Classroom via automation Sep 11, 2019
@andrewbredow andrewbredow requested review from a team and removed request for mozzadrella, srinjoym and BenEmdon September 12, 2019 12:44
@stale stale bot removed the stale label Sep 12, 2019
@ghost ghost requested a review from spinecone September 12, 2019 12:45
@@ -111,11 +111,33 @@ GitHub Classroom is a [Ruby on Rails](http://rubyonrails.org/) application.

New to Ruby? No worries! You can follow these instructions to install a local server.

#### macOS
#### Cross-platform option - Self-contained Docker Development Environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move the Docker setup instructions to their own file? The readme is getting a bit long with these additions.

#
# bindadress bindport connectaddress connectport
localhost 2345 postgresql 5432
localhost 9337 elasticsearch 9300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually aren't using elasticsearch anymore so this can be removed 🎉

environment:
- SELFCONTAINED=true

elasticsearch:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More elasticsearch config that can be removed 🎉 🎉

ENV PATH "$PATH:/root/.rbenv/bin"
ENV PATH "$PATH:/root/.rbenv/shims"

#not sure what this bug is, should probably try taking it out later
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug may be because we are using an older version of Ruby, and the container for that version is based on debian jessie which is no longer supported. Maybe this should be using a newer version (possibly alpine) instead.

#not sure what this bug is, should probably try taking it out later
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list

#install rbenv (though is this really necessary? Will try both ways.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image might be more efficient if we use the default Ruby that comes with the container rather than installing a different version. We're also hoping to upgrade to Ruby 2.6.3 in the nearish future which should make this process simpler.

@jeffrafter
Copy link
Contributor

As a note we've updated Ruby to 2.6.4. It might make things easier (more modern distros available)

@DavidGriswoldTeacher
Copy link
Author

DavidGriswoldTeacher commented Sep 16, 2019 via email

@andrewbredow andrewbredow moved this from In progress to Triage in GitHub Classroom Sep 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
GitHub Classroom
  
Triage
Development

Successfully merging this pull request may close these issues.

None yet

4 participants