Code Monkey home page Code Monkey logo

docker-rails-base's People

Contributors

deepakinseattle avatar dependabot-preview[bot] avatar dependabot[bot] avatar juice10 avatar ledermann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-rails-base's Issues

SECRET_KEY_BASE=dummy - a security risk?

Just noticed that the base Dockerfile precompile step has SECRET_KEY_BASE=dummy . Isn't this a security risk?

There are a few workarounds here: rails/rails#32947 that could make it more secure, such as using SECRET_KEY_BASE=``bin/rake secret`` bin/rake assets:precompile.

how to add alpine packages in Build Stage

I (sadly) have the need for imagemagick(-dev, -libs) in my Build Stage in Order to use a certain gem later in Production.

How would that be possible?
I tried copying the whole Builder Dockerfile in place of FROM ledermann/rails-base-builder:3.2.2-alpine AS Builder but i don't get running Images.

Appreciated!

Feature request: Add vips-dev in Builder Stage

Asset Precompilation in Builder Stage crashes with
Error loading shared library glib-2.0.so.0: No such file or directory.
if gem "vips" is added to Bundle.

Builder Stage would need vips-dev Alpine Package in order to alleviate this.

Related Issue

how to add package like sqlite-dev

I tried this way

FROM ledermann/rails-base-builder:3.1.1-alpine AS Builder
FROM ledermann/rails-base-final:3.1.1-alpine

RUN apk add --no-cache sqlite-dev
USER app
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

failed with cmd docker build .

Installing sqlite3 1.4.2 with native extensions
Installing importmap-rails 1.0.3
Installing stimulus-rails 1.0.4
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/sqlite3-1.4.2/ext/sqlite3
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.1.0 -r
./siteconf20220313-8-4cuwka.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'brew install sqlite3',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'

it seems sqlite-dev is not added before onbuild is triggered.
maybe I need build my builder image?

Clear out entire cache directory

Just noticed this line:

