This should only have to be done once, or whenever the Gemfile is updated.
docker-compose build
docker-compose up
DNA Admin should now be available at localhost:8080, but it probably needs to be set up first.
In a new terminal run:
docker-compose exec web rails db:create db:schema:load db:migrate &&
docker-compose exec -e [email protected] -e ADMIN_PASSWORD=spree123 web rails db:seed &&
docker-compose exec web rails spree_sample:load &&
docker-compose restart
email: [email protected] password: spree123
This will reset the existing database back to blank.
docker-compose exec web rails db:reset railties:install:migrations db:migrate db:seed spree_sample:load
You could also blow away all the DB files. WARNING! You'll have to start the install over again if you do this.
sudo rm -rf tmp/db
The system uses 3 spree extensions
spree_reffiliate
(Thanks @Gaurav2728) githubspree_static_content
githubspree_digital
githubspree_promo_users_codes
github
Each one is installed after spree, with it's own migrations generated using a
specific bundle exec rails g
command, which can be found on the README of the github
page for each project. This only needs to be done once after spree is installed or upgraded.
- Generate Affiliate Codes for Existing Users:
bundle exec rake reffiliate:generate
- Create or reset a New Admin User:
docker-compose exec web rails spree_auth:admin:create
This uses heroku ruby buildpack on the heroku-20 stack. The master
branch
on github is hooked in to the deployment.
Git: https://github.com/1instinct/dna-admin
Steps:
- Create pipelines on Heroku
- Add Github repos
- Create apps
- Add PG add-on
heroku config:set -a app-name
heroku stack:set heroku-20 -a app-name
heroku run rails db:seed -a app-name
heroku run rails db:schema:load db:migrate -a app-name
heroku run rails spree_auth:admin:create -a app-name
heroku run rails spree_sample:load -a app-name
To test the production settings locally (used to test things like the S3 buckets
for active storage), you need to set environment variables directly in
the docker-compose.yml
file. The production environment is configured
to NOT use .env
files.
To do this, apply the following patch to docker-compose.yml
(after filling
in real values for the keys and bucket name):
--- docker-compose.yml.orig 2021-06-02 10:50:59.011383071 -0400
+++ docker-compose.yml 2021-06-02 10:51:03.267414021 -0400
@@ -16,4 +16,10 @@
depends_on:
- db
environment:
- DATABASE_URL: postgres://postgres:password@db:5432/dna_admin_development
+ DATABASE_URL: postgres://postgres:password@db:5432/dna_admin_production
+ RAILS_ENV: production
+ AWS_REGION_NAME: us-west-1
+ AWS_BUCKET_NAME:
+ AWS_ACCESS_KEY_ID:
+ AWS_SECRET_ACCESS_KEY:
+ RAILS_SERVE_STATIC_FILES: 1
After building and starting the container, you will need to build the assets in the local container with:
docker-compose exec web rails assets:precompile
docker-compose restart
When there are lots of active changes occuring on this repo, make sure to regularly:
- Commit (or stash) your local changes on your branch
git fetch origin
git checkout main
git pull origin main
git checkout <your_branch>
git rebase origin/main
- Fix merge conflicts (if any)
git add .
git commit
git rebase --continue
Done! …now you will be up-to-date with latest code. Do this before you submit your PR, and you can be sure it will be a clean merge.
Other things we may need 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