Skip to content

Commit

Permalink
chore: update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirsamdarshi committed Apr 17, 2024
1 parent 6aaeb0c commit 1edffd3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
29 changes: 16 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
6 changes: 0 additions & 6 deletions docker-entrypoint.sh

This file was deleted.

17 changes: 16 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MoTrPAC",
"version": "0.1.0",
"version": "2.0.0",
"private": true,
"dependencies": {
"auth0-js": "9.20.0",
Expand Down

0 comments on commit 1edffd3

Please sign in to comment.