-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile-study
74 lines (58 loc) · 3.03 KB
/
Dockerfile-study
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
FROM nginx:1.14.2
# install some handy utilities. do this early in docker so they are cached in a layer
RUN \
apt-get update \
&& apt-get install -y curl \
&& apt-get install -y nano \
&& apt-get install -y git
RUN apt-get install -qy libpcre3 libpcre3-dev libz-dev apache2-dev wget libxml2-dev lua5.1 lua5.1-dev && \
cd /root && \
git clone https://github.com/nbs-system/naxsi.git && \
curl -fSL http://nginx.org/download/nginx-1.14.2.tar.gz -o nginx.tar.gz && \
tar -xvzf nginx.tar.gz && \
cd nginx-1.14.2 && \
./configure --with-compat --add-dynamic-module=../naxsi/naxsi_src && \
make modules && \
cp objs/ngx_http_naxsi_module.so /etc/nginx/modules
RUN cp -rfp /root/naxsi/naxsi_config/naxsi_core.rules /etc/nginx/modules/
COPY nginx.conf /etc/nginx/nginx.conf
# install node in another early layer so it can be cached
ENV NODE_VERSION v10.16.0
# download and install node
RUN curl -SLO https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-linux-x64.tar.gz
RUN tar -xzf "node-$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1
RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs
# install angular in a separate cached layer
RUN mkdir -p /ddp-workspace/projects
ENV ANGULAR_CLI @angular/[email protected]
RUN npm install -g $ANGULAR_CLI
# now install most of the dependencies early for the sdk and test-app builds
# when package.json-ish files change, a fresh download will happen. otherwise, they'll be cached.
ADD ddp-workspace/angular.json /ddp-workspace/
ADD ddp-workspace/package.json /ddp-workspace/
ADD ddp-workspace/package-lock.json /ddp-workspace/
ADD ddp-workspace/tsconfig.json /ddp-workspace/
RUN mkdir -p /ddp-workspace/projects/ddp-sdk
RUN mkdir -p /ddp-workspace/projects/toolkit
COPY ddp-workspace/projects/ddp-sdk/src/ /ddp-workspace/projects/ddp-sdk/src
COPY ddp-workspace/projects/toolkit/src/ /ddp-workspace/projects/toolkit/src
# build the study
ARG ANGULAR_DIR
RUN mkdir -p /ddp-workspace/projects/$ANGULAR_DIR
ADD ddp-workspace/projects/$ANGULAR_DIR/tsconfig.app.json /ddp-workspace/projects/$ANGULAR_DIR/
ADD ddp-workspace/projects/$ANGULAR_DIR/tsconfig.es5.json /ddp-workspace/projects/$ANGULAR_DIR/
ADD ddp-workspace/projects/$ANGULAR_DIR/tsconfig.spec.json /ddp-workspace/projects/$ANGULAR_DIR/
ADD ddp-workspace/projects/$ANGULAR_DIR/browserslist /ddp-workspace/projects/$ANGULAR_DIR/
COPY ddp-workspace/projects/$ANGULAR_DIR/src/ /ddp-workspace/projects/$ANGULAR_DIR/src
WORKDIR /ddp-workspace
RUN ["npm", "ci"]
# remove the config dir if it's been rendered for local dev; it should be mounted via docker-compose
RUN rm -fr /ddp-workspace/projects/$ANGULAR_DIR/src/assets/config
RUN ng build $ANGULAR_DIR --prod --aot --base-href=/ --output-path=/usr/share/nginx/html
# gzip and preserve unzipped stuff so we can serve out both compressed and uncompressed
RUN gzip -k -q /usr/share/nginx/html/*.js || true
RUN gzip -k -q /usr/share/nginx/html/assets/images/*.svg || true
RUN gzip -k -q /usr/share/nginx/html/*.css || true
# keep track of git hash
ARG GIT_SHA
RUN echo $GIT_SHA > git_sha.txt