diff --git a/Dockerfile b/Dockerfile index e10dd21..6598ab1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,6 @@ RUN yarn build # production environment FROM nginx:stable-alpine -#COPY --from=build /app/build /usr/share/nginx/html -COPY --from=build /app/build /usr/share/nginx/html/keycloakify-demo-app +COPY --from=build /app/build /usr/share/nginx/html COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf CMD nginx -g 'daemon off;' diff --git a/Dockerfile.ci b/Dockerfile.ci index cdf659d..13fb0bc 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -16,7 +16,6 @@ COPY nginx.conf . # production environment (copy pasted from ./Dockerfile) FROM nginx:stable-alpine -#COPY --from=build /app/build /usr/share/nginx/html -COPY --from=build /app/build /usr/share/nginx/html/keycloakify-demo-app +COPY --from=build /app/build /usr/share/nginx/html COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf CMD nginx -g 'daemon off;' \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 2af9eed..062d238 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,36 +1,36 @@ +# NOTE: This file will only work with an app hosted at root +# it is not the case here ("homename": "https://.../keyclaokify-demo-app") server { listen 80; - location /keycloakify-demo-app { + root /usr/share/nginx/html; + index index.html; - root /usr/share/nginx/html; - - } + try_files $uri $uri/ /index.html; + # Any route containing a file extension (e.g. /devicesfile.js) + location ~ ^.+\..+$ { + try_files $uri =404; - #location ~* \.(?:manifest|appcache|html?|xml|json)$ { - # expires -1; - #} + location ~* \.(?:html|json|txt)$ { + expires -1; + } - #location ~* \.(?:css|js|eot|ttf|woff|woff2|svg)$ { - # try_files $uri =404; - # expires 1y; - # access_log off; - # add_header Cache-Control "public"; - #} + # CRA generates filenames with hashes so we can + # tell the browser to keep in cache the resources. + location ~* \.(?:css|js|woff2?|eot|ttf|xml)$ { + expires 1y; + access_log off; + add_header Cache-Control "public"; - #location ~* \.(eot|ttf|woff|woff2|svg)$ { - # add_header Access-Control-Allow-Origin *; - #} + # Allow font to be downloaded from pages + # served by Keycloak + location ~* \.(?:woff2?|eot|ttf|xml)$ { + add_header Access-Control-Allow-Origin *; + } - ## Any route containing a file extension (e.g. /devicesfile.js) - #location ~ ^.+\..+$ { - # try_files $uri =404; - #} + } - ## Any route that doesn't have a file extension (e.g. /devices) - #location / { - # try_files $uri $uri/ /index.html; - #} + } } \ No newline at end of file diff --git a/package.json b/package.json index 051409e..c24a06b 100755 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "homepage": "https://garronej.github.io/keycloakify-demo-app", + "homepage": "https://garronej.github.io/keycloakify-demo-app/", "name": "keycloakify-demo-app", "version": "0.2.9", "description": "A demo project for keycloakify",