✒️
poocho • documentation
  • Introduction
  • Basics
    • To Do
    • Logins
    • Table of Contents
  • Useful Commands
  • Environments
    • Local Environment Setup
      • macOS setup
      • Routes
    • Remote Server Setup
      • Server Setup
      • Client Environment
    • AWS Cognito Setup
    • Dockerhub
  • Server Info
    • Application
      • ** NATS
      • Dependencies
      • Main Stack
    • Server Information
      • Continuous Integration
      • Servers
        • Amazon Web Services
        • Digital Ocean
      • Code Repositories
      • Domains In Use
      • Email Settings
      • Domain Hosts & Registration
        • Domain Registrar (NameCheap)
        • DNS Host (Cloudflare)
        • Email (Gsuite)
    • External Services
      • Landbot.io
      • Flow.ai
    • Amazon Web Services (AWS)
      • AWS EC2/EBS
      • AWS Simple Email Service
      • AWS Cognito (v2)
      • AWS Cognito
      • AWS Lightsail
      • AWS Route 53
  • Code & Documentation
    • Client
    • Functions
    • Server
Powered by GitBook
On this page
  • Instructions
  • Navigate to Root Directory
  • Start Local Environment
  • Setup Local Database
  • Start local

Was this helpful?

  1. Environments
  2. Local Environment Setup

macOS setup

PreviousLocal Environment SetupNextRoutes

Last updated 5 years ago

Was this helpful?

Instructions

  • Install and make sure it is up to date.

  • Clone the repo with git clone https://github.com/yalefox/poocho-messenger

  • Open terminal and navigate to the root of the repo.

  • Make sure Docker is open.

  • Run docker swarm init (Note: this only needs to be run the first time

Swarm initialized: current node (kfgchus63c3b6ew9nyrx93gya) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-41k14i127ao4m6ncj6mmu5bq4w3mqvirdl8igb417wn4v5wlez-5q0rfq8bc7qh6gdjmr654fiw1 192.168.65.3:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

Most applications using docker are in a single container. Poocho messenger has a number of different containers that need to be running at the same time. The swarm is always running, if you need to get rid of it, run docker swarm leave --force

  • Run cd client to navigate to /client directory.

  • Create a local environment file with sudo nano .env

  • Paste the following, save and exit.

REACT_APP_NATS_HOST = localhost:4222
REACT_APP_API_URL = http://localhost:5050
REACT_APP_AWS_REGION=us-east-1
REACT_APP_AWS_POOL_ID=us-east-1_Qccxby2tn
REACT_APP_AWS_CLIENT_ID=5foo8qktllsqfd8c91kh7bq8i6
REACT_APP_AWS_POOL_DOMAIN=poochodemo.auth.us-east-1.amazoncognito.com
REACT_APP_AWS_POOL_CALLBACK_URL=http://localhost

Some of the variables above come from AWS Cognito.

Navigate to Root Directory

  • Navigate to the root folder of the project.

  • Create a new local environment file with sudo nano .env

POSTGRES_HOST=messages-db
POSTGRES_USER=postgres
POSTGRES_PASS=postgres
POSTGRES_DB=underdog
AWS_REGION=us-east-1
AWS_POOL_ID=us-east-1_Qccxby2tn
AWS_CLIENT_ID=5foo8qktllsqfd8c91kh7bq8i6
NATS_URL=nats://nats:4222
API_PORT=5050

Start Local Environment

  • Build Docker Images and run services with sh build.sh

    • The first time you run this will take some time, it took 3 minutes and 45 seconds on my local.

Setup Local Database

  • Open a new terminal window and run:

PG_CONTAINER_ID=$(docker ps --filter name=messages-db --format "{{.ID}}")
docker exec -ti $PG_CONTAINER_ID psql -U postgres -c "CREATE DATABASE underdog;"
docker service update --force underdog_apis
CREATE DATABASE
underdog_apis
overall progress: 1 out of 1 tasks 
1/1: running   [==================================================>] 
verify: Service converged 

Start local

  • Open your browser to http://localhost and you should see the following page.

You will see a message that looks like this:

Docker
https://dog.under.wtf/v1urQ1Gz
First run of build script