docker compose up -d- wait for it...
- visit
localhost:3000 - rejoice!
You can either run:
$ docker compose exec web sh
or
$ bin/ssh_to_container
Renaming your app is super simple, first clone into its own folder. Then update the following:
config/application.rb- change
RailsStartertoNewName
- change
package.json- change
STARTER_REPLACE_NAMEtonew_name
- change
By default we have set this up to use port 3000, but as every rails app uses that port you may conflict with other projects. To update to port 5000 for example, change the following:
compose.yml- change"3000:3000"->"5000:3000".env.development- changeAPP_PORT=3000->APP_PORT=5000
We try to keep the base repository up to date, but when you pull it's worth looking into whether you need to upgrade rails. A guide can be found on the rails website.
As of Rails 5.1, the upgrade process should be as simple as:
- Update the
railsgem inGemfile - Run
bundle install - Run
rails app:updatefor an interactive upgrade
There are a number of gems that need configuration to work:
- Configure
simple_form - Ensure columns for
discard
This starter uses standard-rb for Ruby code formatting and linting. We have moved away from prettier in favor of standard-rb conventions.
To format your code, run:
bundle exec standardrb --fixTo check your code without fixing, run:
bundle exec standardrbThe configuration can be found in .rubocop.yml.
By default, this repo comes set up to run vite_rails, along with React and Stimulus. This is our recommended setup for a monolith, where you plan to build the frontend as part of your Rails app.
To enable assets, you'll need to uncomment the vite container in compose.yml, along with the vite environment variables and volumes. This will start the asset building container along with the rest of the application, will place built assets from the frontend directory into public.
To actually see these assets, you'll need to uncomment the vite_*_tag entries in app/views/layouts/application.html.erb. Once that's done, you should have hot reloading of CSS & JS, along with automatic refresh when a Rails view changes.
While the assets build and inclusion is disabled by default, if you plan to use a different mechanism for building your assets (a different builder, an external client, etc.), you may want to remove all the vite stuff we've set up for you.
If that's the case, you'll want to delete all of the following:
vite_*_tagentries fromapp/views/layouts/application.html.erbconfig/vite.jsvite.config.jsbin/vitedocker/start_assets.shvite_railsfromGemfile- References to
viteinconfig/initializers/content_security_policy.rb - Optionally,
package.jsonandpackage-lock.json&node_modules - Optionally, the entire
frontend/directory
- http://www.betterspecs.org/
- https://github.com/ankane/production_rails
- https://github.com/ankane/secure_rails
- https://robots.thoughtbot.com/its-about-time-zones
If you look in compose.yml and compose.override.yml (local) you'll notice that we've spun up a number of containers, not all of which may be useful for your project.
- web: Your core container which runs the
railsserver process. - worker: A duplicate of your core app, but running
solid_queueinstead. [Disabled by Default as it runs in the puma process] - vite: A duplicate of your core app, but running
vite_railsinstead. - postgres: Your application's database.
- mailhog: Mail catcher for preventing outbound emails from escaping.
To cleanup all containers, volumes and networks execute docker compose down -v
This starter is set up to deploy out of the box on dokploy using a compose configuration. There are some items that need to be set up properly:
- Configure the environment variables. You can find samples in
.env.dokploy.example - Make sure you configure a domain
- Make sure you turn on Enable Isolated Deployment in the Advanced tab of your deployment
rails_starter was built by Apsis Labs. We love sharing what we build! Check out our other libraries on Github, and if you like our work you can hire us to build your vision.
