Read How to deploy on DigitalOcean.
Docker makes it easy and safe to install and start the two servers required for Openwhyd: the MongoDB database server, and the web/application server (formerly called whydJS).
With this approach, you don’t need to have Node.js installed on your computer.
If you intend to make changes to Openwhyd’s source code, skip to the “Setup for development” section. Otherwise, don’t forget to rebuild Openwhyd’ Docker container after every change. (e.g. docker compose up --build
)
All you need is:
Docker for Windows Home runs on a virtual box, so localhost may not work. For all the instructions below, if localhost is not working, replace it with your docker ip. You can find your docker ip with :
$ docker-machine ip
Commands to type in your shell:
$ git clone https://github.com/openwhyd/openwhyd.git
$ cd openwhyd
$ docker compose up --build --detach # starts openwhyd's web server and database in the background
$ open http://localhost:8080 # ... in your web browser => you should see Openwhyd's home page! 🎉
$ docker compose down --rmi local --remove-orphans # when you're done: stop openwhyd's web server and database
After making changes to the source code, don’t forget to restart with docker compose up --build --detach
, so the containers are rebuilt with the changes.
Commands to run all automated tests in Docker containers:
$ make test-in-docker
If you want to connect to the MongoDB database with the mongo
shell using docker-compose
container:
$ docker-compose exec mongo mongo mongodb://localhost:27117/openwhyd_test
Type these shell commands to run Openwhyd on your computer, against a MongoDB database running in a Docker container:
$ git clone https://github.com/openwhyd/openwhyd.git
$ cd openwhyd
$ nvm use # picks the expected version of Node.js, assuming it's installed
$ make dev # starts openwhyd's web server and database in the background
$ open http://localhost:8080 # ... in your web browser => you should see Openwhyd's home page! 🎉
$ make down # when you're done: stop openwhyd's web server and database
This approach makes it more efficient than the one above to iterate on the code, because there is not need to rebuild a Docker container after every change.
Run all tests, including approval tests:
$ make test
To see what other scripts are available, run:
$ make
And check out the list of scripts
provided in package.json
.
If you want to import some user data from openwhyd.org into your local/test database, you can use the following script:
$ make dev # starts openwhyd's web server and database in the background
$ make docker-seed # clears the database and restarts openwhyd's container
$ node scripts/import-from-prod.js test # imports 21 posts from https://openwhyd.org/test
After that, you will be able to sign in as an administrator using the credentials returned by the script.
The data imported can be seen from http://localhost:8080/all
If you don’t want to use Docker (or can’t), you can follow these instructions.
make
and g++
are installed (required for building npm binaries, I had to do this and this)mongo openwhyd_data config/initdb.js
and mongo openwhyd_data config/initdb_testing.js
)npm install
)npm start
, or make start
(auto-restart daemon)WHYD_URL_PREFIX
)Openwhyd’s entry point (app.js
) accepts two kinds of command-line arguments:
--no-color
, --fakeEmail
and --emailAdminsOnly
; (see FLAGS
from app.js
for an up-to-date list)urlPrefix
can be set as --urlPrefix <value>
. (see process.appParams
from app.js
for an up-to-date list)If you want to test email digests locally:
$ node app.js --emailAdminsOnly --digestInterval 5000 --digestImmediate true
If you want to test Deezer Connect, you will need your server to be reachable through a domain name. Here’s a way to achieve that:
http://local.openwhyd.org:8080
;local.openwhyd.org
to your /private/etc/hosts
file;$ dscacheutil -flushcache
;$ npm start -- --urlPrefix http://local.openwhyd.org:8080
.WHYD_GENUINE_SIGNUP_SECRET
(mandatory. a secret key that is used to make sure that sign-ups are legit)WHYD_SESSION_SECRET
(mandatory. a secret key used to sign session cookies)WHYD_ADMIN_OBJECTID
(ObjectId of the user that can access to admin endpoints)WHYD_ADMIN_NAME
(Full-text name of the user that can access to admin endpoints)WHYD_ADMIN_EMAIL
(mandatory. Email address of the user that can access to admin endpoints)WHYD_CONTACT_EMAIL
(mandatory. email for users to contact the site’s team)WHYD_URL_PREFIX
(default: http://localhost:8080
)WHYD_PORT
(default: 8080
)MONGODB_DATABASE
(example: openwhyd_data
, or openwhyd_test
)MONGODB_HOST
(default: localhost
)MONGODB_PORT
(default: 27017
)MONGODB_USER
(default: none)MONGODB_PASS
(default: none)SENDGRID_API_KEY
(mandatory. API key of the Sendgrid account to be used for sending emails)SENDGRID_API_FROM_EMAIL
(mandatory. email address of email sender)SENDGRID_API_FROM_NAME
(mandatory. name of email sender)LAST_FM_API_KEY
(mandatory. for lastfm scrobbling)LAST_FM_API_SECRET
(mandatory. for lastfm scrobbling)ALGOLIA_APP_ID
(mandatory. for search index)ALGOLIA_API_KEY
(mandatory. for search index)The value of following constants is required to connect to the corresponding APIs:
YOUTUBE_API_KEY
SOUNDCLOUD_CLIENT_ID
JAMENDO_CLIENT_ID
DEEZER_APP_ID