-
On your remote machine, execute the instructions from the Deploy section above.
-
On remote, setup the following env variables:
# edit and replace any env variable's value, based on your needs # or feel free to use the defaults # if a dir specified as a value doesn't exist then create it before setting the env variables export MASTER_DEV_HOME=`echo ~/dev` export SYNC_DEV_HOME=`echo ~/Dropbox/remote-dev` export WAREHOUSE_PROJECT_NAME=warehouse-1 export WAREHOUSE_SYNC_DIR_NAME=`echo $WAREHOUSE_PROJECT_NAME.sync` export WAREHOUSE_HOME=`echo $MASTER_DEV_HOME/$WAREHOUSE_PROJECT_NAME` # spit out and confirm the values for all of the following before proceeding echo MASTER_DEV_HOME=$MASTER_DEV_HOME && \ echo WAREHOUSE_PROJECT_NAME=$WAREHOUSE_PROJECT_NAME && \ echo MASTER_DEV_HOME + WAREHOUSE_PROJECT_NAME = WAREHOUSE_HOME = $WAREHOUSE_HOME && \ echo SYNC_DEV_HOME=$SYNC_DEV_HOME && \ echo WAREHOUSE_SYNC_DIR_NAME=$WAREHOUSE_SYNC_DIR_NAME && \ echo SYNC_DEV_HOME + WAREHOUSE_SYNC_DIR_NAME = $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME
-
Optionally, you can create and save a
setenv_master.sh
file for reuse in future sessions but do not commit it:#!/bin/sh echo "###" echo Its best to invoke this script as: '. ./setenv_master.sh' rather than './setenv_master.sh' echo "###" export MASTER_DEV_HOME=`echo ~/dev` && \ export SYNC_DEV_HOME=`echo ~/Dropbox/remote-dev` && \ export WAREHOUSE_PROJECT_NAME=warehouse-1 && \ export WAREHOUSE_SYNC_DIR_NAME=`echo $WAREHOUSE_PROJECT_NAME.sync` && \ export WAREHOUSE_HOME=`echo $MASTER_DEV_HOME/$WAREHOUSE_PROJECT_NAME` && \ echo MASTER_DEV_HOME=$MASTER_DEV_HOME && \ echo WAREHOUSE_PROJECT_NAME=$WAREHOUSE_PROJECT_NAME && \ echo MASTER_DEV_HOME + WAREHOUSE_PROJECT_NAME = WAREHOUSE_HOME = $WAREHOUSE_HOME && \ echo SYNC_DEV_HOME=$SYNC_DEV_HOME && \ echo WAREHOUSE_SYNC_DIR_NAME=$WAREHOUSE_SYNC_DIR_NAME && \ echo SYNC_DEV_HOME + WAREHOUSE_SYNC_DIR_NAME = $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME
-
-
On remote, clone warehouse and any submodules
cd $MASTER_DEV_HOME && \ git clone --recursive [email protected]:ShoppinPal/warehouse.git $WAREHOUSE_PROJECT_NAME && \ cd $WAREHOUSE_HOME
-
On remote, before making our project sync-capable, let us add rules to prevent unnecessary stuff from syncing:
# change this according to your needs before running export WAREHOUSE_SYNC_DIR_NAME=warehouse-sync-pr-xxx && echo $WAREHOUSE_SYNC_DIR_NAME # run this as-is dropbox exclude add $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME/.git && \ dropbox exclude add $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME/node_modules && \ dropbox exclude add $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME/docker/volumes && \ dropbox exclude add $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME/warehouse-workers/.git && \ dropbox exclude add $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME/warehouse-workers/node_modules
-
On remote, check if they are now excluded, use
dropbox exclude list | grep remote-dev
- if an incorrect path was excluded, you can fix it with:
dropbox exclude remove /the/path
- for example, if you decide to sync the
.git
folder over to your local then un-exclude it with:dropbox exclude remove $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME/.git
- if an incorrect path was excluded, you can fix it with:
-
On remote, wire up your project root to be synced via Dropbox:
-
go to your WAREHOUSE_HOME:
cd $WAREHOUSE_HOME
-
then run the following command:
# make sure this is setup by printing it out echo WAREHOUSE_SYNC_DIR_NAME=$WAREHOUSE_SYNC_DIR_NAME # make sure this is setup by printing it out echo WAREHOUSE_HOME=$WAREHOUSE_HOME # then, run as-is cd $WAREHOUSE_HOME && \ ln -s `pwd` ~/Dropbox/remote-dev/$WAREHOUSE_SYNC_DIR_NAME
-
make sure it worked:
ls -alrt ~/Dropbox/remote-dev/
-
-
On remote, when you check the status via:
dropbox status
... you will see that the sync has begunSyncing (353 files remaining) Indexing 353 files...
-
Setup dropbox on local machine
-
On local, setup the following env variables:
# edit and replace any env variable's value, based on your needs # or feel free to use the defaults # if a dir specified as a value doesn't exist then create it before setting the env variables export SYNC_DEV_HOME=`echo ~/Dropbox/remote-dev` export WAREHOUSE_PROJECT_NAME=warehouse-1 export WAREHOUSE_SYNC_DIR_NAME=`echo $WAREHOUSE_PROJECT_NAME.sync` export SLAVE_WAREHOUSE_HOME=`echo $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME` # spit out and confirm the values for all of the following before proceeding echo SYNC_DEV_HOME=$SYNC_DEV_HOME && \ echo WAREHOUSE_PROJECT_NAME=$WAREHOUSE_PROJECT_NAME && \ echo WAREHOUSE_SYNC_DIR_NAME=$WAREHOUSE_SYNC_DIR_NAME && \ echo SLAVE_WAREHOUSE_HOME = $SLAVE_WAREHOUSE_HOME
-
Optionally, you can create and save a
setupenv_slave.sh
file for reuse in future sessions but do not commit it:#!/bin/sh echo "###" echo Its best to invoke this script as: '. ./setupenv_slave.sh' rather than './setupenv_slave.sh' echo "###" export SYNC_DEV_HOME=`echo ~/Dropbox/remote-dev` && \ export WAREHOUSE_PROJECT_NAME=warehouse-1 && \ export WAREHOUSE_SYNC_DIR_NAME=`echo $WAREHOUSE_PROJECT_NAME.sync` && \ export SLAVE_WAREHOUSE_HOME=`echo $SYNC_DEV_HOME/$WAREHOUSE_SYNC_DIR_NAME` && \ echo SYNC_DEV_HOME=$SYNC_DEV_HOME && \ echo WAREHOUSE_PROJECT_NAME=$WAREHOUSE_PROJECT_NAME && \ echo WAREHOUSE_SYNC_DIR_NAME=$WAREHOUSE_SYNC_DIR_NAME && \ echo SLAVE_WAREHOUSE_HOME = $SLAVE_WAREHOUSE_HOME
-
-
On local, Dropbox's autosync will create a directory and you can jump into it:
cd $SLAVE_WAREHOUSE_HOME
-
On local, open your favorite IDE and start working
- for example, visual studio can be opened with:
cd $SLAVE_WAREHOUSE_HOME && code .
- for example, visual studio can be opened with:
-
On master, create empty env files:
cd $WAREHOUSE_HOME && touch .env worker.env worker2.env
- run:
docker-compose run nodejs npm install inquirer --save-dev
- then run the command
npm run generate-env -e=terraform
for generating aterraform.tfvars
file.-
It will be used by terraform to generate queues in your AWS SQS infrastructure.
-
Run these commands:
# Tested with Terraform v0.10.8 as of this commit. # step 1 cd $WAREHOUSE_HOME/terraform/ # step 2 docker-compose run terraform init # step 3: used to download and update modules mentioned in the root module (main.tf). docker-compose run terraform get # step 4 docker-compose run terraform plan # step 5 docker-compose run terraform apply # step 6: to destroy your infrastructure! docker-compose run terraform destroy
-
Once terraform creates queues, the appropriate AWS_SQS_URL and AWS_SQS_REGION will be automatically added to your .env and worker.env files.
-
- then run the command
docker-compose run nodejs npm run generate-env -e=web
for configuring the remaining portions of.env
file for warehouse web service- It will ask you for the environment variables to be configured.
- Once done, it will generate files for you as per the values you specified.
- then run the command
docker-compose run nodejs npm run generate-env -e=worker
for configuring the remaining portions ofworker.env
for warehouse worker service. - then run the command
npm run generate-env -e=worker2
for configuring the remaining portions ofworker2.env
for warehouse worker2 service.
- run:
-
Fill in any remaining values that are empty in
.env
andworker.env
andworker2.env
files -
Open file
/etc/hosts
:sudo vim /etc/hosts
-
Append the following line
127.0.0.1 lb
-
-
To build and run, choose:
- background:
docker-compose up -d --build
- foreground:
docker-compose up --build
- background:
-
For local development, open application in your browser with url http://lb/