-
Notifications
You must be signed in to change notification settings - Fork 121
/
Dockerfile-frontend
44 lines (31 loc) · 1.39 KB
/
Dockerfile-frontend
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
####################################################################
# Stage 1 : NODE_BUILD
#
# Use a docker image with NODE to build the deliverable
# Build everywhere
####################################################################
FROM node:12 as build
MAINTAINER Cedrick Lunven
# Get Sources
RUN apt update && \
apt install -y git && \
git clone https://github.com/spring-petclinic/spring-petclinic-angular.git /workspace
ARG NPM_REGISTRY=" https://registry.npmjs.org"
# Enforcing env var BACKEND_URL
RUN echo "export const environment = {production: false, REST_API_URL: 'http://petclinic-backend:9966/petclinic/api/'};" > /workspace/src/environments/environment.ts && \
echo "registry = \"$NPM_REGISTRY\"" > /workspace/.npmrc && \
cd /workspace/ && \
npm install && \
npm run build
####################################################################
# Stage 2 : RUNTIME
# Use the DIST folder to package an image with NGINX.
####################################################################
FROM nginx:1.19.4 AS runtime
COPY --from=build /workspace/dist/ /usr/share/nginx/html/
RUN chmod a+rwx /var/cache/nginx /var/run /var/log/nginx && \
sed -i.bak 's/listen\(.*\)80;/listen 8080;/' /etc/nginx/conf.d/default.conf && \
sed -i.bak 's/^user/#user/' /etc/nginx/nginx.conf
EXPOSE 8080
USER nginx
HEALTHCHECK CMD [ "service", "nginx", "status" ]