diff --git a/cmd/nginx/Dockerfile b/cmd/nginx/Dockerfile new file mode 100644 index 0000000..0fdd591 --- /dev/null +++ b/cmd/nginx/Dockerfile @@ -0,0 +1,15 @@ +# Build fronend +FROM node:8-slim AS frontend_builder +WORKDIR /app +COPY . . +RUN npm install +RUN npm run build + +# Build nginx +FROM umputun/nginx-le:latest + +COPY cmd/nginx/podsync.conf /etc/nginx/service.conf +COPY cmd/nginx/robots.txt /var/www/ + +COPY --from=frontend_builder /app/templates/ /var/www/ +COPY --from=frontend_builder /app/dist/ /var/www/assets/ diff --git a/cmd/nginx/podsync.conf b/cmd/nginx/podsync.conf index 9b152fb..583e1aa 100644 --- a/cmd/nginx/podsync.conf +++ b/cmd/nginx/podsync.conf @@ -9,7 +9,9 @@ upstream backend { server { listen 443; - root /usr/share/nginx/html; + root /var/www/; + index index.html; + server_name podsync.net; ssl on; @@ -34,6 +36,10 @@ server { } location / { + try_files $uri $uri/ @backend; + } + + location @backend { proxy_pass http://backend; proxy_buffers 8 16k; proxy_buffer_size 16k; diff --git a/cmd/nginx/robots.txt b/cmd/nginx/robots.txt new file mode 100644 index 0000000..07c5cc4 --- /dev/null +++ b/cmd/nginx/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Allow: /$ +Disallow: / +Host: www.podsync.net \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 9f1fdcc..6a17e06 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,7 +46,7 @@ services: mem_limit: 268435456 # 256MB oom_kill_disable: true nginx: - image: umputun/nginx-le:latest + image: mxpv/nginx:latest container_name: nginx restart: always ports: diff --git a/nginx.sh b/nginx.sh new file mode 100755 index 0000000..9c36004 --- /dev/null +++ b/nginx.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +docker build -t mxpv/nginx -f cmd/nginx/Dockerfile . +docker push mxpv/nginx