Skip to content

Installation

Marcel Zúbrik edited this page Feb 6, 2024 · 13 revisions

Home

Installation options

  1. npm - your own project. This is quick and easy way to create development environment for your own e-shop project, with demo data - so you can try it in minutes.
  2. Docker - latest StretchShop container for quick demo or if you don't need customization.
  3. Git - for contributors and everyone who like to see the code.

If you prefer video over text, this one describes the NPM installation:

StretchShop Installation

Visit StretchShop Youtube Channel to see more https://www.youtube.com/channel/UCWge8fht1i0Wp0q2g9q2t6Q

NPM

Before trying to run app using npm, make sure you have:

  1. Node.js with npm installed (https://nodejs.org/en/download/)
  2. MongoDB running - if you have docker, you can get it running using this docker container run -d -p 27017:27017 --name mongo mongo.

Note: This NPM setup is for development and demo purposes.

Once you have all that's required

  1. In terminal (that command line tool that you should know, go to your working directory, where you want to have your project.
  2. In terminal run npm i stretchshop.

This should install latest stretchshop and create your own project in your directory based on it and get you the latest resources. Ready to start ... if you have data.

To Run with the Demo data

1. Get demo data

To get demo data, run this after installation was done (in the same directory):

node node_modules/stretchshop/demo/repo/db/demo_data.js

If your MongoDB requires authentication, you can add 2 more parameters with name and password for your MongoDB connection:

node node_modules/stretchshop/demo/repo/db/demo_data.js username password

Note: Demo is trying to access MongoDB on using DEFAULT authMechanism and authSource in admin database.

2. Run on localhost port 3000

After you have Demo data successfully installed, run it with:

npm run dev

Now you should be able to view Demo version of StretchShop on http:https://localhost:3000 .

Possible issues

  • Don't have required permissions - If you don't have required permissions on your work computer, ask administrator to get them. If you don't have required permissions on servers, don't get them - this NPM setup is not for test, stage or production (use Docker for that).
  • No MongoDB connection. Check if MongoDB is correctly installed, running on port 27017. If your MongoDB requires authentication, edit your .env file.

Docker

Before trying to run app from docker image, make sure you have:

  • Docker and docker-compose installed
  • for production, you need - web-server installed (eg. nginx or apache) and running
  • firewall with port 80 allowed.

Note: You can run it even without web-server and firewall just with docker, but it will run on port 3000. That's fine if you want to try it on localhost https://localhost:3000 .

With Docker Compose

  1. download YAML docker-compose.yml
  2. download ENV docker-compose.env
  3. and run docker-compose up to get StretchShop in very basic form without data and custom resources.
  4. see it on http:https://localhost:3000 .

With containers

  1. Install Docker if not installed.
  2. In terminal run docker pull mongo:latest to get MongoDB container.
  3. docker container run -d -p 27017:27017 --name mongo mongo to run it. It's not running on port 27017, added to Docker's default bridge network and available from 172.17.0.2:27017 .
  4. docker pull wradgio/stretchshop:latest to get latest StretchShop container.
  5. Before we can let StretchShop run, we have to direct it to environment file. You can get one from StretchShop repo using curl -o .env https://raw.githubusercontent.com/StretchShop/StretchShop/master/docker/mono/docker-compose.env and update it like this:
    1. comment row with TRANSPORTER so it looks like this: #TRANSPORTER=nats:https://yourNATSname:yourNATSpassword@nats-server:4222
    2. update the row with MONGO_URI to use bridge network IP mentioned before, should look like this: MONGO_URI=mongodb:https://localhost:27017/stretchshop_demo
  6. sudo docker container run -p 3000:3000 --env-file .env --rm --name stretchshop-test wradgio/stretchshop:latest to run StretchShop in very basic form without data and custom resources.
  7. see it on http:https://localhost:3000 .

Git

  1. Create directory and clone GitHub repository there $ git clone https://github.com/StretchShop/StretchShop.git . (notice dot).
  2. run $ npm install to install required libraries.
  3. npm run dev