yongjhih / docker-parse-server

Provide docker images and docker stack for parse-server npm versions and latest commit
https://hub.docker.com/r/yongjhih/parse-server/
Apache License 2.0
475 stars 166 forks source link

Where to place .p12 for push notification? #36

Closed katopz closed 8 years ago

katopz commented 8 years ago

Refer to readme if I want to test push notification I've to add path to .p12 here.

DEV_PFX: $DEV_PFX

So I suppose to upload .p12 somewhere in docker container am I right? The question is which path? and how? via git? scp? to where? parse-server? And when it go production, how to secure it?

Thanks

yongjhih commented 8 years ago

I updated docker-compose.yml, and you should docker pull yongjhih/parse-server to get latest parse-server docker image.

Place .p12 to ./volumes/production-pfx and/or ./volumes/dev-pfx and restart docker stack.

mv /xxx/.p12 ./volumes/production-pfx
docker-compose down
docker-compose up

And DEV_PFX is not necessary.

katopz commented 8 years ago

Cool, BTW it throw error when I'm not config it yet at the moment.

fs.js:976
  return binding.lstat(pathModule._makeLong(path));
                 ^
2016-04-30T15:54:59.937599902Z 
Error: ENOENT: no such file or directory, lstat '/production-pfx'
    at Error (native)
    at Object.fs.lstatSync (fs.js:976:18)
    at Object.<anonymous> (/parse/index.js:35:9)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:159:18)
[nodemon] app crashed - waiting for file changes before starting...

It didn't required before so it shouldn't throw error?

Thanks

yongjhih commented 8 years ago

Did you fetch latest commit of this project? I updated docker-compose.yml before, I think you need it.

katopz commented 8 years ago

@yongjhih Gotcha! working now :)

katopz commented 8 years ago

I try to send push from dash board but not success yet. Did I place it right? screen shot 2559-05-02 at 18 17 35

It would be nice if we've some console.log to tell that certificate is there and valid. Apart from certificate, Is there another config required to use push notifications? How can I debug where and what made push notfication failed?

Thanks

yongjhih commented 8 years ago

volumes/dev-pfx is a file as .p12, so rename your Cerificates.p12 to dev-pfx

katopz commented 8 years ago

like this? screen shot 2559-05-03 at 23 57 07

yongjhih commented 8 years ago

Yes

katopz commented 8 years ago

Hm weird. I got

devPfx : null
devPushConfig : undefined
pushConfig : undefined
verifyUserEmails : false
emailModule : 
emailAdapter : undefined

But when I changed code to

var devPfx = '/dev-pfx';
// if (!fs.lstatSync(devPfx).isFile()) devPfx = null;

I got

devPfx : /dev-pfx
devPushConfig : [object Object]
pushConfig : [object Object]
verifyUserEmails : false
emailModule : 
emailAdapter : undefined

Something wrong with if (!fs.lstatSync(devPfx).isFile()) it's always true and made devPfx null all the time.

yongjhih commented 8 years ago

Oh, sorry. I replied wrong answer before. Remove your dev-pfx directory, and rename your Certificate.p12 to dev-pfx as file.

katopz commented 8 years ago

I think

- "./volumes/dev-pfx:/dev-pfx"

in docker compose made it to be Docker folder. because when I check....

console.log('fs.lstatSync(devPfx).isFile() : ' + fs.lstatSync(devPfx).isFile());
console.log('fs.lstatSync(devPfx).isDirectory() : ' + fs.lstatSync(devPfx).isDirectory());

I got

fs.lstatSync(devPfx).isFile() : false
fs.lstatSync(devPfx).isDirectory() : true

So current code will return false and always devPfx : null there Hre's what it look like via Kitematic screen shot 2559-05-04 at 22 52 39

And I don't think we can use it as file there?

katopz commented 8 years ago

This is working btw

var devPfx = process.env.DEV_PFX || '/dev-pfx/dev-pfx.p12';

And place dev-pfx.p12 inside dev-pfx folder also remap /dev-pfx with ral folder.

And I think you need to fix this too.

dev-pfx-cert.pem.isFile : false
dev-pfx-key.pem.isFile : false

Should it be easier if we use 1 folder and have every cers in there? e.g.

cers/dev-pfx.p12
cers/dev-pfx-cert.pem
cers/dev-pfx-key.pem

File name is unique anyway.

yongjhih commented 8 years ago

Anyway, now we expect that are files:

- /dev-pfx (file)
- /dev-pfx-cert.pem (file)
- /dev-pfx-key.pem (file)

If you did not place these files into ./volumes/ before, docker will create dummy directories as defaults:

- /dev-pfx/ (dir)
- /dev-pfx-cert.pem/ (dir)
- /dev-pfx-key.pem/ (dir)

So we must to check that be file in js. Until you remove these dirs, overwrite them by files. (I think given a certs mount dir avoid dummy dirs by docker)

In official docs represents pfx can be p12 or other file format, so I did not given suffix filename for it.

katopz commented 8 years ago

if you did not place these files into ./volumes/ before, docker will create dummy directories as defaults:

That gotcha moment! This should add to README or could be better if just let Docker mount cers folder and let everyone put cers related in after that so no one stuck at this like me tho. ;)

Thanks anyway, push is fire and working perfectly.

yongjhih commented 8 years ago

Maybe good. I did not expect it's hard to explain that

volumes/dev-pfx is a file as .p12, so rename your Cerificates.p12 to dev-pfx as file.

ref. https://github.com/yongjhih/docker-parse-server/commit/f45040f247493fe3f2ed0345ce6fc80b433ed33b

BTW, this project is welcome PR, i think you can make it good README by your experiences.

katopz commented 8 years ago

Sure! I'll do PR when I get it right. I'm also blog my step here.

BTW, What it will look like for multiple app? (I'm almost forget about multiple certs)

katopz commented 8 years ago

Oh, Here's another issue I found when I use dev-pfx

var devPfx = process.env.DEV_PFX || '/certs/dev-pfx';
console.log('fs.lstatSync(devPfx).isFile() : ' + fs.lstatSync(devPfx).isFile());
console.log('fs.lstatSync(devPfx).isDirectory() : ' + fs.lstatSync(devPfx).isDirectory());

I'll get

2016-05-07T13:16:41.004512973Z 
Error: ENOENT: no such file or directory, lstat '/certs/dev-pfx'
    at Error (native)
    at Object.fs.lstatSync (fs.js:976:18)
    at Object.<anonymous> (/parse/index.js:62:53)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:159:18)
[nodemon] app crashed - waiting for file changes before starting...

But if I use dev-pfx.p12 extension

var devPfx = process.env.DEV_PFX || '/certs/dev-pfx.p12';
console.log('fs.lstatSync(devPfx).isFile() : ' + fs.lstatSync(devPfx).isFile());
console.log('fs.lstatSync(devPfx).isDirectory() : ' + fs.lstatSync(devPfx).isDirectory());

I got

fs.lstatSync(devPfx).isFile() : true
fs.lstatSync(devPfx).isDirectory() : false

Which is weird, this maybe only happen with my machine Mac OSX EL Capitan 10.11.4 fresh install.

yongjhih commented 8 years ago

It's fixed, you can update image bt the following command, docker pull yongjhih/parse-server

katopz commented 8 years ago

Now I know what going on here, Mac is Hide extension! When you rename from foo.p12 to foo via Finder it will appear in finder as foo but will still foo.p12!

screen shot 2559-05-08 at 12 10 56

To proper rename to .p12 is use terminal instead.

$ mv Certificates.p12 dev-pfx

Cheers