Skip to content

Instantly share code, notes, and snippets.

View ajcastro's full-sized avatar

Arjon Jason Castro ajcastro

View GitHub Profile
# Source: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/linux-repository.md
curl -sSL https://get.docker.com/ | sh
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash
sudo apt-get install gitlab-ci-multi-runner
# Enter values manually:
sudo gitlab-ci-multi-runner register
FROM ubuntu
RUN apt-get update -qq
RUN apt-get install -y build-essential nodejs npm nodejs-legacy git
RUN mkdir /app
WORKDIR /app
# Install dependency of phantomjs-prebuilt
RUN apt-get install -y libfontconfig

This tutorial requires you, the reader, to have a knowledge of docker and creating Dockerfile, and of course installed docker in your machine.

Use Dockerfile I created, https://gist.github.com/ajcastro/b990369b8d669ebb4070423f83e6e78f.

Then build:

docker build -t ajcastro/angular-dock .

Then create a container for each of your angular-project, for example a calculator angular app:

http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api
http://dev.enchant.com/api/v1
https://www.toptal.com/web/cookie-free-authentication-with-json-web-tokens-an-example-in-laravel-and-angularjs
https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps
https://scotch.io/tutorials/the-anatomy-of-a-json-web-token
https://scotch.io/tutorials/the-ins-and-outs-of-token-based-authentication
http://blog.ninja-squad.com/2015/05/28/angularjs-promises/
http://blog.ninja-squad.com/2015/06/04/angularjs-promises-2/

Solving the root User Issue

Running containers use root as the logged in user. This is fine, but in times like you run method like npm init and bower init, this will be cumbersome. This commands generate json configuration files for development. And when you try to edit this files in your host machine, you will notice that you may have Permission denied errors and you should run first chown command to give you permission on these created files.

Fortunately, we have a solution for this, by creating our own user inside the docker container.

In this example, let's say we created a container for our calculator angular app by using this command: