react-slingshot
react-slingshot copied to clipboard
Dotenv-webpack and Docker support
This PR attempts to make React Slingshot more versatile when dealing with continuous integration. It accomplishes this in the following ways:
- Adds dotenv support via dotenv-webpack.
- Adds Docker support for containerization.
To support dotenv-webpack the following had to be adjusted:
- An
.env
file is created (with values) from.env.template
onnpm run setup
. - Created
config/configurationApp.js
file to make configuration easier. - Added dotenv to
webpack.config.dev.js
andwebpack.config.prod.js
. System variables will trump anything local per dotenv specs. (this is important for CI). - Refactored
npm start
to start development or production build per NODE_ENV. Executestools/start.js
- Refactored
npm run build
to just compile/build thedist
folder. (This will be used for Docker support). - Refactored
npm run prestart
intonpm start
. Also, added a prompt for production build as well. - Updated documentation.
To support Docker the following had to be modified:
- Created
Dockerfile
which hosts thedist
folder via Nginx. - Created
nginx.template
which is copied to the Docker image's Nginx configuration directory. - 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
- 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.
Coverage remained the same at 91.453% when pulling 39c490975e2d3a43b30677bbc3fd7c7bc9e8bb18 on acmitch:master into 135abfa9981faf3acaddcdf15f47f476f226e0c3 on coryhouse:master.
@coryhouse is there an easy way to debug why AppVeyor is failing?
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.
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.