redcross / smoke-alarm-portal

Red Cross web portal accepting free smoke alarm installation requests
https://getasmokealarm.org/
Other
7 stars 20 forks source link

Dockerizing #292

Open YaxelPerez opened 4 years ago

YaxelPerez commented 4 years ago

This PR adds a docker-compose configuration and makefile to make it easier to run this project for development.

frankduncan commented 4 years ago

This is failing to work for me. I am on debian stable, and I did sudo apt install docker docker-compose to get started. When I run make run, I get:

docker-compose up --remove-orphans
Starting smokealarmportal_db_1 ... 
Starting smokealarmportal_db_1 ... done
Starting smokealarmportal_web_1 ... 
Starting smokealarmportal_web_1 ... done
Attaching to smokealarmportal_db_1, smokealarmportal_web_1
db_1   | 
db_1   | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1   | 
db_1   | 2020-04-23 22:28:52.412 UTC [1] LOG:  starting PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1   | 2020-04-23 22:28:52.412 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1   | 2020-04-23 22:28:52.413 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1   | 2020-04-23 22:28:52.436 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1   | 2020-04-23 22:28:52.500 UTC [29] LOG:  database system was shut down at 2020-04-23 22:28:50 UTC
db_1   | 2020-04-23 22:28:52.520 UTC [1] LOG:  database system is ready to accept connections
web_1  | npm ERR! missing script: dev
web_1  | 
web_1  | npm ERR! A complete log of this run can be found in:
web_1  | npm ERR!     /root/.npm/_logs/2020-04-23T22_28_53_525Z-debug.log
smokealarmportal_web_1 exited with code 1
YaxelPerez commented 4 years ago

@frankduncan It should work now. I think package.json changed, and when I rebased this branch my docker-compose config was looking for a command that wasn't there anymore.

frankduncan commented 4 years ago

@YaxelPerez Now I'm getting

SequelizeConnectionError: password authentication failed for user "smoke"
    at /usr/src/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:133:20
    at Connection.<anonymous> (/usr/src/app/node_modules/pg/lib/client.js:176:5)
    at emitOne (events.js:116:13)
    at Connection.emit (events.js:211:7)
    at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:109:12)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:601:20)

I have update the config.json on my machine to have smoke/smoke as username and password for the DB. Is that what's breaking it?

frankduncan commented 4 years ago

@YaxelPerez I also tried changing the username/pw in the docker-compose.yml.

YaxelPerez commented 4 years ago

@frankduncan Managed to get the same error. username and password needs to be the same in docker-compose.yml and docker-compose.builder/yml, and container state needs to be reset (make clean && make setup).

I looked into having the makefile read credentials from config/config.json and put them in docker-compose.yml and docker-compose.builder.yml, but it would have made things a lot more complicated since the config file may not exist when make setup is run. It's probably better to add a line about it in the documentation?

frankduncan commented 4 years ago

@YaxelPerez We should create template files and .gitignores so that people don't accidentally check in their development passwords into source control. After that, have documentation about the move.

Also, now that I've done that, I am running into

docker-compose run db psql -d smokealarm_development -f migrations/20151208-admin-access.sql
psql: error: could not connect to server: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

when running the admin access script so I can log in. The docker db is running via make run in another window, and I can access the site and login.