Skip to content

Commit

Permalink
chore: setup commands to prepare dev env in make
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeirojose committed Sep 26, 2024
1 parent 1c51613 commit c7950d9
Show file tree
Hide file tree
Showing 10 changed files with 1,089 additions and 764 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prepare-dev:
@echo "Preparing development environment..."
$(MAKE) -C ./apps/govquests-api prepare-dev
@echo "Database is running on Docker."
@echo "Installing dependencies..."
pnpm install
$(MAKE) -C ./apps/govquests-api install
@echo "Dependencies installed..."
@echo "Development environment ready."

23 changes: 1 addition & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
- Rails API runs in port 3001, and next app runs in port 3000
5 changes: 5 additions & 0 deletions apps/govquests-api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prepare-dev:
docker-compose up -d

install:
bundle install
41 changes: 25 additions & 16 deletions apps/govquests-api/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,37 @@ default: &default
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
checkout_timeout: <%= ENV.fetch("DATABASE_CONNECTION_POOL_TIMEOUT") { 5000 } %>
gssencmode: disable
variables:
statement_timeout: "300s"
lock_timeout: "80s"


development:
development: &development
<<: *default
database: govquests_rails_development

database: govquests_api_development

# The specified database role being used to connect to PostgreSQL.
# To create additional roles in PostgreSQL see `$ createuser --help`.
# When left blank, PostgreSQL will use the default role. This is
# the same name as the operating system user running Rails.
#username: govquests_rails
username: postgres

# The password associated with the PostgreSQL role (username).
#password:
password: postgres

# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
host: localhost

# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432
port: 5432

# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
#schema_search_path: govquests_api,sharedapp,public

# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
Expand All @@ -55,8 +60,8 @@ development:
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: govquests_rails_test
<<: *development
database: govquests_api_test

# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
Expand All @@ -65,7 +70,7 @@ test:
# Instead, provide the password or a full connection URL as an environment
# variable when you boot the app. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# If the connection URL is provided in the special DATABASE_URL environment
# variable, Rails will automatically merge its configuration values on top of
Expand All @@ -81,14 +86,18 @@ test:
production:
primary: &primary_production
<<: *default
database: govquests_rails_production
username: govquests_rails
password: <%= ENV["GOVQUESTS_RAILS_DATABASE_PASSWORD"] %>
database: govquests_api_production
username: govquests_api
password: <%= ENV["govquests_api_DATABASE_PASSWORD"] %>
cache:
<<: *primary_production
database: govquests_rails_production_cache
database: govquests_api_production_cache
migrations_paths: db/cache_migrate
queue:
<<: *primary_production
database: govquests_rails_production_queue
database: govquests_api_production_queue
migrations_paths: db/queue_migrate
cable:
<<: *primary_production
database: govquests_api_production_cable
migrations_paths: db/cable_migrate
2 changes: 1 addition & 1 deletion apps/govquests-api/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
config.action_mailer.perform_caching = false

# Set localhost to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
config.action_mailer.default_url_options = { host: "localhost", port: 3001 }

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
Expand Down
2 changes: 1 addition & 1 deletion apps/govquests-api/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT", 3000)
port ENV.fetch("PORT", 3001)

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
Expand Down
13 changes: 13 additions & 0 deletions apps/govquests-api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
postgres:
image: postgres:latest
restart: unless-stopped
environment:
- POSTGRES_PASSWORD=postgres
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
13 changes: 13 additions & 0 deletions apps/govquests-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@bleu/op-govquests-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "bin/dev"
},
"keywords": [],
"author": "",
"license": "MIT",
"packageManager": "[email protected]"
}
Loading

0 comments on commit c7950d9

Please sign in to comment.