Giter Site home page Giter Site logo

falx / docker-nginx-spa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from socialengine/docker-nginx-spa

0.0 0.0 0.0 12 KB

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.

Shell 27.41% Dockerfile 72.59%

docker-nginx-spa's Introduction

docker pull tdupont/nginx-spa

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.

Supported tags and Dockerfile links

Included on top of base nginx image

App Setup

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 tdupont/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.

Env Config

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 create a config.js file, which you can then add to your index.html, or load asynchronously. The path can be controlled with CONFIG_FILE_PATH environmental variable.

The filename can be controller with CONFIG_FILE_NAME environment variable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.