-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.web
82 lines (70 loc) · 2.64 KB
/
Dockerfile.web
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
75
76
77
78
79
80
81
82
# Custom builder image
FROM monogramm/docker-ngxp:jdk AS builder
WORKDIR /usr/src/app
ARG BUILD_ENV=prod
ARG CLIENT_LOCALE=en
ARG API_CLIENT_ID
ARG API_CLIENT_SECRET
COPY . .
# Install NGXP project dependencies
# Build web site
RUN set -ex; \
node --version; \
npm --version; \
ng --version; \
set +e; \
test -n "${API_CLIENT_ID}" || exit 1; \
test -n "${API_CLIENT_SECRET}" || exit 2; \
set -e; \
npm run ngxp-install; \
sed -i \
-e "s| locale: '.*',| locale: '${CLIENT_LOCALE}',|gm" \
-e "s| clientId: '.*',| clientId: '${API_CLIENT_ID}',|gm" \
-e "s| clientSecret: '.*',| clientSecret: '${API_CLIENT_SECRET}',|gm" \
"web/src/environments/environment.${BUILD_ENV}.ts" \
; \
npm run "build.${BUILD_ENV}"; \
mkdir -p /usr/src/dist; \
mv /usr/src/app/web/dist/app /usr/src/dist/app; \
rm -rf /usr/src/app
FROM nginx:alpine
# NGINX configurations
COPY ./nginx/conf.d /etc/nginx/conf.d
# Copy built app from builder to www root
COPY --from=builder /usr/src/dist/app /var/www/html
# Arguments to label built container
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown
ARG VERSION=1.1.0
ARG DOMAIN=localhost
RUN set -ex; \
sed -i \
-e "s|localhost|${DOMAIN}|g" \
-e "s|lastmod>.*</lastmod|lastmod>${BUILD_DATE}</lastmod|g" \
/var/www/html/robots.txt \
/var/www/html/sitemap.xml \
; \
echo "${TAG} ${VCS_REF} ${BUILD_DATE}" > '/var/www/html/.docker-app-version'
# Container labels (http://label-schema.org/)
# Container annotations (https://github.com/opencontainers/image-spec)
LABEL maintainer="[email protected]" \
product="NGXP-Seed" \
version=$VERSION \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/Monogramm/ngxp-seed/" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="NGXP-Seed" \
org.label-schema.description="Cross-platform application." \
org.label-schema.url="https://${DOMAIN}/" \
org.label-schema.vendor="Monogramm" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.source="https://github.com/Monogramm/ngxp-seed/" \
org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.title="NGXP-Seed" \
org.opencontainers.image.description="Cross-platform application." \
org.opencontainers.image.url="https://${DOMAIN}/" \
org.opencontainers.image.vendor="Monogramm" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.authors="[email protected]"