Giter Site home page Giter Site logo

docked's Introduction

Docked Rails CLI

Setting up Rails for the first time with all the dependencies necessary can be daunting for beginners. Docked Rails CLI uses a Docker image to make it much easier, requiring only Docker to be installed.

Install Docker (and WSL on Windows). Then copy'n'paste into your terminal:

docker volume create ruby-bundle-cache
alias docked='docker run --rm -it -v ${PWD}:/rails -u $(id -u):$(id -g) -v ruby-bundle-cache:/bundle -p 3000:3000 ghcr.io/rails/cli'

Then create your Rails app:

docked rails new weblog
cd weblog
docked rails generate scaffold post title:string body:text
docked rails db:migrate
docked rails server

That's it! Your Rails app is running on http://localhost:3000/posts.

Sidenote

docked is not intended to replace a full development setup. It is merely a way for newcomers to quickly get started with Rails. The included dependencies stick to what you need when running rails new without additional options. It does not include dependencies for running with PostgreSQL or Redis for example.

docked's People

Contributors

adrianhj avatar dhh avatar dijonkitchen avatar durierem avatar elalemanyo avatar esasse avatar m11o avatar nicksieger avatar oniram88 avatar rafaelfranca 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  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

docked's Issues

No write access after creating new app

After creating a new rails application with Docked, all files and folders are read-only.
And when I create a new file, e.g. a controller, it gives me permission denied.
So it seems the write permissions are not set correct?
When I create a Rails app without Docked in the same directory, I don't have this issue.
It is on Ubuntu 22.04 on Windows WSL2.

Ruby versions

Is there a way to change the ruby version? Because i have a project that uses the old version of ruby.

Setup build process for creating a single multi-platform image

Currently there are separate images for macOS (darwin/arm64) and Linux/Windows (linux/amd64). Would be nicer to have a single image, but buildx can't do that locally on macOS. Can we do it via a GH action? Or is there another process we can setup to build these images automatically?

Error when running rails new

I can't generate a new rails app. When running the rails news test command, the image message is always returned.

  • MacBook with the latest version of Macos
  • I don't have rails installed
  • Even running the command docker run --rm -it -v ${PWD}:/rails -v ruby-bundle-cache:/bundle ghcr.io/rails/cli new test message is returned

Captura de Tela 2022-12-17 às 00 03 00

Problem with PG gem

If trying to create a rails app from scratch using the --database=postgresql flag it will run into an error where the pg gem wont install because it lacks of a psql installation.

Bad yarn recommendation in readme

Hello, i guess doing alias yarn='docked yarn' as we propose in readme will be very bad for regular developer.
Maybe we should recommend doing something like yarn:rails for this alias?

Use package manager to install Node

The nodesource script way of installing node

RUN curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR.x | bash -
is deprecated and will make you wait for a minute if you are using it.
The way to do it now is using the deb repository

Like

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get install nodejs -y

See https://github.com/nodesource/distributions#debian-and-ubuntu-based-distributions

I could open a PR if needed.

Usage of docked in developement env with new setup of rails main branch

II would firstly like to thank you for yours contributions on this project to make docker easier in development environment.

Source: https://github.com/rails/rails/blob/main/railties/CHANGELOG.md

  • Add Docker files by default to new apps: Dockerfile, .dockerignore, bin/docker-entrypoint.
    These files can be skipped with --skip-docker. They're intended as a starting point for
    a production deploy of the application. Not intended for development (see Docked Rails for that).

    Example:

    docker build -t app .
    docker volume create app-storage
    docker run --rm -it -v app-storage:/rails/storage -p 3000:3000 --env RAILS_MASTER_KEY=<see config/master.key> app
    

    You can also start a console or a runner from this image:

    docker run --rm -it -v app-storage:/rails/storage --env RAILS_MASTER_KEY=<see config/master.key> app console
    

    To create a multi-platform image on Apple Silicon to deploy on AMD or Intel and push to Docker Hub for user/app:

    docker login -u <user>
    docker buildx create --use
    docker buildx build --push --platform=linux/amd64,linux/arm64 -t <user/image> .
    

    DHH, Sam Ruby

Could you manage do make RUBY_VERSION a build arg too so we can use the ruby-version of our choice ?

I can see that you are installing in the rails main branch the package yarn and npm through volta, is it something you planned to do the same with docked ?

And finally, could you make an example in the readme with the usage of a docker-compose which does the good practices for us to use it with redis and sidekiq ?

What is this?

What is this repo? What are its goals? It is unclear to me why I should use this or what it offers me. A standard rails 7.1 app already comes with a Dockerfile included by default, doesn't it? It seems to when I do a rails new on my system, one which honors my usage of database=postgresql, which docked does not seem to.

Bug: cannot run multiple consoles via docked rails c

Given I already have a live console via docked rails c, I cannot start an additional rails console with docked rails c.

The error I receive is:

docker: Error response from daemon: driver failed programming external connectivity on endpoint vigorous_hertz (be93a27e17aba8081f1a9cb781f7a6f38b7fa1e6f8535fa3f474a1d9eed39b99): Bind for 0.0.0.0:3000 failed: port is already allocated.

Starting Place (for esbuild environments)

Just wanted to share my docker-compose.yml file and Dockerfile that I use for development whenever I'm making new Rails applications. My preferred way is to use esbuild, so these are tailored to that. Hopefully it can be of some use.

# Dockerfile.dev
ARG RUBY_VERSION
FROM ruby:$RUBY_VERSION

RUN apt update -qq && apt upgrade -y
RUN apt install -y build-essential
RUN apt install -y postgresql-client
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt update -qq
RUN apt install -y nodejs yarn
RUN gem update --system
RUN gem install bundle

WORKDIR /app
RUN echo 'gem: --no-rdoc --no-ri >> "$HOME/.gemrc"'

COPY Gemfile Gemfile.lock ./
COPY package.json yarn.lock ./

RUN bundle install -j $(nproc)
RUN yarn install
# docker-compose.yml
version: '3.8'
x-base: &base
  build:
    context: .
    dockerfile: ./Dockerfile.dev
    args:
      RUBY_VERSION: '3.1.3'
  stdin_open: true
  tty: true
  volumes:
    - .:/app:cached
  environment:
    - DATABASE_URL=postgres://postgres:postgres@postgres:5432
  depends_on:
    - redis
    - postgres

services:
  app:
    <<: *base
    command: bin/rails server -p 3000 -b 0.0.0.0
    ports:
      - '3000:3000'

  css:
    <<: *base
    command: yarn build:css --watch

  js:
    <<: *base
    command: yarn build --watch

  # sidekiq:
  #   <<: *base
  #   command: bundle exec sidekiq -C config/sidekiq.yml

  redis:
    image: redis:latest
    restart: always

  postgres:
    image: postgres:14-alpine
    volumes:
      - postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=postgres
    ports:
      - 5432

volumes:
  postgres:

Additionally, I also modify the bin/dev with docker compose up

# bin/dev
#!/usr/bin/env bash

docker compose up

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.