Deprecated: Creation of dynamic property c2c_AddAdminCSS::$admin_options_name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$config is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$disable_contextual_help is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$disable_update_check is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$hook_prefix is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$form_name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$menu_name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$name is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$nonce_field is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$settings_page is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$show_admin is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$textdomain is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$textdomain_subdir is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 106 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$author_prefix is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 109 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$id_base is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 110 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$options_page is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 111 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$plugin_basename is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 112 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$plugin_file is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 113 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$plugin_path is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 114 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$u_id_base is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 115 Deprecated: Creation of dynamic property c2c_AddAdminCSS::$version is deprecated in /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php on line 116 Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/add-admin-css/c2c-plugin.php:106) in /var/www/html/wp-includes/rest-api/class-wp-rest-server.php on line 1768 {"id":197,"date":"2022-07-06T11:19:54","date_gmt":"2022-07-06T04:19:54","guid":{"rendered":"https:\/\/erwin.co\/?p=197"},"modified":"2022-07-06T11:19:54","modified_gmt":"2022-07-06T04:19:54","slug":"docker-gemfile-gemfile-lock-rbenv-rubygems-bundler-or-why-good-planning-can-often-beat-evolution","status":"publish","type":"post","link":"https:\/\/erwin.co\/docker-gemfile-gemfile-lock-rbenv-rubygems-bundler-or-why-good-planning-can-often-beat-evolution\/","title":{"rendered":"Docker, Gemfile, Gemfile.lock, rbenv, rubygems, bundler or why good planning can often beat evolution"},"content":{"rendered":"\n

Rbenv \u00e2\u2020\u2019 specifies a Ruby version<\/p>\n\n\n\n

Ruby \u00e2\u2020\u2019 loads some gems that are part of the base Ruby distribution (bundler, rubygems, irb, etc)<\/p>\n\n\n\n

Rubygems \u00e2\u2020\u2019loads other gems (for the system or user) \u00e2\u2020\u2019 GEM_HOME<\/code> and GEM_PATH<\/code><\/p>\n\n\n\n

Bundler \u00e2\u2020\u2019 loads other gems (for the current project) \u00e2\u2020\u2019 BUNDLE_PATH<\/code><\/p>\n\n\n\n

So basically Ruby ships with a bunch of gems, rubygems manages most of the gems you install, and bundler manages all of the gems for a specific project, and both rubygems and bundler ship with Ruby.<\/p>\n\n\n\n

The initial release of Docker<\/em> was done at PyCon in 2013, but I wonder how much Ruby<\/em> and the various shades of gem catostrophe helped inspire Docker adoption?<\/p>\n\n\n\n

If you're using Docker and thus only running a single set of gems<\/code> at a time, I think you should simplify the models as much as possible. For a ruby focused docker container, just skip rbenv<\/code> and similar tools, try to bypass the system gems as much as possible, and try to get bundler \/ rubygems to force everything into \/gems.<\/p>\n\n\n\n

You'll want to check what bundler<\/strong> and rubygems<\/strong> detect as the environment via:<\/p>\n\n\n

\nbundler env\ngems env\n<\/pre><\/div>\n\n\n

Basically, inside of your docker-compose.yml<\/code> and Dockerfile<\/code> and perhaps even your dip.yml<\/a><\/code> you want to set<\/p>\n\n\n

\nHOME:        \/app\nBUNDLE_PATH: \/gems\nGEM_HOME:    \/gems\nGEM_PATH:    \/gems\nPATH:        \/gems\/ruby\/<ruby-version>\/bin:\/gems\/bin:\/app\/bin:$PATH\n<\/pre><\/div>\n\n\n

Also, I found my local docker<\/code> build environment to be far less annoying when I figured out how to run everything as my local user... Ultimately I need to move to actually using a text template system to process all of the required variables (it's pretty lame that the Docker people make permissions that match the developer impossible without your own wrappers) but if it bothers you enough you could always fork docker.<\/p>\n\n\n

\nARG UID=<your id -u>\nARG GID=<your id -g>\nARG APPUSER=appuser\n\nRUN set -x \\\n    && addgroup --system --gid $GID $APPUSER || true \\\n    && adduser  --system --disabled-login --ingroup $APPUSER --no-create-home --home \/app --gecos "$APPUSER" --shell \/bin\/false --uid $UID $APPUSER || true\n\nUSER $APPUSER\n\n# Why on earth does Docker's COPY always copy as root instead of the USER: you set? Only the Docker people know...\nCOPY --chown=$APPUSER: Gemfile* \/app\/\n<\/pre><\/div>\n\n\n

Then in your dip.yml<\/code> makle sure to add run_option<\/code>s for your user...<\/p>\n\n\n

\ninteraction:\n  shell:\n    description: Open the Bash Shell in Container\n    service: web\n    command: bash\n    compose:\n      run_options: ["no-deps", "user=<your id -u>"]\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"

Rbenv \u00e2\u2020\u2019 specifies a Ruby version Ruby \u00e2\u2020\u2019 loads some gems that are part of the base Ruby distribution (bundler, rubygems, irb, etc) Rubygems \u00e2\u2020\u2019loads other gems (for the system or user) \u00e2\u2020\u2019 GEM_HOME and GEM_PATH Bundler \u00e2\u2020\u2019 loads other gems (for the current project) \u00e2\u2020\u2019 BUNDLE_PATH So basically Ruby ships with a bunch of […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts\/197"}],"collection":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":1,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"predecessor-version":[{"id":198,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/posts\/197\/revisions\/198"}],"wp:attachment":[{"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/erwin.co\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}