Files
reference/Dockerfile
T

20 lines
594 B
Docker

# Stage 1: build the application
FROM nginx:alpine AS build-nginx
RUN apk add nodejs npm
COPY . .
RUN npm i
RUN npm run build
RUN rm -rf /etc/nginx/conf.d/*
COPY nginx.conf /etc/nginx/
COPY public /usr/share/nginx/html/
EXPOSE 80
# Stage 2: final image
FROM alpine:latest
RUN apk add --no-cache nginx && mkdir -p /run/nginx
COPY --from=build-nginx /usr/share/nginx/html/ /usr/share/nginx/html/
COPY --from=build-nginx /etc/nginx/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
HEALTHCHECK --interval=1s --timeout=3s CMD wget -q -O - http://localhost:80 || exit 1
CMD ["nginx", "-g", "daemon off;"]