reactioncommerce/reaction-next-starterkit

Name: reaction-next-starterkit

Owner: Reaction Commerce

Description: null

Created: 2018-04-03 21:50:03.0

Updated: 2018-05-24 08:49:11.0

Pushed: 2018-05-24 16:42:54.0

Homepage: null

Size: 2287

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Reaction Storefront Next.js Starter Kit

Note: This project is a work in progress and should not be used in production at this time.

Reference Storefront application for Reaction Commerce.

Getting Started

Follow steps as necessary. If you already have Reaction installed, you may be able to skip some of these steps.

  1. Prerequesites

  2. Install Docker and Docker Compose. Docker Compose is included when installing Docker on Mac and Windows, but will need to be installed separately on Linux.

  3. Clone the main Reaction repo and checkout the release-1.12.0 branch

    clone git@github.com:reactioncommerce/reaction.git
    eaction
    checkout release-1.12.0
    
    ange directory to the parent of your reaction install
    .
    
  4. Clone this repo

    clone git@github.com:reactioncommerce/reaction-next-starterkit.git
    
  5. Create a local docker network

    You'll need to create a docker network for the GraphQL service and the Reaction Storefront to communicate

    er network create reaction-api
    

    You can run docker network ls to verify the network has been created.

  6. Start Reaction's GraphQL server From your reaction directory run

    er-compose up -d --build
    

    You'll need to run the full app at least once in order for step 5 to work. After this initial run, if you don't want to start the Reaction Meteor app, you can just run docker-compose up -d devserver

  7. Generate a Meteor login token

    This process will be eliminated once we've built out the GraphQL API for authentication

    • Visit the Reaction Meteor shop localhost:3000
    • Open devtools and copy the Meteor.loginToken from localStorage.
  8. Setup the Storefront environment

    Navigate to the reaction-next-starterkit directory and create a .env file.

    env.example .env
    
  9. Start the storefront application in development mode using Docker Compose

    er-compose up -d --build
    
  10. Visit the storefront on localhost:4000

Development
Build and run in development mode with logs
er-compose up -d && docker-compose logs -f
Running Commands inside the container
er-compose run --rm web [command]

Run any command inside a Docker container and then remove the container. Use this to run any tooling operations. Remember your project directory will be mounted and things will usually just work.

Running Tests in Container

Run tests locally

er-compose run --rm web yarn test

Run tests locally without cache (this can be helpful if changes aren't showing up)

er-compose run --rm web yarn test --no-cache

To update a failing snapshot (if you've made changes to a component)

er-compose run --rm web yarn test -u

To run snyk security tests (this will run tests in the same way as CI)

er-compose run --rm web sh -c "cp package.json ../ && cp .snyk ../ && cd .. && snyk auth && snyk test"

To run eslint

er-compose run --rm web eslint src
Yarn Commands

Yarn & NPM should run inside the Docker container. We've taken steps to ensure that the node_modules are placed into a cacheable location. If you run Yarn locally, the node_modules are written directly to the project directory and take precedence over those from the Docker build. Yarn Add

er-compose run --rm web yarn add --dev [package]

Yarn Install

?? Always rebuild the image and start a new container after modifying yarn.lock or Dockerfile!

er-compose run --rm web yarn install
er-compose down --rmi local
er-compose up -d --build
Cleanup Containers

Stop, and retain containers:

er-compose stop

Stop, and remove containers:

er-compose down

Stop, and remove containers, volumes and built images:

er-compose down -v --rmi local
Production

Running the command below will build the starterkit for production.

er build -t reaction-storefront --build-arg BUILD_ENV=production .

To start the app in production mode execute:

er run -d --name storefront -p ${port}:4000 --env-file .env --network reaction-api reaction-storefront

To stop the docker container after starting it with the above command

er stop storefront

NOTE: Replace the ${port} with the localhost port you'd like the application to run at. I'm partial to 4040 NOTE: The above command is assuming ether the devserver or reaction is also running.

Documentation

See our full documentation

Features

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.