A nodeJS image embedding common related tools
2.6K
A nodeJS image, based on Tribalnova Linux Alpine image, with common related tools and a project builder script. dev variants (see tags) include common development tools and features.
dev tags are available and provide common nodeJS development packages (global installation), as well as the parent's image development tools.
Development Linux packages:
Development ndoeJS packages:
This image expect project files to be available in the directory /srv. The default command is npm start. Therefore, this image is designed to run a project embedding a package.json file, that includes a start script section, for instance:
"scripts": {
"start": "forever --minUptime 1000 --spinSleepTime 1000 lib/index.js",
}
docker build Dockerfile
docker run --rm tribalnova/nodejs <command>
docker exec -ti <container_name> sh
Containers from the dev image tags allow to run a bash or even a zsh shell (recommended). Just replace sh by the desired shell.
To run a container embedding a local project:
docker run --name <my_project> -v .:/srv -p 80:80 -p 5858:5859 tribalnova/nodejs-dev
- port 80 serves HTTP content
- port 5859 can be mapped to attach a debugger
Optionaly, other volumes can be mounted to ease development:
version: "2"
services:
csl:
image: tribalnova/nodejs-dev
ports:
- "80:80"
- "5858:5859"
links:
- memcached
- dynamodb
volumes:
- .:/srv
- ~/.ssh/id_rsa:/home/node/.ssh/id_rsa:ro
- ~/.gitconfig:/home/node/.gitconfig:ro
- ~/.npmrc:/home/node/.npmrc:ro
The container entrypoint runs the script startup.sh, that attach the debugger, run the container command, and reads optional environment variables to:
TIMEZONE can be used to define a different timezoneBUILD if not null, the project will be fetched and built from a Git bucket, according to these environment variables:
GIT_BUCKET the git project bucket.GIT_BRANCH (optional) master by default. Can specify another git branch.BUILD (optional) if the value is dev, the project will be versioned and embed NPM dev packages.docker run -ti -v ~/.ssh/id_rsa:/home/node/.ssh/id_rsa -v ~/.npmrc:/home/node/.npmrc -e TIMEZONE='America/Montreal' -e BUILD=1 -e [email protected]:tribalnova/myproject.git GIT_BRANCH=test tribalnova/nodejs
The image includes the executable /opt/docker/startup-timezone.sh, which can be used at runtime to set the container timezone. The timezone must correspond to the Linux tzdata timezone names, for instance America/Montreal.
The image includes the executable /opt/docker/build.sh, which can be used at runtime to fetch the project from Git sources. May need an id-rsa key to be shared for the bucket to be accessible.
After fetching the source, a npm install command is run. If the developer option is set, the resulting project will be versioned, and the NPM development packages will be deployed. Otherwise, the project will be a production version.
/opt/docker/build.sh [-dh] <git bucket> [<git branch>]
Content type
Image
Digest
Size
98 MB
Last updated
almost 9 years ago
docker pull tribalnova/nodejs