Skip to content

Commit 8fcd5dc

Browse files
authored
Use docker to build dashboard app. (as alternative) (eclipse-che#5848)
* Use docker to build dashboard app. By using layer for package.json and bower.json file, it saves extra time to get npm or bower dependencies Also, if dashboard files are not modified, the build is faster. it targets as well 5127 By default : "$ mvn clean install" --> use docker "$ mvn clean install -Pnative" --> use native tools Change-Id: Ia65161b58e8ae70f7799500750a3d87687e34819 Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
1 parent 530aa44 commit 8fcd5dc

5 files changed

Lines changed: 196 additions & 68 deletions

File tree

dashboard/.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Dockerfile
2+
node_modules
3+
bower_components
4+
target
5+
pom.xml
6+
./typings
7+
./tmp
8+
./codeverage
9+
10+
# Eclipse #
11+
###################
12+
13+
*.launch
14+
.classpath
15+
.project
16+
.settings/
17+
bin/
18+
test-output/
19+
maven-eclipse.xml
20+
21+
# Idea #
22+
##################
23+
*.iml
24+
*.ipr
25+
*.iws
26+
.idea/
27+

dashboard/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2012-2017 Red Hat, Inc
2+
# All rights reserved. This program and the accompanying materials
3+
# are made available under the terms of the Eclipse Public License v1.0
4+
# which accompanies this distribution, and is available at
5+
# http://www.eclipse.org/legal/epl-v10.html
6+
7+
# This is a Dockerfile allowing to build dashboard by using a docker container.
8+
# Build step: $ docker build -t eclipse-che-dashboard
9+
# It builds an archive file that can be used by doing later
10+
# $ docker run --rm eclipse-che-dashboard | tar -C target/ -zxf -
11+
FROM mhart/alpine-node:6
12+
13+
RUN apk update && \
14+
apk add --no-cache git
15+
COPY package.json /dashboard/
16+
RUN cd /dashboard && npm install
17+
COPY bower.json /dashboard/
18+
RUN cd /dashboard && ./node_modules/.bin/bower install --allow-root
19+
COPY . /dashboard/
20+
RUN cd /dashboard && npm run build && cd target/ && tar zcf /tmp/dashboard.tar.gz dist/
21+
22+
CMD zcat /tmp/dashboard.tar.gz

dashboard/README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,30 @@ Eclipse Che is a next generation Eclipse IDE and open source alternative to Inte
44
Che Dashboard
55
==============
66

7-
#Requirements
8-
- Python `v2.7.x`(`v3.x.x`currently not supported)
9-
- Node.js `v4.x.x` (`v5.x.x` / `v6.x.x` are currently not supported)
10-
- npm
11-
12-
Installation instructions for Node.js and npm can be found on the following [link](https://docs.npmjs.com/getting-started/installing-node).
7+
## Requirements
8+
- Docker
139

14-
#Quick start
10+
## Quick start
1511

1612
```sh
1713
cd che/dashboard
1814
mvn clean install
1915
```
2016

17+
note: by default it will build dashboard using a docker image.
18+
If all required tools are installed locally, the native profile can be used instead of the docker build by following command:
19+
20+
```sh
21+
$ mvn -Pnative clean install
22+
```
23+
24+
Required tools for native build:
25+
- Python `v2.7.x`(`v3.x.x`currently not supported)
26+
- Node.js `v4.x.x`, `v5.x.x` or `v6.x.x`
27+
- npm
28+
29+
Installation instructions for Node.js and npm can be found on the following [link](https://docs.npmjs.com/getting-started/installing-node).
30+
2131
## Running
2232
In order to run the project, the serve command is used
2333
```sh

dashboard/gulp/conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var gutil = require('gulp-util');
1616
*/
1717
exports.paths = {
1818
src: 'src',
19-
dist: 'dist',
19+
dist: 'target/dist',
2020
tmp: '.tmp',
2121
e2e: 'e2e'
2222
};

dashboard/pom.xml

Lines changed: 129 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -35,72 +35,13 @@
3535
<build>
3636
<finalName>dashboard-war</finalName>
3737
<plugins>
38-
<plugin>
39-
<artifactId>maven-clean-plugin</artifactId>
40-
<configuration>
41-
<filesets>
42-
<fileset>
43-
<directory>${basedir}/bower_components</directory>
44-
<followSymlinks>false</followSymlinks>
45-
</fileset>
46-
<fileset>
47-
<directory>${basedir}/node_modules</directory>
48-
<followSymlinks>false</followSymlinks>
49-
</fileset>
50-
<fileset>
51-
<directory>${basedir}/dist</directory>
52-
<followSymlinks>false</followSymlinks>
53-
</fileset>
54-
</filesets>
55-
</configuration>
56-
</plugin>
57-
<plugin>
58-
<artifactId>maven-antrun-plugin</artifactId>
59-
<executions>
60-
<execution>
61-
<id>compile</id>
62-
<phase>compile</phase>
63-
<goals>
64-
<goal>run</goal>
65-
</goals>
66-
<configuration>
67-
<target>
68-
<!-- Download NPM dependencies -->
69-
<exec dir="${basedir}" executable="npm" failonerror="true">
70-
<arg value="install" />
71-
</exec>
72-
<!-- Change base HREF of the application that will be hosted on /dashboard -->
73-
<replace file="${basedir}/dist/index.html">
74-
<replacetoken><![CDATA[<base href="/">]]></replacetoken>
75-
<replacevalue><![CDATA[<base href="/dashboard/">]]></replacevalue>
76-
</replace>
77-
</target>
78-
</configuration>
79-
</execution>
80-
<execution>
81-
<id>compilation</id>
82-
<phase>test</phase>
83-
<goals>
84-
<goal>run</goal>
85-
</goals>
86-
<configuration>
87-
<target unless="skipTests">
88-
<!-- Run unit tests -->
89-
<exec dir="${basedir}" executable="gulp" failonerror="true">
90-
<arg value="test" />
91-
</exec>
92-
</target>
93-
</configuration>
94-
</execution>
95-
</executions>
96-
</plugin>
9738
<plugin>
9839
<groupId>org.apache.maven.plugins</groupId>
9940
<artifactId>maven-war-plugin</artifactId>
10041
<configuration>
10142
<webResources>
10243
<resource>
103-
<directory>dist</directory>
44+
<directory>target/dist</directory>
10445
</resource>
10546
</webResources>
10647
<webXml>${basedir}/src/webapp/WEB-INF/web.xml</webXml>
@@ -129,6 +70,134 @@
12970
</plugins>
13071
</build>
13172
<profiles>
73+
<profile>
74+
<!-- Docker build used by default, to use native build, use -Pnative -->
75+
<id>docker</id>
76+
<activation>
77+
<activeByDefault>true</activeByDefault>
78+
</activation>
79+
<build>
80+
<plugins>
81+
<plugin>
82+
<artifactId>maven-antrun-plugin</artifactId>
83+
<executions>
84+
<execution>
85+
<id>build-image</id>
86+
<phase>generate-sources</phase>
87+
<goals>
88+
<goal>run</goal>
89+
</goals>
90+
<configuration>
91+
<target>
92+
<!-- build user dashboard with maven -->
93+
<exec dir="${basedir}" executable="docker" failonerror="true">
94+
<arg value="build" />
95+
<arg value="-t" />
96+
<arg value="eclipse-che-dashboard" />
97+
<arg value="." />
98+
</exec>
99+
</target>
100+
</configuration>
101+
</execution>
102+
<execution>
103+
<id>unpack-docker-build</id>
104+
<phase>generate-sources</phase>
105+
<goals>
106+
<goal>run</goal>
107+
</goals>
108+
<configuration>
109+
<target>
110+
<!-- build user dashboard with docker -->
111+
<exec executable="bash">
112+
<arg value="-c" />
113+
<arg value="docker run --rm eclipse-che-dashboard | tar -C target/ -xf -" />
114+
</exec>
115+
</target>
116+
</configuration>
117+
</execution>
118+
<execution>
119+
<id>update-href</id>
120+
<phase>prepare-package</phase>
121+
<goals>
122+
<goal>run</goal>
123+
</goals>
124+
<configuration>
125+
<target>
126+
<!-- Change base HREF of the application that will be hosted on /dashboard -->
127+
<replace file="${basedir}/target/dist/index.html">
128+
<replacetoken><![CDATA[<base href="/">]]></replacetoken>
129+
<replacevalue><![CDATA[<base href="/dashboard/">]]></replacevalue>
130+
</replace>
131+
</target>
132+
</configuration>
133+
</execution>
134+
</executions>
135+
</plugin>
136+
</plugins>
137+
</build>
138+
</profile>
139+
<profile>
140+
<id>native</id>
141+
<build>
142+
<plugins>
143+
<plugin>
144+
<artifactId>maven-clean-plugin</artifactId>
145+
<configuration>
146+
<filesets>
147+
<fileset>
148+
<directory>${basedir}/bower_components</directory>
149+
<followSymlinks>false</followSymlinks>
150+
</fileset>
151+
<fileset>
152+
<directory>${basedir}/node_modules</directory>
153+
<followSymlinks>false</followSymlinks>
154+
</fileset>
155+
</filesets>
156+
</configuration>
157+
</plugin>
158+
<plugin>
159+
<artifactId>maven-antrun-plugin</artifactId>
160+
<executions>
161+
<execution>
162+
<id>build-dashboard</id>
163+
<phase>compile</phase>
164+
<goals>
165+
<goal>run</goal>
166+
</goals>
167+
<configuration>
168+
<target>
169+
<!-- build user dashboard -->
170+
<exec dir="${basedir}" executable="npm" failonerror="true">
171+
<arg value="install" />
172+
</exec>
173+
<!-- Change base HREF of the application that will be hosted on /dashboard -->
174+
<replace file="${basedir}/target/dist/index.html">
175+
<replacetoken><![CDATA[<base href="/">]]></replacetoken>
176+
<replacevalue><![CDATA[<base href="/dashboard/">]]></replacevalue>
177+
</replace>
178+
</target>
179+
</configuration>
180+
</execution>
181+
<execution>
182+
<id>compilation</id>
183+
<phase>test</phase>
184+
<goals>
185+
<goal>run</goal>
186+
</goals>
187+
<configuration>
188+
<target unless="skipTests">
189+
<!-- Run unit tests -->
190+
<exec dir="${basedir}" executable="gulp" failonerror="true">
191+
<arg value="test" />
192+
</exec>
193+
</target>
194+
</configuration>
195+
</execution>
196+
</executions>
197+
</plugin>
198+
</plugins>
199+
</build>
200+
</profile>
132201
<profile>
133202
<id>qa</id>
134203
<build>

0 commit comments

Comments
 (0)