Skip to content
Catalog service repo - this is part of the larger ACME fitness application
Go Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images
.gitignore
Dockerfile
README.md
db.go
go.mod
go.sum
main.go
products.json
service.go

README.md

catalogsvc

Getting Started

These instructions will allow you to run catalog service

Requirements

Go (golang) : 1.11.2

mongodb as docker container

zipkin as docker container (optional)

Instructions

  1. Clone this repository

  2. You will notice the following directory structure

├── db.go
├── go.mod
├── go.sum
├── images
│   ├── catsocks_1.jpg
│   ├── cross_1.jpeg
│   ├── product2.jpg
│   ├── puma_1.jpeg
│   ├── slide1.jpg
│   ├── weave1.jpg
│   └── youtube_1.jpeg
├── main.go
├── products.json
├── README.md
└── service.go

  1. Set GOPATH appropriately as per the documentation - https://github.com/golang/go/wiki/SettingGOPATH

  2. Build the go application from the root of the folder

go build -o bin/catalog

  1. Run a mongodb docker container

sudo docker run -d -p 27017:27017 --name mgo -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo

  1. Execute this command to import the products.json file

    sudo docker cp products.json {mongodb_container_id}:/

  2. Login into the mongodb container

    sudo docker exec -it {mongodb_container_id} bash

  3. Import the products file into the database

    mongoimport --db catalog --collection products --file products.json -u mongoadmin -p secret --authenticationDatabase=admin

  4. Export CATALOG_IP/CATALOG_PORT (port and ip) as ENV variable. You may choose any used port as per your environment setup.

    export CATALOG_IP=0.0.0.0 export CATALOG_PORT=:8087

  5. Also, export ENV variables related to the database

    export CATALOG_DB_USER=mongoadmin
    export CATALOG_DB_SECRET=secret
    export CATALOG_DB_IP=0.0.0.0
    
  6. Run the catalog service

./bin/catalog

Additional Info

You can’t perform that action at this time.