Public | Automated Build

Last pushed: a year ago
Short Description
Builds the postgres with store locator schema/data as default in image.
Full Description

Just Store Locator Endpoint

Setup the development environment

Running Locally

This endpoint is built on Node.js 5.4.1 and MYSQL 5.5 and is setup to be run on Docker containers. To run your development environment in a virtual Docker container you will need to install the Docker Toolbox.

Once Docker is installed you will need to build your docker containers:

docker-compose build

Once built, you can run the development environment with:

docker-compose up

The endpoint will be running on <your-docker-ip>:5000/

Initial database setup on production

To setup database, you need to run db/dev.sql on Postgres server; this file contains the schema. Do the following steps:

  • Able SSH connection on public EC2 server on AWS adding your IP address to allowed Inbound connections on RCSecurityGroup Security Group. To discover the IP use What Is My IP;

  • Get a SSH PEM key to connect directly on remote server;

  • Discover on AWS EC2 panel what is the public IP address from one of running Just servers;

  • Copy db/dev.sql to remote server:

      scp -i <just-ssh-pem-path> db/dev.sql ec2-user@<just-server-public-ip>:~/dev.sql
    
  • Connect to remote server:

      ssh -i <just-ssh-pem-path> ec2-user@<just-server-public-ip>
    
  • On remote server, check if Docker already have any Postgres images available:

      docker images
    
  • If Docker instance not contains a Postgres image, pull a new one:

      docker pull postgres:9.5
    
  • With a valid Postgres image on Docker, runs the following command to charge database (a password prompt will appear, fill it):

      docker run -it --rm -v $PWD:/sql postgres:9.5 psql -h <rds-host> -U <user> -W -d <database-name> -f /sql/dev.sql
    
  • To check schema, runs psql cli to do any queries you want:

      docker run -it --rm postgres:9.5 psql -h <rds-host> -U <user> -W -d <database-name>
    
  • Disconnect from server;

  • Remove your IP address from authorized Inbound connections from RCSecurityGroup Security Group

Docker Pull Command
Owner
workandco
Source Repository