react-slingshot icon indicating copy to clipboard operation
react-slingshot copied to clipboard

Dotenv-webpack and Docker support

Open acmitch opened this issue 5 years ago • 4 comments

This PR attempts to make React Slingshot more versatile when dealing with continuous integration. It accomplishes this in the following ways:

  1. Adds dotenv support via dotenv-webpack.
  2. Adds Docker support for containerization.

To support dotenv-webpack the following had to be adjusted:

  1. An .env file is created (with values) from .env.template on npm run setup.
  2. Created config/configurationApp.js file to make configuration easier.
  3. Added dotenv to webpack.config.dev.js and webpack.config.prod.js. System variables will trump anything local per dotenv specs. (this is important for CI).
  4. Refactored npm start to start development or production build per NODE_ENV. Executes tools/start.js
  5. Refactored npm run build to just compile/build the dist folder. (This will be used for Docker support).
  6. Refactored npm run prestart into npm start. Also, added a prompt for production build as well.
  7. Updated documentation.

To support Docker the following had to be modified:

  1. Created Dockerfile which hosts the dist folder via Nginx.
  2. Created nginx.template which is copied to the Docker image's Nginx configuration directory.
  3. Added npm commands:
    • npm start docker:up - Build the dist folder, build the docker image, and start the docker container
    • npm start docker:down - Stop the docker container, delete the docker container, delete the docker image
  4. Updated documentation.

Overall, I think this PR is a good "first step" in giving developers an easier CI experience.

Please clone and try to break these changes. Specifically: - The npm start command, (first time I've used execSync) - Docker up and down commands (might break on Windows).

If accepted, this PR might be worth including in a major release, due to the npm commands changing functionality.

acmitch avatar Oct 14 '18 16:10 acmitch

Coverage Status

Coverage remained the same at 91.453% when pulling 39c490975e2d3a43b30677bbc3fd7c7bc9e8bb18 on acmitch:master into 135abfa9981faf3acaddcdf15f47f476f226e0c3 on coryhouse:master.

coveralls avatar Oct 14 '18 16:10 coveralls

@coryhouse is there an easy way to debug why AppVeyor is failing?

acmitch avatar Oct 14 '18 17:10 acmitch

Thanks for your help on this! The AppVeyor issue has been going on for awhile. It's not your fault. We just need to disable the runs for older versions of Node since Yarn doesn't support them per the error message I'm seeing.

Sorry, I'm really buried at the moment (trying to finish a new course) so I can't dig into this yet to vet it. My apologies.

coryhouse avatar Oct 16 '18 03:10 coryhouse

Sorry for the delay on this @acmitch. Just following up on this PR. The AppVeyor issues should be fine now, but there's some file conflicts that need to be resolved. It'd be great to take this PR for a spin in Docker once the conflicts are sorted out.

nickytonline avatar May 07 '19 03:05 nickytonline