Skip to content

Commit

Permalink
update server hosts configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeragamba committed May 25, 2024
1 parent 283d108 commit 2c46c93
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
15 changes: 7 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
HOSTNAME=localhost

APP_HOST=localhost
APP_PORT=3001
APP_URL=https://${APP_HOST}:${APP_PORT}
APP_ENV=development

APP_PORT=8080
APP_URL=https://${HOSTNAME}:${APP_PORT}

# Router Config
SSL_CRT=./.certs/current.crt
SSL_KEY=./.certs/current.key

Expand All @@ -19,6 +18,6 @@ TOKEN_SECRET=token-secret
# Development Config
DEV_DB_PORT=5432
DEV_CLIENT_PORT=3000
DEV_CLIENT_URL=https://${HOSTNAME}:${DEV_CLIENT_PORT}
DEV_SERVER_PORT=3001
DEV_SERVER_URL=https://${HOSTNAME}:${DEV_SERVER_PORT}
DEV_CLIENT_URL=https://${APP_HOST}:${DEV_CLIENT_PORT}
DEV_SERVER_PORT=${APP_PORT}
DEV_SERVER_URL=https://${APP_HOST}:${DEV_SERVER_PORT}
6 changes: 3 additions & 3 deletions docker-compose.shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ services:
environment:
RAILS_ENV: "${APP_ENV}"

CLIENT_URL: "${APP_URL}"
SERVER_URL: "${APP_URL}/api"
IMAGES_URL: "${APP_URL}/images"
APP_HOST: "${APP_HOST}"
APP_URL: "${APP_URL}"
APP_NAME: "${APP_NAME}"

DB_HOST: db # internal docker host
DB_PORT: 5432
Expand Down
7 changes: 1 addition & 6 deletions server/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Dotenv.load('../.env')
Dotenv::Rails

module ZeraDraws
module Server
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
Expand All @@ -40,11 +40,6 @@ class Application < Rails::Application
# Skip views, helpers and assets when generating a new resource.
config.api_only = true

config.hosts << "server"
config.hosts << "router"
config.hosts << "localhost"
config.hosts << "(.*\.)?zeragamba.art"

config.autoload_paths << 'app/views'
config.autoload_paths << 'app/lib'

Expand Down
14 changes: 9 additions & 5 deletions server/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# Load the Rails application.
require_relative "application"

HOSTNAME = ENV.fetch("HOSTNAME") { "zeragamba.art" }
SERVER_URL = ENV.fetch("HOST_URL") { "https://#{HOSTNAME}" }
CLIENT_URL = ENV.fetch("CLIENT_URL") { SERVER_URL }
APP_NAME = ENV.fetch("APP_NAME") { "Zeragamba Draws" }
APP_HOST = ENV.fetch("APP_HOST")
APP_NAME = ENV.fetch("APP_NAME")
APP_URL = ENV.fetch("APP_URL") { "https://#{APP_HOST}" }

CLIENT_URL = ENV.fetch("CLIENT_URL") { "#{APP_URL}" }
SERVER_URL = ENV.fetch("SERVER_URL") { "#{APP_URL}/api" }
IMAGES_URL = ENV.fetch("IMAGES_URL") { "#{APP_URL}/images" }

AUTH_TOKEN_SECRET = ENV.fetch("TOKEN_SECRET")
AUTH_TOKEN_ALGO = 'HS512'

PROJECT_ROOT = Rails.root.join('..')
IMAGES_DIR = PROJECT_ROOT.join(ENV.fetch("IMAGES_DIR"))
IMAGES_URL = ENV.fetch("IMAGES_URL")

Rails.application.config.hosts << APP_HOST

# Initialize the Rails application.
Rails.application.initialize!

0 comments on commit 2c46c93

Please sign in to comment.