Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerizing #292

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Dockerizing #292

wants to merge 5 commits into from

Conversation

YaxelPerez
Copy link
Collaborator

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

Cannot access the server when running on docker if running on 127.0.0.1
Separate docker-compose configurations are used for running and
building/dependency management to allow for live code reloading.
Otherwise, this app would have to be made into a docker image and
rebuilt every time a change is made.
This makefile adds the following commands:

  $ make setup
  $ make migrate
  $ make run
  $ make test
  $ make clean
Adds local installation instructions in INSTALL.md, and a few lines
regarding testing in DEVELOPMENT.md
@frankduncan
Copy link

frankduncan commented Apr 23, 2020

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

docker-compose.yml was running 'npm run dev', a command which no longer
exists in package.json.
@YaxelPerez
Copy link
Collaborator Author

@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
Copy link

@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
Copy link

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

@YaxelPerez
Copy link
Collaborator Author

@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
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants