From 752b23dbb403032cf67e6d29205e04474d2e19a2 Mon Sep 17 00:00:00 2001 From: Yatish Mehta Date: Tue, 14 May 2024 19:11:10 -0700 Subject: [PATCH] Fixed Gemfile --- Gemfile.lock | 4 +- README.md | 72 ++++++++++++++++++++++++-------- bin/setup | 12 ------ docs/installing_prerequisites.md | 21 ++++++++-- 4 files changed, 74 insertions(+), 35 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b150c77..2259673 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -242,7 +242,7 @@ GEM rdoc (6.6.3.1) psych (>= 4.0.0) regexp_parser (2.9.1) - reline (0.5.6) + reline (0.5.7) io-console (~> 0.5) rexml (3.2.6) rubocop (1.63.5) @@ -312,7 +312,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.13) + zeitwerk (2.6.14) PLATFORMS aarch64-linux diff --git a/README.md b/README.md index 68a8c6a..1eeaa88 100644 --- a/README.md +++ b/README.md @@ -25,46 +25,82 @@ ## Getting Started ๐Ÿ’ป +Shore is preconfigured base Ruby on Rails application. You can clone this repository and add it to your repo. + +```bash +git clone git@github.com:yatish27/shore.git your_new_project_name +``` + +### Requirements +You will need the following installed to run the application. -### Prerequisites - Ruby 3.3.1 - Check the [.ruby-version](.ruby-version) - PostgreSQL 16.3 - Bun 1.1.8 -- [Overmind](https://github.com/DarthSim/overmind) (optional), it will be used in place of Foreman - `brew install tmux overmind` - +- [Overmind](https://github.com/DarthSim/overmind) (optional), it will be used in place of Foreman. +- Docker & Docker Desktop if you want to use docker compose for local development Refer [installing prerequisites](./docs/installing_prerequisites.md) to install these dependencies -### Building a new application +All Homebrew dependencies are in `Brewfile`, you can install them in one shot. -1. Clone the base repository -``` -git clone git@github.com:yatish27/shore.git your_new_project_name +```bash +brew bundle install --no-upgrade ``` +Make sure your postgresSQL server is running. -2. Enter the project directory -``` -cd your_new_project_name +### Initial setup + +The default name of the application is Shore. You can rename the application to you desired new name. +The name should be in camelcase. + +```bash +./bin/replace_name YourNewProjectName ``` -3. Replace `Shore` with your application's name. The name should be camelCase. +Copy the `env.sample` to `.env` + +The default username and password for database is set to `postgres` and `password`. You can override them in `.env` file. + +Run `bin/setup` to setup the application. It prepares the database, install the required ruby gems and javascript packages. The script is idempotent, so you can run it multiple times. +```bash +./bin/setup ``` -./bin/replace_name YourNewProjectName + +### Running the application +Start your application + +```bash +bin/dev ``` -4. Run setup +This runs overmind or foreman using the Procfile.dev. It starts the rails server, solid queue background job process and vite server. + +Visit `http://localhost:3000` to see the home page ๐Ÿš€. + +### Running locally with docker compose +Shore has support for docker and docker compose for local development. +Refer the [Dockerfile](./Dockerfile.dev) and [docker-compose.yml](./docker-compose.yml). + +Once you have cloned the repository and have docker installed + +- Run `docker compose build` to build. It will build the images. +- Run `docker compose run --rm web bin/setup` to create and setup the database. +- Run `docker-compose up` to start the application. +Since the local code from your host machine is mounted in the docker container, any change made in the code will be directly reflected. You don't need to rebuild you container. + +## Testing ๐Ÿงช +Running all tests ``` -./bin/setup +./bin/rails test:all ``` -5. Start your application +Running a single test ``` -bin/dev +./bin/rails test test/jobs/hello_world_job_test.rb ``` -6. Visit `http://localhost:3000` - diff --git a/bin/setup b/bin/setup index 26c7991..2f42380 100755 --- a/bin/setup +++ b/bin/setup @@ -31,18 +31,6 @@ FileUtils.chdir APP_ROOT do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - - if File.exist?(".env.sample") && !File.exist?(".env") - puts "\n== Copying env.sample files ==" - FileUtils.cp ".env.sample", ".env" - puts "Copied .env.sample to .env".green - end - - # # Install system dependencies if Homebrew is installed - # if Gem::Platform.local.os.include?("darwin") && command?("brew") - # puts "\n== Installing packages with Homebrew ==" - # system("brew bundle check --no-lock --no-upgrade") || system!("brew bundle --no-upgrade --no-lock") - # end puts "\n== Installing gems ==" system! "gem install bundler --conservative" diff --git a/docs/installing_prerequisites.md b/docs/installing_prerequisites.md index 41aeada..88ed132 100644 --- a/docs/installing_prerequisites.md +++ b/docs/installing_prerequisites.md @@ -69,8 +69,6 @@ ALTER ROLE postgres WITH PASSWORD 'password'; ## Bun Visit [bun.sh](https://bun.sh/docs/installation) to learn about installation process -### Using homebrew - ``` brew install oven-sh/bun/bun ``` @@ -79,4 +77,21 @@ After installing, check the version ``` bun -v -``` \ No newline at end of file +``` + +## Overmind +Overmind is an alternative to Foreman. It requires tmux +[Overmind](https://github.com/DarthSim/overmind) + +``` +brew install tmux overmind +``` + +## Docker +Install docker using homebrew +``` +brew install docker +``` +Latest version of docker install docker compose along with it. + +To install the docker desktop, visit https://www.docker.com/products/docker-desktop/ \ No newline at end of file