Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

fix(docker): updating the Dockerfile and docker-compose.yml #1249

Merged

Conversation

lirantal
Copy link
Member

@lirantal lirantal commented Mar 4, 2016

updating the Dockerfile and docker-compose.yml for up to date versions of MEAN.JS development environment

Fixes #1067

@lirantal lirantal self-assigned this Mar 4, 2016
@lirantal lirantal added this to the 0.5.0 milestone Mar 4, 2016

# Install Utilities
RUN apt-get update -q
RUN apt-get install -yqq wget aptitude htop vim vim-puppet git traceroute dnsutils curl ssh sudo psmisc gcc make build-essential libfreetype6 libfontconfig tree tcpdump nano
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a lot of tools here? Usually it's better to keep to minimum with Docker.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood, yet the idea is to provide a development environment, not propose an ideal docker setup for production.
are there any packages you think should be strictly left out?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that light this list might be fine!

BTW Check note about "Sort multi-line arguments" from https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/

@simison
Copy link
Member

simison commented Mar 4, 2016

Neat! Should there be separate Docker+docker-compose files for production and development?

@lirantal
Copy link
Member Author

lirantal commented Mar 4, 2016

@simison I think we can focus on the developer perspective for now. Different people do different things in production and I don't think we're at an expertise level to provide an ideal solution out of the box that fits everyone.

@simison
Copy link
Member

simison commented Mar 4, 2016

@lirantal Fair enough. :-)

@lirantal lirantal force-pushed the feature/docker_update_dev_environment branch from 42c71f0 to 1273a43 Compare March 6, 2016 07:56
@lirantal
Copy link
Member Author

lirantal commented Mar 6, 2016

@simison I updated a lot, including all the comments you mentioned.
can you check? :)

@simison
Copy link
Member

simison commented Mar 6, 2016

Cool. What do you think about adding MailDev to development setup? It's suuuper handy. Could be a separate PR:

maildev:
  image: djfarrelly/maildev
  restart: always
  ports:
    - "1080:80"
    - "1025:25"


# Install gem sass for grunt-contrib-sass
RUN apt-get update -qq && apt-get install -y build-essential
FROM ubuntu:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use the ubuntu image instead of the official node image?

@codydaig
Copy link
Member

codydaig commented Mar 7, 2016

Left a couple questions above. Otherwise squash and LGTM.

@lirantal
Copy link
Member Author

@simison

  1. I'll add --quiet for the npm installs, that's a good idea.
  2. agree about a separate PR for maildev, I didn't try it and no idea how that integrates yet
  3. npm start as part of the README sounds like a good idea ( @codydaig ?) but then again it would use grunt which is now the default, so not sure if we want to 'hide' the gulp, grunt behind the scenes in the docs.

@lirantal
Copy link
Member Author

@codydaig

  1. I believe an ubuntu image is a good start for local development beyond MEAN.JS if that will be required. the whole point of this docker container is a quickstart for dev purposes and I don't know what's the history of the official 'nodejs' image template. maybe that would be used for more production/deployment purposes.
  2. With regards to maintainer - I do intend on submitting this dockerfile to the Docker Hub so that's mainly the purpose for it. I couldn't find a reason for removing it before either (not in the commits logs anyway), maybe because it wasn't an official member of the MEAN.JS team but I don't know for sure.

@simison
Copy link
Member

simison commented Mar 10, 2016

@lirantal:

npm start as part of the README sounds like a good idea but then again it would use grunt which is now the default, so not sure if we want to 'hide' the gulp, grunt behind the scenes in the docs.

That's a valid point. My reasoning is that gulp is getting to a new major version soon and I'm afraid globally installed versions will have lots of troubles with wrong versions of Gulp files. That's why it's nice to be able to control your task runner version, esp. when it's isolated environment like Docker. Same for Bower, btw. Pros and cons...

PS. Wasn't the idea to get rid of Grunt?

@lirantal
Copy link
Member Author

@simison understood but I think that's a decision we need to take project-wide in MEAN.JS and not specific to the docker container, right?

@simison
Copy link
Member

simison commented Mar 10, 2016

Totally! Opened this; #1258

@codydaig
Copy link
Member

@lirantal Makes sense. Thanks for addressing those points.

@lirantal
Copy link
Member Author

I'll go ahead and merge then.
I'm checking now at Docker Hub how we can have automated builds as well so we can test the docker image too to make sure it doesn't break, or if it does to know about it.

@codydaig
Copy link
Member

Don't forget to squash! Otherwise, LGTM.

