├── .angular-cli.tpl.json ├── .editorconfig ├── .env.example ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── Dockerfile ├── Dockerfile-dev ├── LICENSE ├── README.md ├── dist └── .gitkeep ├── docker-compose.prod.tpl.yml ├── docker-compose.tpl.yml ├── dockerignore ├── docs ├── README.md ├── dev-guide │ └── README.md └── user-guide │ ├── README.md │ └── getting-started.md ├── e2e ├── app.e2e-spec.ts ├── app.po.ts └── tsconfig.e2e.json ├── karma.conf.js ├── node_modules └── .gitkeep ├── package.tpl.json ├── protractor.conf.js ├── setup.sh ├── src ├── app │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ └── app.module.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── typings.d.ts └── tslint.json /.angular-cli.tpl.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "${PROJECT_NAME}" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "assets": [ 11 | "assets", 12 | "favicon.ico" 13 | ], 14 | "index": "index.html", 15 | "main": "main.ts", 16 | "polyfills": "polyfills.ts", 17 | "test": "test.ts", 18 | "tsconfig": "tsconfig.app.json", 19 | "testTsconfig": "tsconfig.spec.json", 20 | "prefix": "app", 21 | "styles": [ 22 | "styles.scss" 23 | ], 24 | "scripts": [], 25 | "environmentSource": "environments/environment.ts", 26 | "environments": { 27 | "dev": "environments/environment.ts", 28 | "prod": "environments/environment.prod.ts" 29 | } 30 | } 31 | ], 32 | "e2e": { 33 | "protractor": { 34 | "config": "./protractor.conf.js" 35 | } 36 | }, 37 | "lint": [ 38 | { 39 | "project": "src/tsconfig.app.json" 40 | }, 41 | { 42 | "project": "src/tsconfig.spec.json" 43 | }, 44 | { 45 | "project": "e2e/tsconfig.e2e.json" 46 | } 47 | ], 48 | "test": { 49 | "karma": { 50 | "config": "./karma.conf.js" 51 | } 52 | }, 53 | "defaults": { 54 | "styleExt": "scss", 55 | "component": {} 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # export environment variables to be used for the project-specific stuff 2 | # how to use: $ export $(cat .env | grep -v ^# | xargs) 3 | 4 | # for package.json 5 | PROJECT_NAME=angular-boilerplate 6 | PROJECT_VERSION=0.2.0 7 | 8 | # for docker-compose.yml and docker-compose.prod.yml 9 | DOCKER_IMAGE_DEV=teracy/angular-boilerplate:dev_develop 10 | DOCKER_IMAGE_PROD=teracy/angular-boilerplate:develop 11 | 12 | # for nginx-proxy to use domains instead of ports 13 | # see: https://github.com/teracyhq/angular-boilerplate/issues/31 14 | DOMAIN_DEV=dev.ab.teracy.dev 15 | DOMAIN_PROD=ab.teracy.dev 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist/* 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules/* 9 | 10 | # IDEs and editors 11 | /.idea 12 | .project 13 | .classpath 14 | .c9/ 15 | *.launch 16 | .settings/ 17 | 18 | # IDE - VSCode 19 | .vscode/* 20 | !.vscode/settings.json 21 | !.vscode/tasks.json 22 | !.vscode/launch.json 23 | !.vscode/extensions.json 24 | 25 | # misc 26 | /.sass-cache 27 | /connect.lock 28 | /coverage/* 29 | /libpeerconnection.log 30 | npm-debug.log 31 | testem.log 32 | /typings 33 | 34 | # e2e 35 | /e2e/*.js 36 | /e2e/*.map 37 | 38 | #System Files 39 | .DS_Store 40 | Thumbs.db 41 | .env 42 | # for teracy-dev file mapping 43 | !dist/.gitkeep 44 | !node_modules/.gitkeep 45 | 46 | # angular-boilerplate 47 | .angular-cli.json 48 | package.json 49 | docker-compose.yml 50 | docker-compose.prod.yml 51 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - docker 3 | env: 4 | global: 5 | CI_BUILD_TIME: $(date -u +"%Y-%m-%dT%H:%M:%SZ") 6 | CI_REGISTRY_IMAGE: $DOCKER_IMAGE 7 | DOCKER_COMPOSE_VERSION: 1.11.2 8 | before_install: 9 | # install the latest docker and docker-compose versions 10 | - sudo apt-get remove docker docker-engine 11 | - sudo curl -sSL https://get.docker.com/ | sh 12 | - sudo rm /usr/local/bin/docker-compose 13 | - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose 14 | - chmod +x docker-compose 15 | - sudo mv docker-compose /usr/local/bin 16 | - docker --version 17 | - docker-compose --version 18 | before_script: 19 | - cp .env.example .env 20 | - export $(cat .env | grep -v ^# | xargs) 21 | - export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH | sed -e 's/[\/]/-/g' | sed -e 's/[\#]//g'; fi` 22 | - export DOCKER_IMAGE_DEV=$CI_REGISTRY_IMAGE:dev_$TAG 23 | - export DOCKER_IMAGE_PROD=$CI_REGISTRY_IMAGE:$TAG 24 | - export CI_BUILD_ID=$TRAVIS_BUILD_ID 25 | - export CI_BUILD_REF=$TRAVIS_COMMIT 26 | - export CI_BUILD_REF_NAME=$TRAVIS_BRANCH 27 | - export CI_PROJECT_NAME=$TRAVIS_REPO_SLUG 28 | - chmod +x setup.sh 29 | - ./setup.sh 30 | script: 31 | - docker-compose build --pull 32 | # run and check the dev container 33 | - docker-compose run --rm dev npm run lint 34 | - docker-compose run --rm dev ng test --browsers Chrome_no_sandbox -w false 35 | - docker-compose run --rm dev npm run e2e 36 | # build, run and check the prod image 37 | - sudo rm -rf .com.google.Chrome* 38 | - docker-compose run --rm dev ng build --prod 39 | - docker-compose -f docker-compose.prod.yml build --pull 40 | after_success: 41 | - docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD 42 | - docker push $DOCKER_IMAGE_DEV 43 | - docker push $DOCKER_IMAGE_PROD 44 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | 4 | ## [v0.2.0][] (2017-03-20) 5 | 6 | The next milestone that upgrades to use teracy/angular-cli:1.0.0-rc.2 7 | 8 | - Improvements: 9 | + upgrade to use teracy/angular-cli:1.0.0-rc.2 Docker image 10 | + refactor code, update for use with teracy-dev's best practices 11 | 12 | 13 | ## [v0.1.0][] (2017-02-13) 14 | 15 | The first milestone that uses angular-cli with Docker workflow support and automated tests support. 16 | 17 | - Features: 18 | + use @angular/cli 1.0.0-beta.30 from teracy/angular-cli:1.0.0-beta.30 19 | + use dynamic file generation to create new projects 20 | + Docker dev and prod modes 21 | + travis-ci support 22 | 23 | - Improvements: 24 | + use docker-compose build instead of docker for the CI system 25 | 26 | - Bug Fixes: 27 | + e2e tests should work 28 | 29 | - Tasks: 30 | + update docs for usage instruction 31 | 32 | 33 | [v0.1.0]: https://github.com/teracyhq/angular-boilerplate/milestone/1?closed=1 34 | [v0.2.0]: https://github.com/teracyhq/angular-boilerplate/milestone/2?closed=1 -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.11-alpine 2 | 3 | LABEL authors="hoatle " 4 | 5 | # add more arguments from CI to the image so that `$ env` should reveal more info 6 | ARG CI_BUILD_ID 7 | ARG CI_BUILD_REF 8 | ARG CI_REGISTRY_IMAGE 9 | ARG CI_PROJECT_NAME 10 | ARG CI_BUILD_REF_NAME 11 | ARG CI_BUILD_TIME 12 | 13 | ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \ 14 | CI_PROJECT_NAME=$CI_PROJECT_NAME CI_BUILD_REF_NAME=$CI_BUILD_REF_NAME CI_BUILD_TIME=$CI_BUILD_TIME 15 | 16 | COPY dist /usr/share/nginx/html 17 | -------------------------------------------------------------------------------- /Dockerfile-dev: -------------------------------------------------------------------------------- 1 | FROM teracy/angular-cli:1.0.0-rc.2 2 | 3 | LABEL authors="hoatle " 4 | 5 | RUN mkdir -p /opt/app 6 | 7 | ENV TERM=xterm APP=/opt/app 8 | 9 | # add more arguments from CI to the image so that `$ env` should reveal more info 10 | ARG CI_BUILD_ID 11 | ARG CI_BUILD_REF 12 | ARG CI_REGISTRY_IMAGE 13 | ARG CI_PROJECT_NAME 14 | ARG CI_BUILD_REF_NAME 15 | ARG CI_BUILD_TIME 16 | 17 | ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \ 18 | CI_PROJECT_NAME=$CI_PROJECT_NAME CI_BUILD_REF_NAME=$CI_BUILD_REF_NAME CI_BUILD_TIME=$CI_BUILD_TIME \ 19 | npm_config_tmp=/tmp 20 | 21 | ADD package.json $APP/ 22 | 23 | WORKDIR $APP 24 | 25 | RUN yarn 26 | 27 | VOLUME $APP/node_modules 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Teracy Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # angular-boilerplate [![Build Status](https://travis-ci.org/teracyhq/angular-boilerplate.svg?branch=develop)](https://travis-ci.org/teracyhq/angular-boilerplate) 2 | 3 | This project was generated with 4 | [teracy/angular-cli:1.0.0-rc.2](https://hub.docker.com/r/teracy/angular-cli/) Docker image. 5 | 6 | This project was created from [angular-boilerplate](https://github.com/teracyhq/angular-boilerplate) 7 | version 0.2.0. 8 | 9 | ## New project setup 10 | 11 | - You need `docker` and `docker-compose` available, so please set up 12 | [teracy-dev](http://dev.teracy.org/docs/getting_started.html) as the following described 13 | steps works with `teracy-dev`. Note that the 1st terminal window after `$ vagrant up` should be 14 | kept running for file watching. 15 | 16 | - Open the 2nd terminal window, git remote add `angular-boilerplate` repo as `seed` and pull the 17 | stable branch (master) or development branch (develop) into your project. 18 | 19 | ``` 20 | $ cd ~/teracy-dev/workspace 21 | $ mkdir 22 | $ cd 23 | $ git init 24 | $ git remote add seed https://github.com/teracyhq/angular-boilerplate.git 25 | $ git pull seed master # or develop branch if you want to have the latest development features 26 | $ cp .env.example .env # and adjust the variables matching your project details 27 | ``` 28 | 29 | For example, if your project name is `angular-hello-world`, your Docker hub account `hoatle`: 30 | 31 | ``` 32 | # export environment variables to be used for the project-specific stuff 33 | # how to use: $ export $(cat .env | grep -v ^# | xargs) 34 | 35 | # for package.json 36 | PROJECT_NAME=angular-hello-world 37 | PROJECT_VERSION=0.1.0-SNAPSHOT 38 | 39 | # for docker-compose.yml and docker-compose.prod.yml 40 | DEV_DOCKER_IMAGE=hoatle/angular-hello-world:dev_develop 41 | PROD_DOCKER_IMAGE=hoatle/angular-hello-world:develop 42 | ``` 43 | 44 | These variables are used to generate project specific files, you can adjust them accordingly. 45 | 46 | 47 | After that, open the 3rd terminal window, `ssh` into the `teracy-dev` VM: 48 | 49 | ``` 50 | $ cd ~/teracy-dev 51 | $ vagrant ssh 52 | $ ws 53 | $ cd 54 | $ export $(cat .env | grep -v ^# | xargs) # to export enviroment variables defined on the .env file 55 | $ ./setup.sh # to generate .angular-cli.json, package.json, docker-compose.yml and docker-compose.prod.yml files 56 | ``` 57 | 58 | Execute the following command to 59 | [sync back](http://dev.teracy.org/docs/develop/basic_usage.html#file-sync) the generated files on 60 | the 2nd terminal window: 61 | 62 | ``` 63 | $ vagrant rsync-back 64 | ``` 65 | 66 | After that, you should see `package.json`, `docker-compose.yml` and `docker-compose.prod.yml` files 67 | available. 68 | 69 | Remove these lines from `.gitignore` to keep these files on your project: 70 | 71 | ``` 72 | # angular-boilerplate 73 | .env 74 | .angular-cli.json 75 | package.json 76 | docker-compose.yml 77 | docker-compose.prod.yml 78 | ``` 79 | 80 | ## Development server 81 | 82 | Execute the following commands on the 3rd `ssh-ed` terminal window: 83 | 84 | ``` 85 | $ docker-compose build && docker-compose up -d && docker-compose logs -f 86 | ``` 87 | 88 | Note that `$ docker-compose pull` should be used instead of `$ docker-compose build` when the 89 | `DEV_DOCKER_IMAGE` is available. Your CI system should be used to push these development and production 90 | Docker images. (See .travis.yml for reference) 91 | 92 | You should see the similar following output: 93 | 94 | ``` 95 | Creating angular-boilerplate-dev 96 | Attaching to angular-boilerplate-dev 97 | angular-boilerplate-dev | Starting virtual X frame buffer: Xvfb. 98 | angular-boilerplate-dev | Executing command bash -c yarn run start 99 | angular-boilerplate-dev | yarn run v0.21.3 100 | angular-boilerplate-dev | $ ng serve --host=0.0.0.0 101 | angular-boilerplate-dev | ** NG Live Development Server is running on http://0.0.0.0:4200 ** 102 | angular-boilerplate-dev Hash: d8df844d0c9cdfe14f5e s 103 | angular-boilerplate-dev | Time: 14272ms 104 | angular-boilerplate-dev | chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 157 kB {4} [initial] [rendered] 105 | angular-boilerplate-dev | chunk {1} main.bundle.js, main.bundle.js.map (main) 4.04 kB {3} [initial] [rendered] 106 | angular-boilerplate-dev | chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 9.89 kB {4} [initial] [rendered] 107 | angular-boilerplate-dev | chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.69 MB [initial] [rendered] 108 | angular-boilerplate-dev | chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered] 109 | angular-boilerplate-dev | webpack: Compiled successfully. 110 | ``` 111 | 112 | Open teracy.dev:4200 on your browser to start developing. The app will automatically reload 113 | when you change any of the source files. 114 | 115 | 116 | ## Code scaffolding 117 | 118 | Open the 4th terminal window and `ssh` into the `teracy-dev` VM: 119 | 120 | ``` 121 | $ cd ~/teracy-dev 122 | $ vagrant ssh 123 | $ ws 124 | $ cd 125 | $ docker-compose run --rm dev 126 | ``` 127 | 128 | could be `ng generate component component-name` to generate a new component. You can 129 | also use `ng generate directive/pipe/service/class/module`. 130 | 131 | Remember to sync back the generated files to the host machine with `$ vagrant rsync-back`: 132 | http://dev.teracy.org/docs/basic_usage.html#file-sync 133 | 134 | ## Run code linting 135 | 136 | Run `$ docker-compose run --rm dev yarn run lint` to execute the code lint checking. 137 | 138 | ## Run unit tests 139 | 140 | Run `$ docker-compose run --rm dev yarn run test` to execute the unit tests via [Karma](https://karma-runner.github.io). 141 | 142 | This will keep the tests running and watching the file changes. 143 | 144 | To run unit tests without file watching, run `$ docker-compose run --rm dev ng test --browsers Chrome_no_sandbox -w false` 145 | 146 | ## Run end-to-end tests 147 | 148 | Run `$ docker-compose run --rm dev yarn run e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 149 | 150 | ## Run the bash command on the running Dev Docker image 151 | 152 | Run `$ docker-compose exec dev /bin/bash` 153 | 154 | 155 | ## Build the Prod Docker image 156 | 157 | On the 4th terminal `ssh-ed` terminal window: 158 | 159 | ``` 160 | $ docker-compose exec dev ng build --prod 161 | $ docker-compose -f docker-compose.prod.yml build 162 | ``` 163 | 164 | to build the project and the prod Docker image. The build artifacts will be stored in the `dist/` 165 | directory. 166 | 167 | Don't forget to sync back the generated files from the VM to the host after the build if you want 168 | to check the `dist/` directory. 169 | 170 | ## Run the Prod Docker image 171 | 172 | ``` 173 | $ docker-compose -f docker-compose.prod.yml up 174 | ``` 175 | 176 | And open teracy.dev:8080 to see the app in production mode served by nginx. 177 | 178 | 179 | ## Contribute to angular-boilerplate project 180 | 181 | - Fork the repo 182 | 183 | - Enable this repo on travis-ci.org with the following settings key - value. 184 | In the *Name* and *Value* fields, please add the info below correlatively: 185 | + Fill in "DOCKER_IMAGE" into the *Name* field, and project Docker image for *Value*, for example, "hoatle/angular-boilerplate" value (will be pushed to https://hub.docker.com/r/hoatle/angular-boilerplate/) 186 | + Fill in "DOCKER_USERNAME" into the *Name* field and your Docker username into the *Value* field 187 | + Fill in "DOCKER_PASSWORD" into the *Name* field and your Docker password into the *Value* field 188 | 189 | - Test, Fix bug, Improve, Add new features on the project issues with pull requests. 190 | 191 | ## Further help 192 | 193 | To get more help on the `angular-cli` use `ng help` or go check out the 194 | [Angular-CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 195 | 196 | ## License 197 | 198 | MIT, see the LICENSE file. 199 | -------------------------------------------------------------------------------- /dist/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/dist/.gitkeep -------------------------------------------------------------------------------- /docker-compose.prod.tpl.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | 5 | prod: 6 | container_name: ${PROJECT_NAME}_prod 7 | build: 8 | context: . 9 | args: 10 | - CI_BUILD_ID=${CI_BUILD_ID} 11 | - CI_BUILD_REF=${CI_BUILD_REF} 12 | - CI_BUILD_REF_NAME=${CI_BUILD_REF_NAME} 13 | - CI_BUILD_TIME=${CI_BUILD_TIME} 14 | - CI_REGISTRY_IMAGE=${CI_REGISTRY_IMAGE} 15 | - CI_PROJECT_NAME=${CI_PROJECT_NAME} 16 | image: ${DOCKER_IMAGE_PROD:-${DOCKER_IMAGE_PROD}} 17 | environment: 18 | VIRTUAL_HOST: ${DOMAIN_PROD} 19 | HTTPS_METHOD: noredirect # support both http and https 20 | ports: 21 | - "80" 22 | restart: unless-stopped 23 | # to get this work with https://github.com/jwilder/nginx-proxy 24 | # related: https://github.com/jwilder/nginx-proxy/issues/305 25 | network_mode: bridge 26 | -------------------------------------------------------------------------------- /docker-compose.tpl.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | 5 | dev: 6 | container_name: ${PROJECT_NAME}_dev 7 | build: 8 | context: . 9 | dockerfile: Dockerfile-dev 10 | args: 11 | - CI_BUILD_ID=${CI_BUILD_ID} 12 | - CI_BUILD_REF=${CI_BUILD_REF} 13 | - CI_BUILD_REF_NAME=${CI_BUILD_REF_NAME} 14 | - CI_BUILD_TIME=${CI_BUILD_TIME} 15 | - CI_REGISTRY_IMAGE=${CI_REGISTRY_IMAGE} 16 | - CI_PROJECT_NAME=${CI_PROJECT_NAME} 17 | # we use image for faster developing with `npm install` already run 18 | image: ${DOCKER_IMAGE_DEV:-${DOCKER_IMAGE_DEV}} 19 | command: bash -c "yarn run start" 20 | environment: 21 | NODE_ENV: development 22 | VIRTUAL_HOST: ${DOMAIN_DEV} 23 | HTTPS_METHOD: noredirect # support both http and https 24 | volumes: 25 | - .:/opt/app 26 | ports: 27 | - "4200" 28 | restart: unless-stopped 29 | # to get this work with https://github.com/jwilder/nginx-proxy 30 | # related: https://github.com/jwilder/nginx-proxy/issues/305 31 | network_mode: bridge 32 | -------------------------------------------------------------------------------- /dockerignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/dockerignore -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/docs/README.md -------------------------------------------------------------------------------- /docs/dev-guide/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/docs/dev-guide/README.md -------------------------------------------------------------------------------- /docs/user-guide/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/docs/user-guide/README.md -------------------------------------------------------------------------------- /docs/user-guide/getting-started.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/docs/user-guide/getting-started.md -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AngularBoilerplatePage } from './app.po'; 2 | 3 | describe('angular-boilerplate App', () => { 4 | let page: AngularBoilerplatePage; 5 | 6 | beforeEach(() => { 7 | page = new AngularBoilerplatePage(); 8 | }); 9 | 10 | it('should display message saying app works', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('app works!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, element, by } from 'protractor'; 2 | 3 | export class AngularBoilerplatePage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "declaration": false, 5 | "moduleResolution": "node", 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "lib": [ 9 | "es2016" 10 | ], 11 | "outDir": "../out-tsc/e2e", 12 | "module": "commonjs", 13 | "target": "es5", 14 | "types":[ 15 | "jasmine", 16 | "node" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/0.13/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular/cli'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular/cli/plugins/karma') 14 | ], 15 | client:{ 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | files: [ 19 | { pattern: './src/test.ts', watched: false } 20 | ], 21 | preprocessors: { 22 | './src/test.ts': ['@angular/cli'] 23 | }, 24 | mime: { 25 | 'text/x-typescript': ['ts','tsx'] 26 | }, 27 | coverageIstanbulReporter: { 28 | reports: [ 'html', 'lcovonly' ], 29 | fixWebpackSourcePaths: true 30 | }, 31 | angularCli: { 32 | environment: 'dev' 33 | }, 34 | reporters: config.angularCli && config.angularCli.codeCoverage 35 | ? ['progress', 'coverage-istanbul'] 36 | : ['progress', 'kjhtml'], 37 | port: 9876, 38 | colors: true, 39 | logLevel: config.LOG_INFO, 40 | autoWatch: true, 41 | browsers: ['Chrome'], 42 | customLaunchers: { 43 | Chrome_no_sandbox: { 44 | base: 'Chrome', 45 | flags: ['--no-sandbox'] // for running within Docker 46 | } 47 | }, 48 | singleRun: false 49 | }); 50 | }; 51 | -------------------------------------------------------------------------------- /node_modules/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/node_modules/.gitkeep -------------------------------------------------------------------------------- /package.tpl.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "${PROJECT_NAME}", 3 | "version": "${PROJECT_VERSION}", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve --host=0.0.0.0 --liveReloadClient http://${DOMAIN_DEV}", 8 | "build": "ng build", 9 | "test": "ng test --browsers Chrome_no_sandbox", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/common": "^2.4.0", 16 | "@angular/compiler": "^2.4.0", 17 | "@angular/core": "^2.4.0", 18 | "@angular/forms": "^2.4.0", 19 | "@angular/http": "^2.4.0", 20 | "@angular/platform-browser": "^2.4.0", 21 | "@angular/platform-browser-dynamic": "^2.4.0", 22 | "@angular/router": "^3.4.0", 23 | "core-js": "^2.4.1", 24 | "rxjs": "^5.1.0", 25 | "zone.js": "^0.7.6" 26 | }, 27 | "devDependencies": { 28 | "@angular/cli": "1.0.0-rc.2", 29 | "@angular/compiler-cli": "^2.4.0", 30 | "@types/jasmine": "2.5.38", 31 | "@types/node": "~6.0.60", 32 | "codelyzer": "~2.0.0", 33 | "jasmine-core": "~2.5.2", 34 | "jasmine-spec-reporter": "~3.2.0", 35 | "karma": "~1.4.1", 36 | "karma-chrome-launcher": "~2.0.0", 37 | "karma-cli": "~1.0.1", 38 | "karma-jasmine": "~1.1.0", 39 | "karma-jasmine-html-reporter": "^0.2.2", 40 | "karma-coverage-istanbul-reporter": "^0.2.0", 41 | "protractor": "~5.1.0", 42 | "ts-node": "~2.0.0", 43 | "tslint": "~4.5.0", 44 | "typescript": "~2.0.0" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './e2e/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome', 13 | 'chromeOptions': { 14 | 'args': ['no-sandbox'] 15 | } 16 | }, 17 | directConnect: true, 18 | baseUrl: 'http://localhost:4200/', 19 | framework: 'jasmine', 20 | jasmineNodeOpts: { 21 | showColors: true, 22 | defaultTimeoutInterval: 30000, 23 | print: function() {} 24 | }, 25 | beforeLaunch: function() { 26 | require('ts-node').register({ 27 | project: 'e2e/tsconfig.e2e.json' 28 | }); 29 | }, 30 | onPrepare() { 31 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # generate angular-cli.json 4 | rm -rf .angular-cli.json 5 | envsubst '${PROJECT_NAME}' <.angular-cli.tpl.json >.angular-cli.json 6 | 7 | # generate package.json 8 | rm -rf package.json 9 | envsubst '${PROJECT_NAME} ${PROJECT_VERSION} ${DOMAIN_DEV}' package.json 10 | 11 | # generate docker-compose.yml 12 | rm -rf docker-compose.yml 13 | envsubst '${PROJECT_NAME} ${DOCKER_IMAGE_DEV} ${DOMAIN_DEV}' docker-compose.yml 14 | 15 | # generate docker-compose.prod.yml 16 | rm -rf docker-compose.prod.yml 17 | envsubst '${PROJECT_NAME} ${DOCKER_IMAGE_PROD} ${DOMAIN_PROD}' docker-compose.prod.yml 18 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |

2 | {{title}} 3 |

4 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/src/app/app.component.scss -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | declarations: [ 9 | AppComponent 10 | ], 11 | }).compileComponents(); 12 | })); 13 | 14 | it('should create the app', async(() => { 15 | const fixture = TestBed.createComponent(AppComponent); 16 | const app = fixture.debugElement.componentInstance; 17 | expect(app).toBeTruthy(); 18 | })); 19 | 20 | it(`should have as title 'app works!'`, async(() => { 21 | const fixture = TestBed.createComponent(AppComponent); 22 | const app = fixture.debugElement.componentInstance; 23 | expect(app.title).toEqual('app works!'); 24 | })); 25 | 26 | it('should render title in a h1 tag', async(() => { 27 | const fixture = TestBed.createComponent(AppComponent); 28 | fixture.detectChanges(); 29 | const compiled = fixture.debugElement.nativeElement; 30 | expect(compiled.querySelector('h1').textContent).toContain('app works!'); 31 | })); 32 | }); 33 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'app works!'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpModule } from '@angular/http'; 5 | 6 | import { AppComponent } from './app.component'; 7 | 8 | @NgModule({ 9 | declarations: [ 10 | AppComponent 11 | ], 12 | imports: [ 13 | BrowserModule, 14 | FormsModule, 15 | HttpModule 16 | ], 17 | providers: [], 18 | bootstrap: [AppComponent] 19 | }) 20 | export class AppModule { } 21 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teracyhq-incubator/angular-boilerplate/0bda5fd2546526b0a6fbae2e56078ffa907e973f/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularBoilerplate 6 | 7 | 8 | 9 | 10 | 11 | 12 | Loading... 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule); 12 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/set'; 35 | 36 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 37 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 38 | 39 | /** IE10 and IE11 requires the following to support `@angular/animation`. */ 40 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 41 | 42 | 43 | /** Evergreen browsers require these. **/ 44 | import 'core-js/es6/reflect'; 45 | import 'core-js/es7/reflect'; 46 | 47 | 48 | /** ALL Firefox browsers require the following to support `@angular/animation`. **/ 49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 50 | 51 | 52 | 53 | /*************************************************************************************************** 54 | * Zone JS is required by Angular itself. 55 | */ 56 | import 'zone.js/dist/zone'; // Included with Angular CLI. 57 | 58 | 59 | 60 | /*************************************************************************************************** 61 | * APPLICATION IMPORTS 62 | */ 63 | 64 | /** 65 | * Date, currency, decimal and percent pipes. 66 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 67 | */ 68 | // import 'intl'; // Run `npm install --save intl`. 69 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/long-stack-trace-zone'; 4 | import 'zone.js/dist/proxy.js'; 5 | import 'zone.js/dist/sync-test'; 6 | import 'zone.js/dist/jasmine-patch'; 7 | import 'zone.js/dist/async-test'; 8 | import 'zone.js/dist/fake-async-test'; 9 | import { getTestBed } from '@angular/core/testing'; 10 | import { 11 | BrowserDynamicTestingModule, 12 | platformBrowserDynamicTesting 13 | } from '@angular/platform-browser-dynamic/testing'; 14 | 15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. 16 | declare var __karma__: any; 17 | declare var require: any; 18 | 19 | // Prevent Karma from running prematurely. 20 | __karma__.loaded = function () {}; 21 | 22 | // First, initialize the Angular testing environment. 23 | getTestBed().initTestEnvironment( 24 | BrowserDynamicTestingModule, 25 | platformBrowserDynamicTesting() 26 | ); 27 | // Then we find all the tests. 28 | const context = require.context('./', true, /\.spec\.ts$/); 29 | // And load the modules. 30 | context.keys().map(context); 31 | // Finally, start Karma to run the tests. 32 | __karma__.start(); 33 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "declaration": false, 5 | "moduleResolution": "node", 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "target": "es5", 9 | "lib": [ 10 | "es2016", 11 | "dom" 12 | ], 13 | "outDir": "../out-tsc/app", 14 | "module": "es2015", 15 | "baseUrl": "", 16 | "types": [] 17 | }, 18 | "exclude": [ 19 | "test.ts", 20 | "**/*.spec.ts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "declaration": false, 5 | "moduleResolution": "node", 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "lib": [ 9 | "es2016" 10 | ], 11 | "outDir": "../out-tsc/spec", 12 | "module": "commonjs", 13 | "target": "es5", 14 | "baseUrl": "", 15 | "types": [ 16 | "jasmine", 17 | "node" 18 | ] 19 | }, 20 | "files": [ 21 | "test.ts" 22 | ], 23 | "include": [ 24 | "**/*.spec.ts" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: { 3 | id: string; 4 | }; 5 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "callable-types": true, 7 | "class-name": true, 8 | "comment-format": [ 9 | true, 10 | "check-space" 11 | ], 12 | "curly": true, 13 | "eofline": true, 14 | "forin": true, 15 | "import-blacklist": [true, "rxjs"], 16 | "import-spacing": true, 17 | "indent": [ 18 | true, 19 | "spaces" 20 | ], 21 | "interface-over-type-literal": true, 22 | "label-position": true, 23 | "max-line-length": [ 24 | true, 25 | 140 26 | ], 27 | "member-access": false, 28 | "member-ordering": [ 29 | true, 30 | "static-before-instance", 31 | "variables-before-functions" 32 | ], 33 | "no-arg": true, 34 | "no-bitwise": true, 35 | "no-console": [ 36 | true, 37 | "debug", 38 | "info", 39 | "time", 40 | "timeEnd", 41 | "trace" 42 | ], 43 | "no-construct": true, 44 | "no-debugger": true, 45 | "no-duplicate-variable": true, 46 | "no-empty": false, 47 | "no-empty-interface": true, 48 | "no-eval": true, 49 | "no-inferrable-types": [true, "ignore-params"], 50 | "no-shadowed-variable": true, 51 | "no-string-literal": false, 52 | "no-string-throw": true, 53 | "no-switch-case-fall-through": true, 54 | "no-trailing-whitespace": true, 55 | "no-unused-expression": true, 56 | "no-use-before-declare": true, 57 | "no-var-keyword": true, 58 | "object-literal-sort-keys": false, 59 | "one-line": [ 60 | true, 61 | "check-open-brace", 62 | "check-catch", 63 | "check-else", 64 | "check-whitespace" 65 | ], 66 | "prefer-const": true, 67 | "quotemark": [ 68 | true, 69 | "single" 70 | ], 71 | "radix": true, 72 | "semicolon": [ 73 | "always" 74 | ], 75 | "triple-equals": [ 76 | true, 77 | "allow-null-check" 78 | ], 79 | "typedef-whitespace": [ 80 | true, 81 | { 82 | "call-signature": "nospace", 83 | "index-signature": "nospace", 84 | "parameter": "nospace", 85 | "property-declaration": "nospace", 86 | "variable-declaration": "nospace" 87 | } 88 | ], 89 | "typeof-compare": true, 90 | "unified-signatures": true, 91 | "variable-name": false, 92 | "whitespace": [ 93 | true, 94 | "check-branch", 95 | "check-decl", 96 | "check-operator", 97 | "check-separator", 98 | "check-type" 99 | ], 100 | 101 | "directive-selector": [true, "attribute", "app", "camelCase"], 102 | "component-selector": [true, "element", "app", "kebab-case"], 103 | "use-input-property-decorator": true, 104 | "use-output-property-decorator": true, 105 | "use-host-property-decorator": true, 106 | "no-input-rename": true, 107 | "no-output-rename": true, 108 | "use-life-cycle-interface": true, 109 | "use-pipe-transform-interface": true, 110 | "component-class-suffix": true, 111 | "directive-class-suffix": true, 112 | "no-access-missing-member": true, 113 | "templates-use-public": true, 114 | "invoke-injectable": true 115 | } 116 | } 117 | --------------------------------------------------------------------------------