Code Monkey home page Code Monkey logo

orchestrating-app's Introduction

Orchestrating React apps and back-ends in a development environment

This repository stores the example source code and presentation source code for a presentation with the above title, to be given on September 6, 2018 at the React NYC Meetup.

Description

This talk will highlight some patterns to help the development environment mirror the production environment by using containers and a reverse proxy image to manage local traffic on a single localhost port. In order to maintain a usable and flexible development environment, this talk will also highlight how to incorporate webpack 4, webpack-serve, and hot module replacement in this environment.

Presentation

The presentation is built with hovercraft, and relies on plantuml for diagrams.

CORS Example

This example highlights the CORS issues found when working with traditional web applications; configuring CORS may be the answer, if multiple origins are the intended setup. Alternatively, create-react-app has a built-in proxy feature.

Working Example

This example has been built and tested on a Linux Mint machine, as well as on Mac OSX High Sierra. It's likely that this example should also work on Windows with similar Docker and docker-compose versions.

Prerequisites

  • Install Docker CE and compose
  • On Mac, install Docker for Mac (edge), which includes both.

On both platforms, these were the tested versions:

docker --version
Docker version 18.06.1-ce, build e68fc7a
docker-compose --version
docker-compose version 1.22.0, build f46880f

This should provide a feasible hot-reloaded front-end development environment under the app/ directory.

Running the working-example

cd working-example
docker-compose build
docker-compose up

... in another shell session (you only have to do this the first time you build)

cd working-example

# Run a bash session within the api container
docker-compose exec api bash

# ... while in the container itself
./node_modules/.bin/sequelize db:migrate
# ... exit the container & bash session

With the database created, the app should be loadable in the browser at http://localhost/app. Any changes made to the database should now be persisted under api_db/postgres/local_data, which means that the containers can be created and destroyed at will.

E.g.:

# Remove all containers & volumes
docker-compose rm -v
# ... say Y

# then create & run the containers again
docker-compose up

Clean up the example

If you want to clean up docker containers/images/volumes in one command, look into docker-compose down --help.

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.