@lirantal
Copy link
Member Author

Of course! :)

@lirantal lirantal force-pushed the feature/docker_update_dev_environment branch from 76f36f4 to 2da1701 Compare March 10, 2016 22:10
@ilanbiala
Copy link
Member

LGTM as long as build passes and Docker works for development purposes.

@lirantal
Copy link
Member Author

Thanks.

Works here, I've built numerous times and also I'm working on connecting an automated build from Docker Hub too.

I'm not on a hurry to merge this so if someone wants to take another day or two to try it out let me know.

@simison
Copy link
Member

simison commented Mar 10, 2016

Does watching (nodemon/gulp watch) files work fine for you and isn't very CPU intensive? I've had issues with that in the past.

I can pull this in tomorrow as well and give it a test.

@lirantal
Copy link
Member Author

@simison Go ahead and try.
Didn't have any CPU issues here :)

The best thing I like about this Docker setup as opposed to the other one is that it is development-ready, meaning you can work with your IDE on Windows/OSx to edit your files and any change you make is immediately shown on the browser with livereload enabled and working out of the box.

@simison
Copy link
Member

simison commented Mar 12, 2016

@lirantal I'm getting first:

web_1 | Running "mkdir:upload" task
web_1 | Warning: Unable to create directory "/opt/mean.js/modules/users/client/img/profile/uploads" (Error code: EACCES). Use --force to continue.

—> Created it manually, works.

Then:

web_1 | Warning: Unable to write "config/env/local-development.js" file (Error code: EACCES). Use --force to continue.

—> Created it manually, works.

The app is running but for some reason I can't connect to it (http://[DOCKER-MACHINE-IP]:3000)

BTW now docker-compose shows logs from previous runs, which can be a lot after a while. Docker-compose 1.6 has some trick to stop that happening, but I can't remember now what exactly. It might've required using docker-compose.yml v2.

@simison
Copy link
Member

simison commented Mar 17, 2016

Ah okay, well I just finished adding it here https://gist.github.com/simison/adcb66908203cdb33dac :-)

@lirantal
Copy link
Member Author

I appreciate it! Good to always have it there as a gist too :)
I have some ideas for re-structuring the Dockerfile so it would work for you (with the issues you mentioned about OSX and the USER directives).

@simison
Copy link
Member

simison commented Mar 17, 2016

Cool, just ping me once you've done any changes and I'll give it a go. I don't know if I'll have time to test it before Mon—Wed again tho, weekend ahead...

@lirantal
Copy link
Member Author

Sure, no problems.

On Fri, Mar 18, 2016 at 12:04 AM, Mikael Korpela notifications@github.com
wrote:

Cool, just ping me once you've done any changes and I'll give it a go. I
don't know if I'll have time to test it before Mon—Wed again tho, weekend
ahead...


You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub
#1249 (comment)

Sincerely, Liran Tal

Author
http://www.amazon.com/Agile-Software-Development-HP-Manager/dp/1484210352/of
Agile Software Development with HP Agile Manager
Founder and Lead Developer of daloRADIUS http://www.daloradius.com/
Blogging at http://www.enginx.com, and tweeting at @liran_tal
https://twitter.com/liran_tal

@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.615% when pulling 55c5f55 on lirantal:feature/docker_update_dev_environment into b0e6b4e on meanjs:master.

@ilanbiala
Copy link
Member

@lirantal are the changes just like @simison suggested? Why did you end up doing it that way?

@lirantal
Copy link
Member Author

That's right @ilanbiala this is now up to date.

@lirantal
Copy link
Member Author

I pushed the Dockerfile and docker-compost.yml to my own repository copy at lirantal/meanjs and it builds just fine: https://hub.docker.com/r/lirantal/meanjs/builds/bfwgz8t4fhaza3ou2gvsexi/

Of course I also use it locally.

@ilanbiala
Copy link
Member

@simison can you take another look to just make sure it works for you now?

@lirantal
Copy link
Member Author

yeah @simison what he said!

@simison
Copy link
Member

simison commented Mar 20, 2016

Did a fresh pull + docker-compose up — still EACCES error + some eslint warnings:

web_1 | Running "eslint:target" (eslint) task
web_1 | 
---edit: snipped a bunch of ES warnings out---
web_1 | 
web_1 | ✖ 40 problems (0 errors, 40 warnings)
web_1 | 
web_1 | 
web_1 | Running "csslint:all" (csslint) task
web_1 | >> 3 files lint free.
web_1 | 
web_1 | Running "mkdir:upload" task
web_1 | Warning: Unable to create directory "/opt/mean.js/modules/users/client/img/profile/uploads" (Error code: EACCES). Use --force to continue.
web_1 | 
web_1 | Aborted due to warnings.

