Closed dillonco closed 7 years ago
Nice, but I think in use .env
to handle environment variables
https://docs.docker.com/compose/environment-variables/#/setting-environment-variables-with-docker-compose-run
I don't think adding the database files is a good practice. Indeed there would be nice for the database to be initialised, but I think it should be via some script/fixtures that would do it programatically.
Thanks for the comments! Yeah we can store the environment variables in an .env file, I like that. I'll remove the database files and work on adding a script to populate the database automatically.
Let me make some changes to the request.
I think this for create DB and Tables:
let dbExists = !!(await rethinkdb.dbList()).includes(config.database.name);
if (!dbExists) {
rethinkdb.dbCreate(config.database.name).run();
rethinkdb.db(config.database.name).tableCreate("Carts").run();
rethinkdb.db(config.database.name).tableCreate("Checkouts").run();
rethinkdb.db(config.database.name).tableCreate("Collections").run();
rethinkdb.db(config.database.name).tableCreate("Contents").run();
rethinkdb.db(config.database.name).tableCreate("Orders").run();
rethinkdb.db(config.database.name).tableCreate("Products").run();
rethinkdb.db(config.database.name).tableCreate("Users").run();
Not been tested but it is an idea of the app create the tables if there is
I made the following changes:
Still some more work to be done but it's late again, let me know your comments and I'll keep improving on the pull request.
Latest commit creates a database if it doesn't exist. It also allows you to set the environment through the .env file. Works pretty well, give it a try! I also want to add automatic JWT key generation to the dockerfile. I'll close this request and send a new proper one later.
Setup Docker so that it's an easy dev installation. Docker Compose automatically installs node and rethink, then runs the npm install and run for you. I changed the Dockerfile to be a lot slimmer and tested it locally. Also I added the basic empty tables to rethink and commited the files, I'm not sure if they will work though.
Also I cleaned up the readme a bit.