跳至主要内容

博文

目前显示的是 2017的博文

Docker multi-stage builds

Docker multi-stage builds Docker 17.06 introduced a new feature, Multi-stage builds, check the Docker blog entry multi stage builds or new multistage builds section in the docker official documentation for more details.

I tried to add a multi-stage Dockefile to build my sample project angularjs-springmvc-sample-boot into Docker images and run it in Docker container.

FROM node:latest AS ui WORKDIR /usr/src/ui COPY package.json . # Setup NPM mirror, optionally for China users. # RUN npm config set registry https://registry.npm.taobao.org/ RUN npm install COPY . . RUN node_modules/.bin/bower install --allow-root RUN node_modules/.bin/gulp FROM maven:latest AS boot WORKDIR /usr/src/app COPY pom.xml . # COPY settings.xml /usr/share/maven/ref/settings-docker.xml RUN mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve COPY . . RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml clean package -DskipTests FROM java:8-jdk-alpine WORKDIR /static COPY --from…

Replace ng-annotate with babel-plugin-angularjs-annotate

Replace ng-annotate with babel-plugin-angularjs-annotateng-annotate was deprecated, the successor is babel-plugin-angularjs-annotate.
More details, please read this post.
babel-plugin-angularjs-annotate is a standard Babel plugin.
Install babel-plugin-angularjs-annotate.
npm install babel-plugin-angularjs-annotate --save-dev It is easy to configure it in the babel configuration file, there is a .babelrc file located in the project root folder.
{ "plugins": ["transform-runtime", ["angularjs-annotate", { "explicitOnly" : true}]], "presets": ["es2015", "stage-0"] } The explicitOnly option force you to use ngInject or /*@ngInject*/ to handle the dependency injection.
I have used ngInject in all of the smaple codes to process dependency injection explicitly, there is no need to change the codes.
In the former codes, I configured a webpack loader named ng-annotate-loader to process ngInject via ng-annotate in we…

Getting started wtih Angular 2: part 5

Authentication We follow the steps in Angular 1.x sample. I will create some facilities.
A Signin and Signup components.A AuthService to wrap HTTP authentiction service.A AppShowAuthed directive to show or hide UI element against the authentiction status. Lets start with creating AuthService.
AuthService In order to handle signin and signup request, create a service named AuthService in src/app/core folder to process it.
@Injectable() exportclassAuthService { private currentUser$:BehaviorSubject<User> =newBehaviorSubject<User>(null); private authenticated$:ReplaySubject<boolean> =newReplaySubject<boolean>(1); private desiredUrl:string=null; constructor( privateapi:ApiService, privatejwt:JWT, privaterouter:Router) { } attempAuth(type:string, credentials:any) { const path = (type==='signin') ?'/login':'/signup'; const url ='/auth'+path; this.api.post(url, credentials) .map(res=>res.jso…