Also:

web_1 | npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.2125781061'
web_1 | npm ERR!     at Error (native)
web_1 | npm ERR!  { [Error: EACCES: permission denied, open 'npm-debug.log.2125781061']
web_1 | npm ERR!   errno: -13,
web_1 | npm ERR!   code: 'EACCES',
web_1 | npm ERR!   syscall: 'open',
web_1 | npm ERR!   path: 'npm-debug.log.2125781061' }
web_1 | npm ERR! 
web_1 | npm ERR! Please try running this command again as root/Administrator.
web_1 | 
web_1 | npm ERR! Please include the following file with any support request:
web_1 | npm ERR!     /opt/mean.js/npm-debug.log

@lirantal
Copy link
Member Author

@simison eslint warnings are natural and happen today with naively grunt as well.
Can you confirm that if you remove the last and only single USER node directive then everything works well?

@simison
Copy link
Member

simison commented Mar 20, 2016

So I commented out these:

RUN groupadd...
...
RUN chown...
...
USER node

Did

docker-compose rm web
docker-compose build --no-cache web
docker-compose up

And all works now! I can get it running and open it in the browser.

@lirantal
Copy link
Member Author

Ok so yeah it's related to the node user for some reason.

I guess we can live with it until we can find a cross-platform solution, which is the whole thing that containers are about so I don't get how it's working here locally but not for you.

@simison
Copy link
Member

simison commented Mar 20, 2016

Are you using Virtualbox driver or something else for your Docker machine?

@simison
Copy link
Member

simison commented Mar 20, 2016

I wouldn't leave those bits there since it's just for development anyway. Would be cool if someone else with OSX would also test it and replicate my issue.

Here's lots more info about this: boot2docker/boot2docker#581

Anyway the system shouldn't be writing anything to the disk once it's running in production, and the installation phase can be done as root, then chown'ed to running user.

Currently on meanjs user avatar are saved to some subfolder inside the app. It should really be somewhere else or in the cloud. Anyway, this is out of scope of this PR.

@lirantal
Copy link
Member Author

Yeah I'm using VirtualBox but I think because Windows is mounting the directory and with OSX doing the same but OSX is more linux-like then you're having permissions issues with OSX.

… date versions of a MEAN.JS development environment setup

* updating mongodb to use a pinned version

* updating for quiet instalations
@lirantal lirantal force-pushed the feature/docker_update_dev_environment branch from 55c5f55 to abd7307 Compare March 20, 2016 14:12
@lirantal
Copy link
Member Author

@simison can you pull this latest update and confirm it's working ok?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.615% when pulling abd7307 on lirantal:feature/docker_update_dev_environment into 89d302d on meanjs:master.

@simison
Copy link
Member

simison commented Mar 21, 2016

@lirantal Yep, tested, builds and runs ok!

@ilanbiala
Copy link
Member

@lirantal LGTM.

@lirantal
Copy link
Member Author

I definitely think we can improve and I'll also now hook our Dockerfile to automated builds in docker hub

lirantal added a commit that referenced this pull request Mar 21, 2016
…ronment

fix(docker): updating the Dockerfile and docker-compose.yml
@lirantal lirantal merged commit 59e6daa into meanjs:master Mar 21, 2016
@@ -1,32 +1,65 @@
FROM node:0.12
# Build:
# docker build -t lirantal/meanjs .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have it linked to lirantal instead of meanjs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, you're right.
I initially created a user repository on docker hub for myself but since then I already created meanjs organization repository: https://hub.docker.com/r/meanjs/mean/

I anyway want to enhance some other things so I'll do it in another PR

@codydaig
Copy link
Member

Works for me on Mac OSX. Left one comment about having the build tied to lirantal instead of meanjs.

@codydaig
Copy link
Member

Just realized this got merged while I was testing. Sorry for the late comment

@gsanant
Copy link

gsanant commented Jul 10, 2019

hello, Just tried docker-compose build on updated dockerfile and docker-compose.yml but it still fails but with different error.

`ERROR: Error installing sass:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/ffi-1.11.1/ext/ffi_c
/usr/bin/ruby2.5 -r ./siteconf20190710-6-19r9lj0.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/ffi-1.11.1 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/ffi-1.11.1/gem_make.out`

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

Successfully merging this pull request may close these issues.

docker build error
6 participants