Skip to content

Commit

Permalink
Add default nginx.conf file
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-low committed Oct 1, 2024
1 parent 7daaa78 commit dbb69fe
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ ARG BUILD_ENV=prod

RUN mkdir /app
WORKDIR /app
COPY package.json /app
COPY yarn.lock /app
COPY package.json yarn.lock /app/
RUN yarn install

COPY . /app/
COPY src/ /app/src
COPY public/ /app/public
ENV REACT_APP_PRODUCTION_API_URL /api/v1
RUN yarn build:${BUILD_ENV}
RUN yarn run build:${BUILD_ENV}

FROM nginx:alpine
COPY --from=builder /app/build /assets
COPY --from=builder /app/build /srv/www
COPY nginx.conf /etc/nginx/templates/default.conf.template
30 changes: 30 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
server {
listen 80;
charset utf-8;

include /etc/nginx/mime.types;
default_type application/octet-stream;

gzip on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;

location ~ ^/(api|admin) {
# /api and /admin routes are handled by the backend
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass $BACKEND_URL;
}

location / {
# other routes are served from static files. if the requested file is not
# found, the homepage (index.html) is served. this is needed because the
# frontend JS code uses the path component of the URL in its client-side
# routing.
root /srv/www;
try_files $uri $uri/ /index.html;
}
}

0 comments on commit dbb69fe

Please sign in to comment.