|
|
|
FROM node:18-alpine as build |
|
|
|
|
|
RUN apk add --no-cache git |
|
|
|
WORKDIR /app |
|
|
|
|
|
RUN addgroup -g 1001 -S nodejs && \ |
|
adduser -S nodejs -u 1001 |
|
|
|
|
|
COPY --chown=nodejs:nodejs package*.json ./ |
|
|
|
|
|
USER nodejs |
|
|
|
|
|
RUN npm ci && npm cache clean --force |
|
|
|
|
|
COPY --chown=nodejs:nodejs . . |
|
|
|
|
|
RUN npm run build |
|
|
|
|
|
FROM nginx:alpine |
|
|
|
|
|
RUN apk add --no-cache wget |
|
|
|
|
|
RUN mkdir -p /var/cache/nginx && \ |
|
chown -R nginx:nginx /var/cache/nginx && \ |
|
chown -R nginx:nginx /var/log/nginx && \ |
|
chown -R nginx:nginx /etc/nginx/conf.d |
|
|
|
|
|
COPY --from=build --chown=nginx:nginx /app/dist /usr/share/nginx/html |
|
|
|
|
|
COPY --chown=nginx:nginx nginx.conf /etc/nginx/conf.d/default.conf |
|
|
|
|
|
USER nginx |
|
|
|
|
|
EXPOSE 80 |
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ |
|
CMD wget --no-verbose --tries=1 --spider http://localhost:80 || exit 1 |
|
|
|
|
|
CMD ["nginx", "-g", "daemon off;"] |
|
|