-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFrontend.dockerfile
47 lines (33 loc) · 1.39 KB
/
Frontend.dockerfile
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
FROM node:lts-alpine as base
RUN apk update && apk upgrade && apk add -q vim git
FROM base as source
RUN mkdir -p /app/frontend
WORKDIR /app
COPY ./package.json .
RUN npm install
COPY pkg-svcs/frontend/package.json /app/frontend/
WORKDIR /app/frontend
RUN npm install
COPY ./pkg-svcs/frontend/ /app/frontend/
FROM source as builder
WORKDIR /app/frontend
ARG API_URL
ARG OTLP_COLLECTOR_URL
RUN sed -i 's/\$OTLP_COLLECTOR_URL/$OTLP_COLLECTOR_URL/' .env.registry
RUN sed -i 's/\$API_URL/$API_URL/' .env.registry
RUN mv .env.registry .env
RUN npm run build
FROM nginx:stable-alpine as production
WORKDIR /app/frontend
COPY --from=builder --chown=101:0 /app/frontend/dist/ /var/www/
COPY --from=builder --chown=101:0 /app/frontend/docker/nginx.conf /etc/nginx/conf.d/default.conf
# run NGINX as an unprivileged user
RUN sed -i -e '/user/!b' -e '/nginx/!b' -e '/nginx/d' /etc/nginx/nginx.conf \
&& sed -i 's!/var/run/nginx.pid!/tmp/nginx.pid!g' /etc/nginx/nginx.conf \
&& sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \
# nginx user must own the cache directory to write cache
&& chown -R 101:0 /var/cache/nginx \
&& chmod -R g+w /var/cache/nginx
EXPOSE 8080
USER 101
CMD ["nginx", "-g", "daemon off;"]