Skip to content
This repository was archived by the owner on Dec 28, 2019. It is now read-only.

Commit 8db77ea

Browse files
committed
Update Project Structure
- Changes in Dockerfile - Update Dependencies - Add Lazy Loading Modules - Remove Tests - Update to 1.0.2
1 parent 0f3a5cf commit 8db77ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3629
-10675
lines changed

.angular-cli.json

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@
2222
"../node_modules/font-awesome/css/font-awesome.min.css",
2323
"styles.scss"
2424
],
25-
"scripts": [
26-
"../node_modules/jquery/dist/jquery.min.js",
27-
"../node_modules/bootstrap/dist/js/bootstrap.bundle.js"
28-
],
25+
"scripts": [],
2926
"environmentSource": "environments/environment.ts",
3027
"environments": {
3128
"dev": "environments/environment.ts",
3229
"prod": "environments/environment.prod.ts"
30+
},
31+
"stylePreprocessorOptions": {
32+
"includePaths": ["./", "./scss"]
3333
}
3434
}
3535
],
36+
"e2e": {
37+
"protractor": {
38+
"config": "./protractor.conf.js"
39+
}
40+
},
3641
"lint": [
3742
{
3843
"project": "src/tsconfig.app.json",
@@ -41,6 +46,10 @@
4146
{
4247
"project": "src/tsconfig.spec.json",
4348
"exclude": "**/node_modules/**"
49+
},
50+
{
51+
"project": "e2e/tsconfig.e2e.json",
52+
"exclude": "**/node_modules/**"
4453
}
4554
],
4655
"test": {
@@ -50,8 +59,31 @@
5059
},
5160
"defaults": {
5261
"styleExt": "scss",
62+
"build": {
63+
"showCircularDependencies": false
64+
},
65+
"class": {
66+
"spec": false
67+
},
5368
"component": {
54-
"inlineStyle": true
69+
"inlineStyle": true,
70+
"inlineTemplate": false,
71+
"spec": false
72+
},
73+
"directive": {
74+
"spec": false
75+
},
76+
"guard": {
77+
"spec": false
78+
},
79+
"module": {
80+
"spec": false
81+
},
82+
"pipe": {
83+
"spec": false
84+
},
85+
"service": {
86+
"spec": false
5587
}
5688
}
5789
}

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.git*
1+
.git*
2+
node_modules/

Dockerfile

Lines changed: 23 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,33 @@
1-
FROM docker.io/lalyos/upx AS upx
1+
# Stage 0, based on Node.js, to build and compile Angular
2+
FROM node:8 as node
23

3-
FROM node:8 AS asset-builder
4-
RUN mkdir -p /usr/src/app
5-
WORKDIR /usr/src/app
6-
ARG NODE_ENV=development
7-
ENV NODE_ENV=$NODE_ENV
8-
COPY package.json /usr/src/app/
9-
COPY package-lock.json /usr/src/app/
4+
WORKDIR /app
105

11-
RUN npm install && npm cache clean --force
6+
COPY package.json /app/
7+
COPY package-lock.json /app/
128

13-
COPY .angular-cli.json /usr/src/app/
14-
COPY build.js /usr/src/app/
15-
COPY tsconfig.json /usr/src/app/
16-
COPY tslint.json /usr/src/app/
9+
RUN npm install
1710

18-
COPY src /usr/src/app/src
11+
COPY ./ /app/
1912

20-
RUN npm run build
13+
ARG env=prod
14+
ARG lang=en
2115

22-
FROM golang AS asset-compiler
23-
RUN go get github.com/elazarl/go-bindata/...
24-
RUN go get github.com/elazarl/go-bindata-assetfs/...
16+
RUN npm run build:$lang -- --prod --environment $env
2517

26-
COPY --from=asset-builder /usr/src/app/dist /dist
27-
RUN go-bindata-assetfs -nomemcopy -nocompress /dist/... \
28-
&& ( grep -q '"os"' bindata_assetfs.go \
29-
|| sed -e 's|"github.com/elazarl/go-bindata-assetfs"|"github.com/elazarl/go-bindata-assetfs"\n\t"os"|' -i bindata_assetfs.go ) \
30-
&& cp bindata_assetfs.go /bindata_assetfs.go
3118

19+
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
20+
FROM nginx
3221

33-
FROM golang AS server-builder
22+
COPY --from=node /app/dist/ /usr/share/nginx/html
3423

