A fork of SocialEngine/nginx-spa that sends env-vars in a cookie.
5.2K
Disclaimer: this is a fork of the brilliant SocialEngine/docker-nginx-spa. This fork does send the env configuration via a cookie, not per file. Do not use paths that contain a "." in the topmost directory (e.g. do not use "socialnetwork.com/tom.tallis" but "/u/tom.tallis")
This is a Docker image used to serve a Single Page App (pure frontend javascript) using nginx, it support PushState, and includes a way to pass configuration at run time.
Dockerfile links/app/index.html. Useful for the clean urls (no !#)This docker image is built for index.html file being in the /app directory. pushState is enabled.
At a minimum, you will want this in your Dockerfile:
FROM skn0tt/nginx-spa
COPY build/ /app
COPY index.html /app/index.html
Then you can build & run your app in the docker container. It will be served by a nginx static server.
$ docker build -t your-app-image .
$ docker run -e API_KEY=yourkey -e API_URL=http://myapi.example.com \
-e CONFIG_VARS=API_URL,API_KEY -p 8000:80 your-app-image
You can then go to http://docker-ip:8000/ to see it in action.
Included is ability to pass run time environmental variables to your app.
This is very useful in case your API is on a different domain, or if you want to configure central error logging.
$ docker run -e RAVEN_DSN=yourkey -e API_URL=http://myapi.example.com \
-e CONFIG_VARS=API_URL,RAVEN_DSN -p 8000:80 socialengine/nginx-spa:latest
==> Writing /app/config.js with {"RAVEN_DSN":"yourkey", "API_URL":"http://myapi.example.com"}
This will send a _config-Cookie with the files, which you can then read in your JS.
The cookie name can be controlled with CONFIG_COOKIE environmental variable.
Content type
Image
Digest
Size
44.1 MB
Last updated
almost 8 years ago
docker pull skn0tt/nginx-spa