Menu

Little helpers for your docker based web development

2 min read October 18, 2017 at 9:52am on alias, caddy, caddyserver, docker, docker-compose, helper, laravel, node, nodejs, npm and php

For my local dev environment i tend to use docker. More specific, i have some docker-compose files, that allow me to have client specific software stacks up and running locally within seconds.

One of those stacks is a LAMP based Laravel (PHP Framework), wich i use in conjunction with one memcache container, one mariadb (drop in mysql replacement) container. The main container is a custom, build-from-source Caddy+PHP  (you do know caddyserver, the fast webserver with built in lets encrypt, written in go, do you?).

But i really don´t like installing nodejs / npm inside my containers, just for the occasional webpack build. Also, alpine linux stable doesn´t come with the latest npm packages.

Thats why i created 2 aliases in my shell environment, that just run the required npm tasks inside of a fire and forget nodejs container.

Here are the lines:

alias npmwatch='docker run -it --rm -v `pwd`:/srv node:alpine sh -c "cd /srv && npm run watch"'
alias npmprod='docker run -it --rm -v `pwd`:/srv node:alpine sh -c "cd /srv && chmod -R 0700 . && npm run prod; chmod -R 0777 ."'

The reason for those chmod´s in the npm run prod is, that it would fail for having wrong permissions, if it would be world read-/writable.

Which is totally correct!

But since it is just my local development machine, i tend to have it all 0777.

 

tbc.