about summary refs log tree commit diff
path: root/boxfile.yml
diff options
context:
space:
mode:
authorDaniel Hunsaker <danhunsaker@gmail.com>2017-05-29 09:59:18 -0600
committerEugen Rochko <eugen@zeonfederated.com>2017-05-29 17:59:18 +0200
commit9ead3d1cdbac2cc40d8926be116cbe15cbf7f24d (patch)
tree400cbb1e9fcb6f028d785d7b71de2008ed758702 /boxfile.yml
parent402c19a92475014e04df91eca759225f8a89d2ac (diff)
[nanobox] Adjustments for Nanobox development (#3295)
Because Nanobox doesn't run data components in the same container as the code, there are a few tweaks that need to be made in the configuration to get WebPack to work properly in development mode.

The same differences lead to needing to use `DATABASE_URL` by default in the `.env` file for Rails to work correctly.

Limitations of our `.env` loader for Node.js mean the `.env` file needs to be compiled everywhere in order to work, so we compile it in development, now, too. Also, all the `.env.production` tweaks have been consolidated into a single command.

Finally, since Nanobox actually creates the database when it sets up the database server, using the existence of the database alone to determine whether to migrate or setup is insufficient. So we add a condition to `rake db:migrate:setup` to check whether any migrations have run - if the database doesn't exist yet, `db:setup` will be called; if it does, but no migrations have been run, `db:migrate` and `db:seed` are called instead (the same basic idea as what `db:setup` does, but it skips `db:create`, which will only cause problems with an existing DB); otherwise, only `db:migrate` is called.

None of these changes should affect development, and all are designed not to interfere with existing behaviors in other environments.
Diffstat (limited to 'boxfile.yml')
-rw-r--r--boxfile.yml5
1 files changed, 2 insertions, 3 deletions
diff --git a/boxfile.yml b/boxfile.yml
index 65f5f6c8c..2fa3fb9ff 100644
--- a/boxfile.yml
+++ b/boxfile.yml
@@ -31,7 +31,7 @@ run.config:
     - yarn.lock
 
   extra_steps:
-    - cp .env.nanobox .env
+    - envsubst < .env.nanobox > .env
     - gem install bundler
     - bundle config build.nokogiri --with-iconv-dir=/data/ --with-zlib-dir=/data/
     - bundle config build.nokogumbo --with-iconv-dir=/data/ --with-zlib-dir=/data/
@@ -43,9 +43,8 @@ run.config:
 deploy.config:
   extra_steps:
     - NODE_ENV=production bundle exec rake assets:precompile
-    - "[ -r /app/.env.production ] || sed 's/LOCAL_HTTPS=.*/LOCAL_HTTPS=true/i' /app/.env.nanobox > /app/.env.production"
   transform:
-    - envsubst < /app/.env.production > /tmp/.env.production && mv /tmp/.env.production /app/.env.production
+    - "sed 's/LOCAL_HTTPS=.*/LOCAL_HTTPS=true/i' /app/.env.nanobox | envsubst > /app/.env.production"
     - |-
         if [ -z "$LOCAL_DOMAIN" ]
         then