diff --git a/Dockerfile b/Dockerfile index 85629963..18e2f01d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,26 @@ # create-react-app build environment -FROM node:16-alpine as react-build +FROM node:20-alpine as react-build WORKDIR /app ENV PATH /app/node_modules/.bin:$PATH -#COPY package.json yarn.lock ./ -COPY package*.json ./ -RUN yarn cache clean && yarn + +COPY package*.json yarn.lock ./ +RUN --mount=type=cache,target=/root/.yarn \ + YARN_CACHE_FOLDER=/root/.yarn JOBS=max \ + yarn install --network-timeout 1000000 + COPY . ./ -RUN yarn sass && yarn build +RUN --mount=type=cache,target=/root/.yarn \ + YARN_CACHE_FOLDER=/root/.yarn JOBS=max \ + yarn sass + +RUN --mount=type=cache,target=/root/.yarn \ + YARN_CACHE_FOLDER=/root/.yarn JOBS=max \ + yarn build # nginx server environment FROM nginx:alpine -COPY nginx.conf /etc/nginx/conf.d/configfile.template -#COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=react-build /app/build /usr/share/nginx/html LABEL org.opencontainers.image.description="MoTrPAC Data Portal Docker Image" @@ -22,9 +30,4 @@ LABEL org.opencontainers.image.url="https://motrpac-data.org" LABEL org.opencontainers.image.vendor="MoTrPAC" LABEL org.opencontainers.image.version=$IMAGE_VERSION -ARG SERVER_PORT -ENV PORT=$SERVER_PORT -EXPOSE $SERVER_PORT -RUN sh -c "envsubst '\$PORT' < /etc/nginx/conf.d/configfile.template > /etc/nginx/conf.d/default.conf" -#ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["nginx", "-g", "daemon off;"] +EXPOSE 80 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 7fcc5244..00000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh -set -eu - -envsubst '$PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf -cat /etc/nginx/conf.d/default.conf -exec "$@" diff --git a/nginx.conf b/nginx.conf index 30042a70..e9b770e6 100644 --- a/nginx.conf +++ b/nginx.conf @@ -9,15 +9,30 @@ events { } server { - listen $PORT; + listen 80; server_name localhost; + log_format main '$remote_addr - $remote_user [$time] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html; } + location /status { + stub_status on; + access_log off; + allow 127.0.0.1; + allow 10.0.0.0/8; + allow 172.16.0.0/12; + allow 192.168.0.0/16; + deny all; + } + gzip on; gzip_vary on; gzip_min_length 10240; diff --git a/package.json b/package.json index 5901a438..9790a750 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "MoTrPAC", - "version": "0.1.0", + "version": "2.0.0", "private": true, "dependencies": { "auth0-js": "9.20.0",