|
|
|
FROM node:16-alpine AS build |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY package*.json ./ |
|
|
|
|
|
RUN npm install |
|
|
|
|
|
COPY . . |
|
|
|
|
|
RUN npm run build |
|
|
|
|
|
FROM nginx:alpine |
|
|
|
|
|
RUN apk add --no-cache shadow \ |
|
&& useradd -u 1001 -U -d /home/user -s /bin/bash user \ |
|
&& mkdir -p /home/user \ |
|
&& chown -R user:user /home/user |
|
|
|
|
|
RUN apk add --no-cache nginx \ |
|
&& mkdir -p /var/cache/nginx /var/log/nginx /var/lib/nginx /var/run \ |
|
&& touch /var/run/nginx.pid \ |
|
&& chown -R user:user /var/cache/nginx /var/log/nginx /var/lib/nginx /var/run/nginx.pid |
|
|
|
|
|
USER root |
|
|
|
|
|
RUN rm /etc/nginx/conf.d/default.conf |
|
|
|
|
|
COPY --from=build /app/dist /usr/share/nginx/html |
|
|
|
|
|
COPY nginx.conf /etc/nginx/conf.d |
|
|
|
|
|
RUN chown -R user:user /usr/share/nginx/html /etc/nginx/conf.d /var/cache/nginx /var/run /var/log/nginx |
|
|
|
|
|
USER user |
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
CMD ["nginx", "-g", "daemon off;"] |
|
|