Running a local version of the API Using Docker

Cloning the Repo

git clone git@bitbucket.org:titanhousedev/titanhouse-api.git

Pull all Dependent Service Images

cd titanhouse-api/.bin && ./run-docker.sh pull

This will start downloading the images in the background. Note, there will be no output in the console until it is finished. If you are running in Windows, run the equivalent run-docker.cmd.

When the command has finished, you should have downloaded 3 images

  • elasticsearch 5.5.x
  • redis
  • postgress

You can double check this by running the docker images command to see a list of all existing images on your system

docker images
REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
redis                                           latest              1babb1dde7e1        3 days ago          94.9MB
postgres                                        latest              7a2907672aab        3 days ago          311MB
docker.elastic.co/elasticsearch/elasticsearch   5.5.3               60503d5b81fb        13 months ago       510MB

Setup your Local API Config

Go to the configuration directory for the api and create a local config. Note, the settings in the config file should match those of the environment variables andports that are defined in the docker-compose file for your dependent services (redis, postgres, elasticsearch)

cd titanhouse-api/cp-api/src/config/environment
cat << EOF >> local.js
export default {
  sequelize: {
    database: 'titanhouse',
    username: 'root',
    password: 't1t@nh0us&',
    options: {
      host: 'localhost',
      port: 5432,
      dialect: 'postgres',
      define: {
        timestamps: false,
        underscored: false,
      },
      logging: null,
    },
  },
  elastic: {
    apiVersion: '5.5',
    keepAlive: true,
    host: 'https://localhost:9200',
  },
  redis: {
    host: 'localhost',
  },
  log: 'info',
};
EOF

Starting the Local API Dependent Services Using Docker

The cmd below should start 5 containers on your system

  • 3 X elasticsearch
  • 1 X redis
  • 1 X postgres

# This will start the containers, detach from the stdout, and attach to the
# log output of the project. If at any point you want to stop tailing the logs,
# simply type `ctrl-c`s
./run-docker.sh up -d && ./run-docker.sh logs -tf

Stopping the Local API Dependent Services

./run-docker.sh stop

Restarting the Local API Dependent Services

./run-docker.sh restart

Installing all API Server Package Dependencies Using NPM

cd titanhouse-api && npm install

Starting the API Server With Node

cd titanhouse-api && npm start:debug

results matching ""

    No results matching ""