Code Monkey home page Code Monkey logo

createreactapp-docker's Introduction

Create React App run with Docker on AWS Elastic Beanstalk

Build Status

Basic Create React App with Docker, Travis CI and AWS Elastic Beanstalk for CI/CD and hosting.

Development

Build with Docker CLI

$ docker build -f Dockerfile.dev

Run with Docker CLI

$ docker run -it -p 3000:3000 <container_id>

Run with Docker CLI and Docker Volumes

$ docker run -it -p 3000:3000 -v /app/node_modules -v $(pwd):/app <container_id>

This will put a bookmark on the node_modules folder (won't map it to anything else), map the /app folder in the container to the current directory (watch for updates). Therefore, you can make use of hot reload for changes in app.

Run React Test Cases with Docker CLI

$ docker run -it <container_id> npm run test

Build and Run with Docker Compose

$ docker-compose up

Rebuild and Run with Docker Compose

$ docker-compose down && docker-compose up --build

Run React Test Cases with Docker Compose (Not Best Approach)

$ docker-compose up
$ docker exec -it <container_id> npm run test

Production

Build with Docker CLI

$ docker build .

Run with Docker CLI

$ docker run -p 8080:80 <container_id>

NOTE: nginx default port is 80

Setup for CI/CD and Deployment to AWS

AWS ElasticBeanstalk

Create a new application and environment with any name.

Select 'Docker' as the Platform.

Select 'Sample application' for Application Code.

Travis CI

Make sure that your GitHub repository is public, and that Travis CI is configured to access it.

Create the following environment variables:

  • AWS_ACCESS_KEY -> Your AWS IAM Access Key with permissions for Elastic Beanstalk
  • AWS_SECRET_KEY -> Your AWS IAM Secret Key with permissions for Elastic Beanstalk
  • AWS_REGION -> Region of your AWS Elastic Beanstalk application
  • AWS_APP_NAME -> AWS Elastic Beanstalk application name
  • AWS_ENV_NAME -> AWS Elastic Beanstalk environment name
  • AWS_BUCKET_NAME -> AWS S3 bucket name where application is stored (check logs when environment is created for name)
  • AWS_BUCKET_PATH -> The folder in the AWS S3 holder your application (usually the same as AWS_APP_NAME)

NOTE: Deployment to AWS is only triggered when a pull request or commit is made to master branch on GitHub

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.