Skip to content

Contributing

Thibault Milan edited this page Apr 4, 2019 · 1 revision

Developpers, you're welcome !

If you want to develop with us, let's take that repository and type:

make dev

That will use docker-compose to build images and start containers. Your uid:gid is written in a base compose file named .user.compose.yml to bind them inside the containers, to not have any rights problems when process writes files.

You may visit http://localhost:8080 to navigate application.

Important Because you probably want to be able to work in another directory than inside the GOPATH, you can use go-switch tool https://github.com/metal3d/goswitch

Using GoSwitch

Install Goswitch and prepare environment to use "activate" script. Goswitch is more or less an equivalent to "Python Virtualenv".

# Install goswitch once
bash <(curl -sSL https://raw.githubusercontent.com/metal3d/goswitch/master/install.sh)

# prepare the environment inside the project
cd /path/to/imannoate
goswitch local-project .

# be able to use real github paths
make virtualenv

# to activate the environment each time you want to develop, launch tests...
source bin/activate

Now, everythin will be installed inside pkg and src directories.

Or, create environment

If you want to make the environment by hand, do tha following:

cd /path/to/imannoate
goswitch local-project .
make virtualenv

Then, you need to change GOPATH and PATH each time you want to work in the project to avoid the installation outside the current project:

export GOPATH=$PWD:$GOPATH
export PATH=$PWD/bin:$PATH

Configure your IDE/Editor

Using an IDE other that "vim" (in the current terminal session), you should set environment:

  • GOPATH to imannotate directory + "src"
  • PATH to imannotate directory + "bin"

Use containers to install components

To simplify development:

  • each change in Golang sources rebuild API (using gin)
  • each change in Angular sources refreshes the view in browser (live-reload)

To enter inside a container:

# entering "ui" container where Angular resides
make enter ui
(here, you can use "ng" to create components, install packages...)


# entering "api" container where API resides
make enter api
(here you can use glide to install packages)

You may also use docker-compose to add Angular component, install packages, or Golang packages (with glide):

docker-compose -f docker-compose-dev.yaml exec ui ng g component src/app/components/myview --dry-run
docker-compose -f docker-compose-dev.yaml exec ui npm install --save-dev package/to/install
docker-compose -f docker-compose-dev.yaml exec api glide get github.com/package/to/vendor

Sometimes, gin doesn't want to rebuild the binary, so restart api container to fix:

docker-compose -f docker-compose-dev.yaml restart api