freedomofpress / securethenews

An automated scanner and web dashboard for tracking TLS deployment across news organizations
https://securethe.news
GNU Affero General Public License v3.0
100 stars 25 forks source link

Converts dev env to use Docker #124

Closed conorsch closed 7 years ago

conorsch commented 7 years ago

Ready for review.

Closes #83.

Leverages the new Molecule-based testing and development workflow to spin up Docker containers for local development, rather than full VMs. Should make for a much more pleasant experience locally.

To test:

  1. Confirm CI is passing (both Travis and Circle).
  2. Run make dev-go and wait for the service to come up.
  3. Browse to the localhost port displayed on screen and navigate through the site.
  4. Confirm you can use the site locally and no errors are reported.
conorsch commented 7 years ago

123 has been merged, so this is ready for review now.

conorsch commented 7 years ago

Thanks for careful review, @redshiftzero. Locally I had gitignored static assets sticking around, and their continued presence between builds was causing the site to render when it shouldn't. Added a make clean to strip out those local assets ad-hoc.

Ported the dev env database settings to use a Postgres container, rather than a local sqlite database. Since Travis was still using sqlite, I disabled Travis, since Circle runs all the app tests in a more prod-like environment (via containers).

The test superuser no longer works for me

Fixed, but you'll need to run make dev-createdevdata in order for that account to be provisioned. Then it should work.

Take it for another spin and let me know.

redshiftzero commented 7 years ago

So, the static assets are still not loading for me. Specifically I'm getting a 404 on the homepage for main.css and build.js (both referenced in the template in securethenews/templates/base.html).

When I hop in the STN node docker container and try to run the build task manually gulp is not found:

$ docker exec -it b034f6754da6 /bin/ash -c "cd /django; npm install; gulp build:production"
npm info it worked if it ends with ok
npm info using npm@2.15.11
npm info using node@v4.8.2
npm info preinstall securethenews@1.0.0
npm info package.json gulp-streamify@1.0.2 No license field.
npm info build /django
npm info linkStuff securethenews@1.0.0
npm info build /django/node_modules/jade
npm info preinstall jade@1.11.0
npm info linkStuff jade@1.11.0
npm info install jade@1.11.0
npm info postinstall jade@1.11.0
npm info install securethenews@1.0.0
npm info postinstall securethenews@1.0.0
npm info prepublish securethenews@1.0.0
npm WARN unmet dependency /django/node_modules/gulp-sass/node_modules/node-sass/node_modules/request/node_modules/http-signature/node_modules/sshpk requires assert-plus@'^1.0.0' but will load
npm WARN unmet dependency /django/node_modules/gulp-sass/node_modules/node-sass/node_modules/request/node_modules/http-signature/node_modules/assert-plus,
npm WARN unmet dependency which is version 0.2.0
npm info ok 
/bin/ash: gulp: not found

Am I missing something?

redshiftzero commented 7 years ago

Update: applying the following:

diff --git a/molecule/dev/playbook.yml b/molecule/dev/playbook.yml
index 36ac0a1..7584966 100644
--- a/molecule/dev/playbook.yml
+++ b/molecule/dev/playbook.yml
@@ -82,6 +82,7 @@
     - name: Wait for node to finish installing deps
       wait_for:
         path: "{{ molecule_scenario_directory }}/../../.node_complete"
+        timeout: 600

     - name: Establish postgres port
       set_fact:

resulted in a completed playbook run _but _my previous issue (the static assets not building) remains (404s on main.css and build.js).

redshiftzero commented 7 years ago
$ docker logs -f 28de9a711135
npm info it worked if it ends with ok
npm info using npm@2.15.11
npm info using node@v4.8.2
npm info preinstall securethenews@1.0.0
npm info package.json gulp-streamify@1.0.2 No license field.
npm info build /django
npm info linkStuff securethenews@1.0.0
npm info build /django/node_modules/jade
npm info preinstall jade@1.11.0
npm info linkStuff jade@1.11.0
npm info install jade@1.11.0
npm info postinstall jade@1.11.0
npm info install securethenews@1.0.0
npm info postinstall securethenews@1.0.0
npm info prepublish securethenews@1.0.0
npm WARN unmet dependency /django/node_modules/browserify/node_modules/readable-stream requires string_decoder@'~1.0.3' but will load
npm WARN unmet dependency /django/node_modules/browserify/node_modules/string_decoder,
npm WARN unmet dependency which is version 0.10.31
npm info ok 
/bin/ash: gulp: not found