Closed alexgleason closed 8 years ago
Alex, before merging this I'd like to understand what happens at various points in the lifecycle.
How does the developer deploy an update to the app?
And how do they do that without losing the uploaded user generated content in public/uploads?
The data/ folder is also meant to be persistent.
I think it might make more sense for this to be presented in a HOWTO on the doc site rather than making it stock, but having it be stock in the boilerplate could work if there is also a HOWTO, and a link in a comment in the dockerfile to that perhaps.
On Wed, Oct 5, 2016 at 7:22 PM, Alex Gleason notifications@github.com wrote:
See my issue comment https://github.com/punkave/apostrophe/issues/619#issuecomment-245484175 on #619 for more information.
If you're interested in making this easy for people using Docker, this is something I've used with Apostrophe and it works fine. It's dead simple: all it does is copies the project folder into the node 6.5.0 https://hub.docker.com/_/node/ Docker image, then runs npm run start when the container starts. Since Apostrophe doesn't have any other requirements, this is all we need.
I've taken an unopinionated (and best practices https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/run-only-one-process-per-container) approach by not including MongoDB in this image. Docker users should know how to make their own separate Mongo container (using the provided Mongo Docker image https://hub.docker.com/_/mongo/) and link it with this one.
This works with a demo Candlewaster site
https://notabug.org/candlewaster/candlewaster-apostrophe I've built.
You can view, comment on, or merge this pull request online at:
https://github.com/punkave/apostrophe-boilerplate/pull/4 Commit Summary
- Add Dockerfile
File Changes
- A Dockerfile https://github.com/punkave/apostrophe-boilerplate/pull/4/files#diff-0 (12)
Patch Links:
- https://github.com/punkave/apostrophe-boilerplate/pull/4.patch
- https://github.com/punkave/apostrophe-boilerplate/pull/4.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/punkave/apostrophe-boilerplate/pull/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB9fZZ3OB4bMdpsg_o7Es6tj4cSzR8oks5qxDEkgaJpZM4KPZEy .
THOMAS BOUTELL, SUPPORT LEAD P'UNK AVENUE | (215) 755-1330 | punkave.com
(Thank you for pursuing this Alex!)
On Mon, Oct 10, 2016 at 10:30 AM, Tom Boutell tom@punkave.com wrote:
Alex, before merging this I'd like to understand what happens at various points in the lifecycle.
How does the developer deploy an update to the app?
And how do they do that without losing the uploaded user generated content in public/uploads?
The data/ folder is also meant to be persistent.
I think it might make more sense for this to be presented in a HOWTO on the doc site rather than making it stock, but having it be stock in the boilerplate could work if there is also a HOWTO, and a link in a comment in the dockerfile to that perhaps.
On Wed, Oct 5, 2016 at 7:22 PM, Alex Gleason notifications@github.com wrote:
See my issue comment https://github.com/punkave/apostrophe/issues/619#issuecomment-245484175 on #619 for more information.
If you're interested in making this easy for people using Docker, this is something I've used with Apostrophe and it works fine. It's dead simple: all it does is copies the project folder into the node 6.5.0 https://hub.docker.com/_/node/ Docker image, then runs npm run start when the container starts. Since Apostrophe doesn't have any other requirements, this is all we need.
I've taken an unopinionated (and best practices https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/run-only-one-process-per-container) approach by not including MongoDB in this image. Docker users should know how to make their own separate Mongo container (using the provided Mongo Docker image https://hub.docker.com/_/mongo/) and link it with this one.
This works with a demo Candlewaster site
https://notabug.org/candlewaster/candlewaster-apostrophe I've built.
You can view, comment on, or merge this pull request online at:
https://github.com/punkave/apostrophe-boilerplate/pull/4 Commit Summary
- Add Dockerfile
File Changes
- A Dockerfile https://github.com/punkave/apostrophe-boilerplate/pull/4/files#diff-0 (12)
Patch Links:
- https://github.com/punkave/apostrophe-boilerplate/pull/4.patch
- https://github.com/punkave/apostrophe-boilerplate/pull/4.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/punkave/apostrophe-boilerplate/pull/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB9fZZ3OB4bMdpsg_o7Es6tj4cSzR8oks5qxDEkgaJpZM4KPZEy .
THOMAS BOUTELL, SUPPORT LEAD P'UNK AVENUE | (215) 755-1330 | punkave.com
THOMAS BOUTELL, SUPPORT LEAD P'UNK AVENUE | (215) 755-1330 | punkave.com
Awesome, I'll add a HOWTO for this soon.
Persistent data is mounted using Docker volumes. Usually these are passed as command line options when the container is started.
I will also add a VOLUME command in the Dockerfile to serve as a fallback if no command line options are specified. This offers the minimum support for persistent data and will at least ensure that data isn't lost across reboots. Command line arguments can be used to override it. Usually you want to override it so you can give the volume a name or a specific location on the host. Otherwise it will be stored in /var/lib/docker/
So with that said, a developer would update the site by rebuilding the image and deploying it with the same volume options as before. This is made easier with Dokku or docker-compose since they can maintain the database and volume configuration.
OK. I think this should wait for a HOWTO so there can be a link to the HOWTO in the dockerfile or something equivalent, but I'm excited to see it land.
On Mon, Oct 10, 2016 at 2:02 PM, Alex Gleason notifications@github.com wrote:
Awesome, I'll add a HOWTO for this soon.
Persistent data is mounted using Docker volumes. Usually these are passed as command line options when the container is started.
I will also add a VOLUME command in the Dockerfile to serve as a fallback if no command line options are specified. This offers the minimum support for persistent data and will at least ensure that data isn't lost across reboots. Command line arguments can be used to override it. Usually you want to override it so you can give the volume a name or a specific location on the host. Otherwise it will be stored in /var/lib/docker/
So with that said, a developer would update the site by rebuilding the image and deploying it with the same volume options as before. This is made easier with Dokku or docker-compose since they can maintain the database and volume configuration.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/punkave/apostrophe-boilerplate/pull/4#issuecomment-252695237, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB9fQp3xCDE_MuUdnHELNL7HJBO9cmpks5qyn2tgaJpZM4KPZEy .
THOMAS BOUTELL, SUPPORT LEAD P'UNK AVENUE | (215) 755-1330 | punkave.com
@alexgleason Just a quick glance through the Dockerfile does this just copy the app directory to the Docker environment or does it also allow edits from the local files to reflect changes within the Dockerfile, Copying just the source to the container would be great for Production onBuild approach.
I could be completely wrong, but what do you think about these options.
Of course docker compose can also be used to orchestrate your mongodb instance, as well as your development/production containers.
Let me know if there is anywhere I can jump in and help I am more happy to do so. Again thank you for taking this step this is great !!!.
I've updated the Dockerfile to mount /data
as a persistent volume.
@rwatts3 Thank you! You are right that this just copies in the source files of the project and runs it.
Development environment , with forever script running inside Docker container
I think you can use the Dockerfile I shared for local development. If you want this configuration you could npm install --save forever
and alter the start
script inside of package.json
to say ./node_modules/forever/bin/forever app.js
before you build the image. Then when you run the container, mount your project folder to /app
so you can edit the files locally.
I've also considered running a file watcher to rebuild and restart the container any time files are changed. I don't know how well it would work but it seems to be more "correct." Local development with Docker still isn't fantastic.
Production A : Dockerfile that simply adds the app and packages it for a deployment
Yep, that's pretty much what this is!
Production B : Dockerfile that creates volumes for persistent data such as images, config settings things that will be saved from Apostrophe to the disk. If we had everything inside of a container. The next build or update of the application would blow out the existing data if it's not stored persistently within a volume ?
It looks like only /data
needs persistent storage. I've updated my PR to reflect that. Config settings should usually be checked into the git repo and will copy straight into the image without issue.
I think this Dockerfile covers all the situations you've mentioned. Let me know if I missed anything.
Of course docker compose can also be used to orchestrate your mongodb instance, as well as your development/production containers.
Yep! I use Dokku for that personally, but you can do it any way you'd like. I also made a Docker HOWTO PR (punkave/apostrophe-documentation#31) to hopefully make this more clear.
Alex this is great work. True champion here. If you'd like id be willing to provide docker compose files for production and development environments. Also a small read me explaining the awesomeness of docker and going from dev to production / staging. Let me know your thoughts.
On Sun, Oct 16, 2016, 5:41 PM Alex Gleason notifications@github.com wrote:
I've updated the Dockerfile to mount /data as a persistent volume.
@rwatts3 https://github.com/rwatts3 Thank you! You are right that this just copies in the source files of the project and runs it.
Development environment , with forever script running inside Docker container
I think you can use the Dockerfile I shared for local development. If you want this configuration you could npm install --save forever and alter the start script inside of package.json to say ./node_modules/forever/bin/forever app.js before you build the image. Then when you run the container, mount your project folder to /app so you can edit the files locally.
I've also considered running a file watcher to rebuild and restart the container any time files are changed. I don't know how well it would work but it seems to be more "correct." Local development with Docker still isn't fantastic.
Production A : Dockerfile that simply adds the app and packages it for a deployment
Yep, that's pretty much what this is!
Production B : Dockerfile that creates volumes for persistent data such as images, config settings things that will be saved from Apostrophe to the disk. If we had everything inside of a container. The next build or update of the application would blow out the existing data if it's not stored persistently within a volume ?
It looks like only /data needs persistent storage. I've updated my PR to reflect that. Config settings should usually be checked into the git repo and will copy straight into the image without issue.
I think this Dockerfile covers all the situations you've mentioned. Let me know if I missed anything.
Of course docker compose can also be used to orchestrate your mongodb instance, as well as your development/production containers.
Yep! I use Dokku for that personally, but you can do it any way you'd like. I also made a Docker HOWTO PR (punkave/apostrophe-documentation#31 https://github.com/punkave/apostrophe-documentation/pull/31) to hopefully make this more clear.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/punkave/apostrophe-boilerplate/pull/4#issuecomment-254089001, or mute the thread https://github.com/notifications/unsubscribe-auth/AFFsSZ0UrWSXL1dSxmtKoqT0QeCs_18qks5q0sRWgaJpZM4KPZEy .
Whoops. Typing got ahead of my reading. You've already provided a very nice read me. Again nice work !!
On Sun, Oct 16, 2016, 5:44 PM Ryan Watts ryandwatts@gmail.com wrote:
Alex this is great work. True champion here. If you'd like id be willing to provide docker compose files for production and development environments. Also a small read me explaining the awesomeness of docker and going from dev to production / staging. Let me know your thoughts.
On Sun, Oct 16, 2016, 5:41 PM Alex Gleason notifications@github.com wrote:
I've updated the Dockerfile to mount /data as a persistent volume.
@rwatts3 https://github.com/rwatts3 Thank you! You are right that this just copies in the source files of the project and runs it.
Development environment , with forever script running inside Docker container
I think you can use the Dockerfile I shared for local development. If you want this configuration you could npm install --save forever and alter the start script inside of package.json to say ./node_modules/forever/bin/forever app.js before you build the image. Then when you run the container, mount your project folder to /app so you can edit the files locally.
I've also considered running a file watcher to rebuild and restart the container any time files are changed. I don't know how well it would work but it seems to be more "correct." Local development with Docker still isn't fantastic.
Production A : Dockerfile that simply adds the app and packages it for a deployment
Yep, that's pretty much what this is!
Production B : Dockerfile that creates volumes for persistent data such as images, config settings things that will be saved from Apostrophe to the disk. If we had everything inside of a container. The next build or update of the application would blow out the existing data if it's not stored persistently within a volume ?
It looks like only /data needs persistent storage. I've updated my PR to reflect that. Config settings should usually be checked into the git repo and will copy straight into the image without issue.
I think this Dockerfile covers all the situations you've mentioned. Let me know if I missed anything.
Of course docker compose can also be used to orchestrate your mongodb instance, as well as your development/production containers.
Yep! I use Dokku for that personally, but you can do it any way you'd like. I also made a Docker HOWTO PR (punkave/apostrophe-documentation#31 https://github.com/punkave/apostrophe-documentation/pull/31) to hopefully make this more clear.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/punkave/apostrophe-boilerplate/pull/4#issuecomment-254089001, or mute the thread https://github.com/notifications/unsubscribe-auth/AFFsSZ0UrWSXL1dSxmtKoqT0QeCs_18qks5q0sRWgaJpZM4KPZEy .
Not sure if this is the right place to put this. But it's also worth noting the true benefits docker brings to the table. For an agency to be able to hand over a dockerfile and docker compose file to an onboarding dev and have the running in an exact environment for their work means a lot of $$$ saved for said agency.
I believe two of the biggest pain points and cost issues for a small agency or a small team is on-boarding in conjunction with devops dev -> production workflows.
By streamlining this process, this certainly cut's down on cost, and also opens the door to devs whom are not too familiar with said agency's environment stack.
I mean how often have either of us had to "Fix Live" or "Sync Staging" due to an honest mistake from a new and even seasoned dev.
public/uploads must also be persistent storage, unless you're configuring uploadfs to use S3.
Otherwise uploaded images etc. will get blown out on each deployment.
Is this addressed yet?
Thanks!
On Sun, Oct 16, 2016 at 8:49 PM, Ryan Watts notifications@github.com wrote:
Not sure if this is the right place to put this. But it's also worth noting the true benefits docker brings to the table. For an agency to be able to hand over a dockerfile and docker compose file to an onboarding dev and have the running in an exact environment for their work means a lot of $$$ saved for said agency.
I believe two of the biggest pain points and cost issues for a small agency or a small team is on-boarding in conjunction with devops dev -> production workflows.
By streamlining this process, this certainly cut's down on cost, and also opens the door to devs whom are not too familiar with said agency's environment stack.
I mean how often have either of us had to "Fix Live" or "Sync Staging" due to an honest mistake from a new and even seasoned dev.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/punkave/apostrophe-boilerplate/pull/4#issuecomment-254089518, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB9fVmDELEcxdAlxGn6zMn-ZCusb-6lks5q0sYngaJpZM4KPZEy .
THOMAS BOUTELL, SUPPORT LEAD P'UNK AVENUE | (215) 755-1330 | punkave.com
Just added this!
See my issue comment on #619 for more information.
If you're interested in making this easy for people using Docker, this is something I've used with Apostrophe and it works fine. It's dead simple: all it does is copies the project folder into the node 6.5.0 Docker image, then runs
npm run start
when the container starts. Since Apostrophe doesn't have any other requirements, this is all we need.I've taken an unopinionated (and best practices) approach by not including MongoDB in this image. Docker users should know how to make their own separate Mongo container (using the provided Mongo Docker image) and link it with this one.
This works with a demo Candlewaster site I've built.