Skip to content

Commit

Permalink
use nginx to serve pbfFiles folder
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Jul 14, 2023
1 parent d9591b5 commit db02b46
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,22 @@ services:
context: ../
dockerfile: docker/web/Dockerfile
command: node server.js
ports:
- "8080:8080"
env_file:
- ./.env
volumes:
- ./web/auth0-conf.js:/app/dist/auth0-conf.js
- ./volumes/databases:/app/databases
- ./volumes/pbfFiles:/app/pbfFiles

nginx:
build:
context: ../
dockerfile: docker/nginx/Dockerfile
ports:
- "8080:80"
volumes:
- ./volumes/pbfFiles:/mnt/volumes/pbfFiles

setup_web:
profiles:
- setup
Expand Down
17 changes: 17 additions & 0 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:16-alpine as base
USER node
WORKDIR /app
COPY --chown=node:node AllNeededDirectories/bicycle-osm-app/package.json AllNeededDirectories/bicycle-osm-app/package-lock.json ./
RUN npm install
COPY --chown=node:node ./AllNeededDirectories/bicycle-osm-app/ ./
CMD ["npm", "start"]

FROM base as build
RUN yarn build


FROM nginx:stable-alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
37 changes: 37 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
server {

listen 80;
resolver 127.0.0.11;

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
}

client_max_body_size 300m;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Cookie $http_cookie;
proxy_redirect off;

location /pbfFiles/ {
alias /mnt/volumes/pbfFiles/;

location ~* \.(?:html|js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|ttf|rtf|swf|ico|flv|txt|woff|woff2|svg|xml|pbf|geojson)$ {
gzip_static always;
expires 30d;
access_log off;
add_header Pragma "public";
add_header Cache-Control "max-age=31536000, public";
}
}

location / {
proxy_pass http://web:8080;
}
}

0 comments on commit db02b46

Please sign in to comment.