Giter VIP home page Giter VIP logo

cra-docker's Introduction

cra-docker

Create statically built Create React App applications docker images for easy deployment with environment variables support at runtime.

This project was created to solve known problem with CRA in favor of 12 factor apps. See facebook/create-react-app#2353

Usage

All you need to do is get the content of built app (build folder) inside docker image in /app folder.

To get this working firstly create Dockerfile in your project root with content:

FROM inloopx/cra-docker

COPY build /app

then you can call:

# or npm run build
yarn build
docker build -t my-new-app .

Once the build is done, you should have your image ready. To verify it, run the image bind to 8080 port:

docker run --rm -p 8080:80 my-new-app

Now if you open http://localhost:8080 You should see your app.

You can find more in example directory. Also if you use gitlab, don't miss the pipeline configuration file example

cra-docker's People

Contributors

jakubknejzlik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cra-docker's Issues

Question around dynamic env variables

I would like to understand a bit more how I can read dynamic variables from window.ENV when I serve my app through your docker image. I don't quite get how the env.js file is injected / read by the app. Do I have to modify my index.html for it to work?

Sorry if this is obvious, but it was not clear to me from the README.

Thank you

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.