Angular client, known as "angular-cli" and providing "ng" command
9.8K
Angular client, known as angular-cli and providing "ng" command to prepare, develop and serve Angular application.
This image creates easy to use development environment with auto compilation and live reload provided by "ng" command. Check environment variables you can provide to adapt the Angular project initialisation, as stylesheet engine, application name, and so on...
Also, take a look at the bottom of this page to create and use this image in good conditions, with or without docker-compose.
Important Angular is not AngularJS !
This image is based on "node:10-alpine" image to limitate size and reduce dependencies.
You can use that tags to get corresponding Angular version.
/app, you may mount your application path (empty or not) on that directory as volume.The container will check if package.json is present, if it's found so npm install is called, either a project is created.
Important
You will want to use that image to "develop", so you'll need to have write access on your working directory. That image can work with forced uid:gid, so follow below explanation to set "uid" and "gid".
You only need to pass "--user $(id -u):$(id -g)" option at startup. We are using Fixuid project to make it possible to use local IDs inside container.
When container is started, correct rights are applied on certain directories inside the container. Then, the "ng" server is launched. To mount your local environment, please read the documentation til the end.
You may change some options to set up application name, change stylesheet engine to less or scss, activate the routing... That options should be passed with -e option => docker run -e OPTION_NAME=.... You can also set them up inside your docker-compose.yml file in environment section or with an environment file.
APPNAME is the name of the generated application, default is "hero", it's only used at generation time.GENERATE is default to "true", if other value is specified so the container will not generate project in case of package.json is not found. It is useful when you want to generate application yourself providing others options with "ng" command inside the container.ANGULAR_STYLESHEET_FORMAT: used at install time, one of the supported stylesheet format css, scss, less, lass... (default: css)ANGULAR_HOST_CHECK: true or false, default is "true"ANGULAR_ROUTING: used at install time to activate routing or not, default "true"Warning application name, stylesheet engine, and several others options cannot be changed after the application generation. Changing that options after application create will not take effect.
This docker image is intended to allow you to mount a local development directory inside the container. Auto compilation and live reload are activated.
You only need to mount the directory on /app directory.
Your local working directory MUST exists BEFORE to mount, if you don't do that, the local directory will be create by docker with "root" owner and the container will fail to install environment.
You can change the volume destination but you will also need to change "working directory" option. The recommendation is to leave the default one: /app
mkdir -p /path/to/my/app
docker run --rm -it -v /path/to/my/app:/app metal3d/ng
On SELinux activated Linux environment as Fedora, CentOS... You'll need either to use :Z flag on volume, or to label your working directory before to mount it.
Recommended: Use :Z as volume option:
$ mkdir myapp
$ docker run --rm -it -v $PWD/myapp:/app:Z metal3d/ng
Or, to label your workind directory, on you local host:
$ mkdir myapp
$ chcon -Rt svirt_sandbox_file_t ./myapp
Prepare an application:
$ mkdir myapp
# generate application named "superhero"
# use "user" option to keep your own uid:gid and be able
# to write in directory.
$ docker run --rm -it \
--user $(id -u):$(id -g)
-e APPNAME=superhero \
-v $PWD/myapp:/app \
-p 4200:4200 \
metal3d/ng
Serve with binding port 4200:
$ docker run --rm -it \
--user $(id -u):$(id -g) \
-v $PWD/myapp:/app \
metal3d/ng \
-p 4200:4200
To generate a distribution release:
$ docker run --rm -it \
--user $(id -u):$(id -g) \
-v $PWD/myapp:/app \
metal3d/ng \
ng build --prod
version: "3"
services:
ngapp:
image: metal3d/ng:latest
# use your own
user: ${UID}:${GID}
environment:
APPNAME: my-super-app
ports:
- 4200:4200
volumes:
# be sure that ./myapp exists before to
# use docker-compose up, and use :Z flag
# on SELinux enabled distributions.
- ./myapp:/app:Z
You need UID and GID environment variable. UID should be already set but you can export your GID in your ~/.bashrc file:
# Do it only once
echo 'export GID=$(id -g)' >> ~/.bashrc
# Reload...
. ~/.bashrc
# launch
docker-compose up
Or directly use it in your shell:
export GID=$(id -g)
docker-compose up
I deactivated auto-build on Docker Hub because I need to use a Makefile that automates image creation without the need to replicate Dockerfile. So, at this time, I push images as soon as I can in the environment.
I'm preparing an automated system to create latest images without the need to recompile them on my local machine.
Content type
Image
Digest
Size
101.7 MB
Last updated
about 7 years ago
docker pull metal3d/ng