35-
RUN go get github.com/heptiolabs/healthcheck/...
36-
RUN go get github.com/gorilla/handlers/...
37-
RUN go get github.com/hkwi/h2c/...
38-
RUN go get github.com/elazarl/go-bindata-assetfs/...
39-
RUN go get github.com/heptiolabs/healthcheck/...
40-
41-
COPY --from=upx /bin/upx /bin/upx
42-
RUN ( \
43-
echo 'package main'; \
44-
echo ''; \
45-
echo 'import ('; \
46-
echo ' "github.com/gorilla/handlers"'; \
47-
echo ' "github.com/hkwi/h2c"'; \
48-
echo ' "log"'; \
49-
echo ' "net/http"'; \
50-
echo ' "os"'; \
51-
echo ')'; \
52-
echo ''; \
53-
echo 'func getEnv(key, fallback string) string {'; \
54-
echo ' if value, ok := os.LookupEnv("SERVER_" + key); ok {'; \
55-
echo ' return value'; \
56-
echo ' }'; \
57-
echo ' return fallback'; \
58-
echo '}'; \
59-
echo ''; \
60-
echo 'type hookedResponseWriter struct {'; \
61-
echo ' http.ResponseWriter'; \
62-
echo ' ignore bool'; \
63-
echo '}'; \
64-
echo ''; \
65-
echo 'func (hrw *hookedResponseWriter) WriteHeader(status int) {'; \
66-
echo ' if status == 404 {'; \
67-
echo ' hrw.ignore = true'; \
68-
echo ' fallbackDocument, err := Asset("dist/index.html")'; \
69-
echo ' if err != nil {'; \
70-
echo ' log.Fatal("cannot process 404-handler", err)'; \
71-
echo ' }'; \
72-
echo ' hrw.ResponseWriter.Header().Set("Content-Type", "text/html; charset=utf-8");'; \
73-
echo ' hrw.ResponseWriter.WriteHeader(200)'; \
74-
echo ' hrw.ResponseWriter.Write(fallbackDocument)'; \
75-
echo ' } else {'; \
76-
echo ' hrw.ResponseWriter.WriteHeader(status)'; \
77-
echo ' }'; \
78-
echo '}'; \
79-
echo ''; \
80-
echo 'func (hrw *hookedResponseWriter) Write(p []byte) (int, error) {'; \
81-
echo ' if hrw.ignore {'; \
82-
echo ' return len(p), nil'; \
83-
echo ' }'; \
84-
echo ' return hrw.ResponseWriter.Write(p)'; \
85-
echo '}'; \
86-
echo ''; \
87-
echo 'type NotFoundHook struct {'; \
88-
echo ' h http.Handler'; \
89-
echo '}'; \
90-
echo ''; \
91-
echo 'func (nfh NotFoundHook) ServeHTTP(w http.ResponseWriter, r *http.Request) {'; \
92-
echo ' nfh.h.ServeHTTP(&hookedResponseWriter{ResponseWriter: w}, r)'; \
93-
echo '}'; \
94-
echo ''; \
95-
echo 'func main() {'; \
96-
echo ' http.Handle("/", handlers.ProxyHeaders(handlers.LoggingHandler(os.Stdout, NotFoundHook{http.FileServer(assetFS())})))'; \
97-
echo ' log.Fatal(http.ListenAndServe(getEnv("BIND", ":8080"), &h2c.Server{}))'; \
98-
echo '}'; \
99-
) > web.go
100-
COPY --from=asset-compiler /bindata_assetfs.go bindata_assetfs.go
101-
ARG GOOS=linux
102-
ENV GOOS=$GOOS
103-
104-
ARG CGO_ENABLED=0
105-
ENV CGO_ENABLED=$CGO_ENABLED
106-
107-
RUN go build -o /server bindata_assetfs.go web.go
108-
109-
ARG UPX_ARGS=-6
110-
RUN upx ${UPX_ARGS} /server
111-
112-
FROM scratch
113-
ENTRYPOINT ["server"]
114-
COPY --from=server-builder /server /bin/server
24+
RUN ( \
25+
echo 'server {'; \
26+
echo ' listen 80;'; \
27+
echo ' location / {'; \
28+
echo ' root /usr/share/nginx/html;'; \
29+
echo ' index index.html index.htm;'; \
30+
echo ' try_files $uri $uri/ /index.html =404;'; \
31+
echo ' }'; \
32+
echo '}'; \
33+
) > /etc/nginx/conf.d/default.conf

karma.conf.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)