rm -rf /usr/local/bundle/cache/*.gem && \

It only clears out .gem caches. If you have a gem that is referencing a git repo, the cache there will be the entire repo itself. I think it's safe to clear out the entire cache/* directory instead of looking only for *.gem files.

Bundler v2 missing

I tried using your project for a fresh rails project (thanks for this! this is great) but wasn't able to get it running out of the box.

Using a brand new rails project, and using the basic Dockerfile:

FROM ledermann/rails-base-builder:latest AS Builder
FROM ledermann/rails-base-final:latest
USER app
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

When running a docker build, I was getting the following error:

/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /app/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
	from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
	from /usr/local/bin/bundle:23:in `<main>'

It looks like the base containers don't actually have bundler so I needed to add RUN gem install bundler before the bundle config call here: https://github.com/ledermann/docker-rails-base/blob/master/Builder/Dockerfile#L22


Am I missing a setup step for local development / is there a reason why install bundler isn't added? (do you expect CI to add it?)

ActiveSupport::EncryptedFile::MissingKeyError when building image

# Dockerfile
FROM ledermann/rails-base-builder:latest AS builder

FROM nginx:alpine
COPY --from=builder /app/public /usr/share/nginx/html/
# build.log 
Step 1/5 : FROM ledermann/rails-base-builder:latest AS builder
# Executing 5 build triggers
 ---> Using cache
 ---> Using cache
 ---> Running in e572cd7508c3
rails aborted!
ActiveSupport::EncryptedFile::MissingKeyError: Missing encryption key to decrypt file with. Ask your team for your master key and write it to /app/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].

I tried to use

# Dockerfile
FROM ledermann/rails-base-builder:latest AS builder
ARG CREDENTIALS_KEY=changeme
ENV RAILS_MASTER_KEY=$CREDENTIALS_KEY

FROM nginx:alpine
COPY --from=builder /app/public /usr/share/nginx/html/

to allow usage with docker-compose --build-arg but it doesn't work that way :(

Any suggested solution?

Not compatible with BuildKit

Since the update to engine 20.10, I can no longer use :

FROM ledermann/rails-base-builder:2.7.2-alpine AS Builder
FROM ledermann/rails-base-final:2.7.2-alpine

It seems to me that rails-base-builder is never executed.

Plans to add tagging?

Hello, Georg. Thanks for putting together the builder and the final docker images. I've recently started using this instead of rolling my own, and the images they produce are nice and lean.

Do you have any plans to add tags to the docker images you push? I had CI start failing on me today because I'm still using Ruby 2.7.1.

With the update of this image to 2.7.2, my docker build step began to fail in CI with Your Ruby version is 2.7.2, but your Gemfile specified 2.7.1 since my Gemfile.lock still has 2.7.1.

Tagging these images (perhaps consistent with the base ruby tag e.g. 2.7.2-alpine) would be a welcome way to avoid getting caught by surprise.

I'm happy to help with a PR if you've got a direction in mind for how you'd like to see the tagging implemented.

Local Path Gems

First up I have to say a thank you for making a great Rails 7 template! What a gentleman for open sourcing all your hard work!

In my project, I install some gems from local path, e.g.:

gem 'awesome_client', path: './vendor/gems/awesome_client'

I was wondering what is the best practice for handling this, so that issues are not raised when trying to docker-compose up.

2.085 Fetching gem metadata from https://rubygems.org/......
32.84 The path `/app/vendor/gems/awesome_client ` does not exist.
------
failed to solve: process "/bin/sh -c bundle config --local without 'development test' &&             bundle install -j4 --retry 3 &&             bundle exec bootsnap precompile --gemfile || true &&             bundle clean --force &&             rm -rf /usr/local/bundle/cache &&             find /usr/local/bundle/gems/ -name \"*.c\" -delete &&             find /usr/local/bundle/gems/ -name \"*.o\" -delete" did not complete successfully: exit code: 13

I saw that only the app directory was copied, so I thought that might be the issue. I tried adding this to the Dockerfile with no success:

RUN mkdir -p /app/vendor/gems

# Copy each gem individually
COPY ./vendor/gems/awesome_client /app/vendor/gems/awesome_client

As knowledgeable as you are, I am sure you can give some guidance on best practices for handing this case with your template/framework. Thank you!

assets:compile task is tied to Sprockets

I'm actively trying to get rid of sprockets since we already have Webpack in Rails applications but calling assets:compile is tied to Sprockets which makes my build fail with

rails aborted!
LoadError: cannot load such file -- uglifier

As far as I am concerned you can call webpacker:compile to get packs compiled.

Would you consider supporting NOT calling assets:precompile?

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "mimemagic":
  In Gemfile:
    rails (~> 6.1.3) was resolved to 6.1.3, which depends on
      activestorage (= 6.1.3) was resolved to 6.1.3, which depends on
        mimemagic (~> 0.3.2)

Could not find gem 'mimemagic (~> 0.3.2)', which is required by gem 'activestorage (= 6.1.3)', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Unable to Load application due to yarn package integrity

When I try running a built image, I run into this error.

Puma starting in single mode...
* Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
sh: yarn: not found


========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================


To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).





! Unable to load application: SystemExit: exit

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::GemNotFound with message: Could not find aws-sdk-s3-1.68.0 in any of the sources

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

removing app/javascript breaks stimulus when using importmaps

https://github.com/ledermann/docker-rails-base/blob/main/Builder/Dockerfile#L67

when app/javascript is removed, the Container will throw a JS Error :

Uncaught TypeError: Failed to resolve module specifier "controllers". Relative references must start with either "/", "./", or "../".

i can't claim to fully grasp what is going on, but my guess is the importmap will pin to the actual uncompressed stimulus .js file located in app/javascript/controllers/hello_controller.js instead of the minified one in /public/assets/controllers/hello_controller.js

Would it be too much to ask to not purge app/javascript?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.