Node image with angular-cli, ionic and cordova to develop cross platform applications with Angular2+
1.5K
Minimal node:8-alpine based image with npm, git, bash, openssl, @angular/[email protected], [email protected] and [email protected].
Segmentation error with ionic serve and sass is fixed with the help of https://github.com/jubel-han/dockerfiles/blob/master/node/Dockerfile
Docker installation:
Usage to create an angular-cli project in a folder at /PATH/TO/YOUR/HOSTDIRECTORY
docker run --rm --name ngx-development -p 4200:4200 -v /PATH/TO/YOUR/HOSTDIRECTORY:/opt/workdir -dit selfbits/angular-cli /bin/bash
docker exec -it ngx-development /bin/bash
cd /opt/workdir
ng new myproject
cd myproject
ng serve --host=0.0.0.0
### Pull and run the angular-cli image in a container named "ngx-development". Param explanation:
### --rm Deletes the container after it is exited
### -p X:Y Forwards the host port X to the docker container port Y. You can use -p 4201:4200 to see your live project at localhost:4201 even if you start the ng serve in the docker container at port 4200.
### Default development port for angular-cli projects is 4200. Default port for ionic is 8100.
### -dit d starts the container in detached mode which prevents that it exits automatically. it is used to execute a command ( "/bin/bash") interactively
### -v Share a volume between host and docker container. For windows you can use "-v /c/Users/myuser/Desktop/myproject:/opt/workdir". This will mount the folder myprojet of the host in the docker container at /opt/workdir
Usage to create an ionic-cli project in a folder at /PATH/TO/YOUR/HOSTDIRECTORY
### Pull and run the selfbits/angular-cli image in a container named "ionic-development" with standard port and live reload ports
docker run --rm --name ionic-development -p 8100:8100 -p 35729:35729 -p 53703:53703 -v /PATH/TO/YOUR/HOSTDIRECTORY:/opt/workdir -dit selfbits/angular-cli /bin/bash
docker exec -it ionic-development /bin/bash
cd /opt/workdir
ionic start
# Follow cli commands
cd $PROJECTNAME
ionic serve
Open browser on host machine and go to localhost:8100
Dockerfile:
FROM node:8-alpine
MAINTAINER Klaus Welle <[email protected]>
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh nano
RUN npm install npm@latest && \
rm -rf /usr/local/lib/node_modules/npm && \
mv node_modules/npm /usr/local/lib/node_modules/npm
RUN apk add --no-cache python3 && \
python3 -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip3 install --upgrade pip setuptools && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
rm -r /root/.cache
RUN pip3 install awscli && aws --version
RUN npm cache verify
RUN npm i -g semver @ionic/cli-utils tslib chalk os-name glob inherits once rimraf @ionic/discover
RUN npm rebuild node-sass
RUN npm i -g cordova
RUN npm i -g ionic@latest && ionic --no-interactive config set -g daemon.updates false
RUN npm rebuild node-sass
RUN npm i -g @angular/[email protected]
RUN npm rebuild node-sass && npm cache verify
RUN apk add --no-cache curl
RUN npm i -g glob inherits once rimraf @ionic/discover
# Add patch fix for segmentation error when running ionic serve
COPY stack-fix.c /lib/
# Prepare the libraries packages
RUN set -ex \
&& apk add --no-cache --virtual .build-deps build-base \
&& gcc -shared -fPIC /lib/stack-fix.c -o /lib/stack-fix.so \
&& apk del .build-deps
# export the environment variable of LD_PRELOAD
ENV LD_PRELOAD /lib/stack-fix.so
# JAVA OPEN JDK Installation
# Default to UTF-8 file.encoding
ENV LANG C.UTF-8
# add a simple script that can auto-detect the appropriate JAVA_HOME value
# based on whether the JDK or only the JRE is installed
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
ENV JAVA_VERSION 8u131
ENV JAVA_ALPINE_VERSION 8.131.11-r2
RUN set -x \
&& apk add --no-cache \
openjdk8="$JAVA_ALPINE_VERSION" \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]
# Install ruby gem and cocoapods
RUN apk update && apk upgrade && apk --update add \
ruby ruby-irb ruby-rake ruby-io-console ruby-bigdecimal ruby-json ruby-bundler \
libstdc++ tzdata bash ca-certificates \
&& echo 'gem: --no-document' > /etc/gemrc \
&& gem install cocoapods --user-install \
&& gem which cocoapods \
&& sed -e '/help/s/^/#/g' -i /root/.gem/ruby/2.4.0/gems/cocoapods-1.3.1/lib/cocoapods/command.rb
ENV GEM_HOME /root/.gem
ENV PATH /root/.gem/ruby/2.4.0/bin:$PATH
RUN \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk --no-cache update \
&& apk --no-cache upgrade \
&& apk add --no-cache --virtual .build-deps \
gifsicle pngquant optipng libjpeg-turbo-utils \
udev ttf-opensans chromium \
&& rm -rf /var/cache/apk/* /tmp/*
ENV CHROME_BIN /usr/bin/chromium-browser
ENV LIGHTHOUSE_CHROMIUM_PATH /usr/bin/chromium-browser
stack-fix.c
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
// THIS IS TO AVOID A SIGFAULT WHEN RUNNING python3.6 manage.py runserver
// This should be fixed at some point by Alpine and/or Python
// Check this issue for more info
// https://github.com/docker-library/python/issues/211
typedef int (*func_t)(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg);
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) {
pthread_attr_t local;
int used = 0, ret;
if (!attr) {
used = 1;
pthread_attr_init(&local);
attr = &local;
}
pthread_attr_setstacksize((void*)attr, 2 * 1024 * 1024); // 2 MB
func_t orig = (func_t)dlsym(RTLD_NEXT, "pthread_create");
ret = orig(thread, attr, start_routine, arg);
if (used) {
pthread_attr_destroy(&local);
}
return ret;
}
Content type
Image
Digest
Size
414.8 MB
Last updated
almost 9 years ago
docker pull selfbits/angular-cli