etsy / 411

An Alert Management Web Application
https://demo.fouroneone.io
MIT License
969 stars 112 forks source link

Docker image on dockerhub #26

Closed trajakovic closed 6 years ago

trajakovic commented 7 years ago

Please provide docker image for testing 411 locally.

Also, docker-compose would be nice.

calh commented 7 years ago

I'm working on one here, and here

But, forewarning it doesn't work yet. I'm having a hard time with the site setup and hostname matching issues.

lbrug commented 7 years ago

Me too @calh I get "invalid credentials" and I checked the apache config and it's Ok. I'll let you know if I have any news.

calh commented 7 years ago

If anyone cares to mess around with mine, here are some rough steps to recreate the issue:

$ docker run -ti --name 411 -p 8080:80 --hostname try_something \
   -v ~/411_data:/data calh/etsy_411
# on first run it'll run the data migration tools to construct the 
# sqlite db in your home dir
$ sqlite3 ~/411_data/data.db
sqlite> update sites set host='try_something_else' where site_id=1;

In the docker container's /var/log/apache2/error.log I get:

[:error] [pid 8] [client 192.168.74.14:25700] except [NONE] 
FOO\\UnauthorizedException: "Invalid nonce specified" 
at [/var/www/411/phplib/REST.php:101] 0:[FOO\\REST->route() 
called at [/var/www/411/htdocs/api/login.php:6]]
kiwiz commented 7 years ago

Most of the time, the 'Invalid nonce specified' error means the 411sess cookie isn't being set correctly. Can you check whether the header is being sent? Another thing you can check is whether HOST/api/data shows the expected hostname value in the JSON it returns.

kiwiz commented 7 years ago

I've uploaded a release of 411. Hopefully that helps efforts here (there are less setup steps).

kbweaver commented 7 years ago

Hey @calh, I had the same problem and it ended up being because the domain of the cookie in the response header was the Docker machine's hostname, which didn't match the domain I was hitting with my browser (localhost). I worked around it by adding the line 127.0.0.1 try_something to my /etc/hosts file (where try_something is the hostname of the Docker machine).

ghost commented 7 years ago

Hey @calh i have got a working version for you if you need it. Can send it to you. I use docker-compose for creating the image and running it.

calh commented 7 years ago

@ChristiaanDouma, sure! I've been side tracked on a ton of other stuff and haven't had a chance to get back to working on 411.

lbrug commented 7 years ago

@ChristiaanDouma would you share it please?

ghost commented 7 years ago

Just a fast version. Quick overview:

docker.zip

sachdeva-vivek commented 7 years ago

@ChristiaanDouma I am trying the steps you listed above. When I try to run step # 6 (run bin/create_sites.php (with port)), I get the following error: `PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 no such table: users in /var/www/411/phplib/DB.php:81 Stack trace:

0 /var/www/411/phplib/DB.php(81): PDO->prepare('SELECT * FROM `...')

1 /var/www/411/phplib/Model.php(494): FOO\DB::query('SELECT * FROM `...', Array)

2 /var/www/411/phplib/Model.php(466): FOO\ModelFinder::getByQuery(Array)

3 /var/www/411/phplib/Auth.php(24): FOO\ModelFinder::getById(NULL)

4 /var/www/411/phplib/411bootstrap.php(66): FOO\Auth::init()

5 /var/www/411/bin/create_site.php(7): require_once('/var/www/411/ph...')

6 {main}

thrown in /var/www/411/phplib/DB.php on line 81 PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 no such table: config in /var/www/411/phplib/DB.php:81 Stack trace:

0 /var/www/411/phplib/DB.php(81): PDO->prepare('SELECT value ...')

1 /var/www/411/phplib/DBArray.php(40): FOO\DB::query('SELECT value ...', Array, 1)

2 /var/www/411/phplib/Cookie.php(187): FOO\DBArray->offsetGet('cookie_secret')

3 /var/www/411/phplib/Cookie.php(91): FOO\Cookie::getKey()

4 /var/www/411/phplib/Cookie.php(106): FOO\Cookie::generate(Array, 1487122699)

5 /var/www/411/phplib/Cookie.php(33): FOO\Cookie::write()

6 [internal function]: FOO\Cookie::FOO{closure}()

7 {main}

thrown in /var/www/411/phplib/DB.php on line 81`

Looks like the tables do not exist. Could you let me know how to set them up?

Thanks

ghost commented 7 years ago

Looks like the data.db is missing. This could be one of three things

  1. Did you did the run commands
  2. did you copy it to the tmp?
  3. Is the mount in docker-compose missing the tmp folder and therefore the data.db file.
sachdeva-vivek commented 7 years ago

Thanks @ChristiaanDouma for the quick response. Up to step #5, everything ran fine. I have /tmp directory in the container and the contents are: root@44592e990782:/tmp# ls -all total 36 drwxr-xr-x 1 nxtgen staff 306 Feb 15 17:22 . drwxr-xr-x 81 root root 4096 Feb 15 17:19 .. -rw-r--r-- 1 nxtgen staff 6148 Feb 15 17:22 .DS_Store -rwxr-xr-x 1 nxtgen staff 482 Nov 16 04:32 411.conf -rwxr-xr-x 1 nxtgen staff 982 Nov 15 18:49 411_crontab -rwxr-xr-x 1 nxtgen staff 481 Nov 16 04:31 411_ssl.conf -rwxr-xr-x 1 nxtgen staff 3282 Oct 4 15:08 Graphite.php -rwxr-xr-x 1 nxtgen staff 687 Nov 16 04:17 docker-entrypoint.sh -rwxr-xr-x 1 nxtgen staff 335 Nov 15 15:26 ports.conf

As you can see, it doesn't have data.db file. I don't see it in the /var/www/411 either. Where do I need to copy it from?

ghost commented 7 years ago

Step 4 set a mount ((/tmp) from the docker container to your host vm ($PWD/centos7-nxtgen-411/artifacts/)

Step 5 to 7 create the data.db file. Step 8 copies the file to /tmp so makes it available to the host VM at $PWD/centos7-nxtgen-411/artifacts/

When running docker-compose on step 11 it will use your created data.db file from the host (check the docker-compose.yml under volumes)

sachdeva-vivek commented 7 years ago

It worked. I was missing sqlite3 data.db < db.sql

I get the following error now when I run step#11 (docker-compose up)

Starting dockeretsy411_elasticsearch-central_1

ERROR: for elasticsearch-central rpc error: code = 2 desc = "oci runtime error: could not synchronise with container process: not a directory" Attaching to

Any ideas?

ghost commented 7 years ago

Hmm, it uses also elasticsearch in a docker container. It's missing the config file of elasticsearch. So either you create one of connect to a elastic search cluster you already have.

kiwiz commented 7 years ago

@calh I'm going to take a stab at finishing up Docker support for 411. Have you hit any new problems during set up that I should keep in mind when working on this?

calh commented 7 years ago

@kiwiz that'd be awesome. I've been so busy with other stuff I haven't had a chance to get back to trying 411 in Docker again. I needed an ELK paging system that I could fire up and get working right away, so I've been using Bosun. But I'm excited to try out the features in 411!

kiwiz commented 7 years ago

A docker image has been set up here: https://hub.docker.com/r/kaiz/411 (Docs coming later)