diff --git a/.env-example b/.env-example index 627f8f78..109b5bc4 100644 --- a/.env-example +++ b/.env-example @@ -1,4 +1,5 @@ ENVIRONMENT=development +SECRET_KEY_BASE=secretkeybasehere POSTGRES_USER=yourusernamehere POSTGRES_PASSWORD=yourpasswordhere diff --git a/app/javascript/helpers/createStore.ts b/app/javascript/helpers/createStore.ts index a4a87388..b894f964 100644 --- a/app/javascript/helpers/createStore.ts +++ b/app/javascript/helpers/createStore.ts @@ -1,19 +1,19 @@ import { createStore, applyMiddleware } from 'redux'; -import { composeWithDevTools } from 'redux-devtools-extension'; +// import { composeWithDevTools } from 'redux-devtools-extension'; import thunkMiddleware from 'redux-thunk'; import rootReducer from '../reducers/rootReducer'; -const composeEnhancers = composeWithDevTools({ - trace: true, -}); +// const composeEnhancers = composeWithDevTools({ +// trace: true, +// }); const createStoreHelper = () => ( createStore( rootReducer, - composeEnhancers( + // composeEnhancers( applyMiddleware(thunkMiddleware) - ) + // ) ) ); diff --git a/config/database.yml b/config/database.yml index d68f1c4f..4fdcd7b4 100644 --- a/config/database.yml +++ b/config/database.yml @@ -21,11 +21,10 @@ default: &default host: db username: <%= ENV['POSTGRES_USER'] %> password: <%= ENV['POSTGRES_PASSWORD'] %> + database: <%= ENV['POSTGRES_USER'] %> development: <<: *default - database: app_development - # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. # When left blank, postgres will use the default role. This is @@ -59,7 +58,7 @@ development: test: <<: *default database: app_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 # ever seen by anyone, they now have access to your database. @@ -81,4 +80,3 @@ test: # production: <<: *default - database: app_production diff --git a/config/environments/production.rb b/config/environments/production.rb index cfe4e80d..1fb3ae60 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,7 +20,7 @@ Rails.application.configure do # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = true # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 00000000..f150fa7a --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,16 @@ +# Be sure to restart your server when you change the secret. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. + +development: + secret_key_base: <%= ENV['SECRET_KEY_BASE'] %> + +test: + secret_key_base: <%= ENV['SECRET_KEY_BASE'] %> + +production: + secret_key_base: <%= ENV['SECRET_KEY_BASE'] %> diff --git a/docker-compose.yml b/docker-compose.yml index 83d8b2f2..d9157a61 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: environment: - UPDATE=0 - ENVIRONMENT + - SECRET_KEY_BASE - POSTGRES_USER - POSTGRES_PASSWORD - EMAIL_CONFIRMATION diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 490021d9..746ee027 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -18,7 +18,16 @@ rm -f /app/tmp/pids/server.pid if [ "$UPDATE" = 1 ]; then # Create database, load schema, run migrations and seed data in an idempotent way. echo "Preparing database..." - rake db:prepare + db_version=$(bundle exec rake db:version) + echo "$db_version" + if [ "$db_version" = "Current version: 0" ]; then + bundle exec rake db:create + bundle exec rake db:schema:load + bundle exec rake db:migrate + bundle exec rake db:seed + else + bundle exec rake db:migrate + fi echo "Database prepared." # Use webpack to build JS and CSS. @@ -37,11 +46,13 @@ fi # Use case 3 echo "Environment is: $ENVIRONMENT" +export RAILS_ENV="$ENVIRONMENT" +export NODE_ENV="$ENVIRONMENT" if [ $ENVIRONMENT == "development" ]; then # Launch Rails server and webpack-dev-server using Foreman foreman start -p 3000 else # production - # Compile assets with Webpack and then launch Rails server + # Compile assets and launch server ./bin/webpack rails server -e production fi \ No newline at end of file