diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7ab1392 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules/ +*.log +Dockerfile* +README.md diff --git a/Dockerfile b/Dockerfile index e4159be..24a2b67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,14 @@ -FROM nginx:1.23.3-alpine - -# Remove the default Nginx configuration -RUN rm -rf /etc/nginx/conf.d/ - -# Copy our Nginx configuration +# Stage 1: build the application +FROM nginx:alpine AS build +RUN rm -rf /etc/nginx/conf.d/* COPY nginx.conf /etc/nginx/ - -# Copy the static website -# Use the .dockerignore file to control what ends up inside the image! COPY public /usr/share/nginx/html/ +EXPOSE 80 -# Expose port 80 -EXPOSE 3000 - -# Start Nginx -CMD ["nginx", "-g", "daemon off;"] +# Stage 2: final image +FROM alpine:latest +RUN apk add --no-cache nginx && mkdir -p /run/nginx +COPY --from=build /usr/share/nginx/html/ /usr/share/nginx/html/ +COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index c1d60b2..3602521 100644 --- a/nginx.conf +++ b/nginx.conf @@ -22,8 +22,8 @@ http { keepalive_timeout 65; server { - listen 3000; - listen [::]:3000; + listen 80; + listen [::]:80; server_name localhost; root /usr/share/nginx/html;