Dockerfile 1.42 KB
Newer Older
jcorvi's avatar
jcorvi committed
1
2
3
4
5
6
### STAGE 1: Build ###
FROM node:10.18.1-alpine as build
WORKDIR /usr/src/app
COPY package.json ./
RUN apk add git
RUN npm install
jcorvi's avatar
jcorvi committed
7
RUN npm update
jcorvi's avatar
jcorvi committed
8
COPY . .
javi's avatar
javi committed
9
COPY src/assets/index.template.html src/index.html
jcorvi's avatar
jcorvi committed
10
11
#RUN npm run build --prod
RUN ./node_modules/.bin/ng build --prod --base-href /pretox/
jcorvi's avatar
jcorvi committed
12
### STAGE 2: Run ###
jcorvi's avatar
jcorvi committed
13
FROM nginx:1.21.6-alpine
jcorvi's avatar
jcorvi committed
14
15
16
17
18
#fix refresh 
#https://makinhs.medium.com/for-some-folks-who-will-get-in-trouble-with-refresh-the-angular-page-and-get-a-404-2cf394b5dac6
RUN rm -rf /usr/share/nginx/html/* && rm -rf /etc/nginx/nginx.conf
COPY ./nginx.conf /etc/nginx/nginx.conf

jcorvi's avatar
jcorvi committed
19
COPY --from=build /usr/src/app/dist/my-app /usr/share/nginx/html/pretox
jcorvi's avatar
jcorvi committed
20

javi's avatar
javi committed
21
#CMD ["/bin/sh",  "-c",  "envsubst < /usr/share/nginx/html/pretox/assets/env.template.js > /usr/share/nginx/html/pretox/assets/env.js && exec nginx -g 'daemon off;'"]
jcorvi's avatar
jcorvi committed
22
CMD ["/bin/sh",  "-c",  "envsubst < /usr/share/nginx/html/pretox/assets/env.template.js > /usr/share/nginx/html/pretox/assets/env.js && envsubst < /usr/share/nginx/html/pretox/index.html > /usr/share/nginx/html/pretox/index.html_2 && cp /usr/share/nginx/html/pretox/index.html_2 /usr/share/nginx/html/pretox/index.html && exec nginx-debug -g 'daemon off;'"]
javi's avatar
javi committed
23
#CMD ["/bin/sh",  "-c",  "envsubst < /usr/share/nginx/html/pretox/assets/index.template.html > /usr/share/nginx/html/pretox/index.html && exec nginx -g 'daemon off;'"]
jcorvi's avatar
jcorvi committed
24
# && exec nginx-debug -g 'daemon off;'
jcorvi's avatar
jcorvi committed
25
26
#FROM nginx:1.17.1-alpine
#COPY /dist/my-app /usr/share/nginx/html