eNMS-automation / eNMS

An enterprise-grade vendor-agnostic network automation platform.
https://www.enms.io/
GNU General Public License v3.0
814 stars 162 forks source link

docker changes for gotty and optional new folder structure #121

Closed jmcgrath207 closed 3 years ago

jmcgrath207 commented 5 years ago

Hi afourmy,

I have been running the git checkout V3.6 in Docker, and I found some issues with gotty not working correctly and also have some possible improvements for docker folder structure in the repo.

I am willing to submit a pull request with the changes, after you get a chance to review this.

docker changes for gotty

The first issue is with the DockerFile itself. I had to add the following commands:

RUN apt-get install -y sshpass
RUN chmod 755 /eNMS/applications/gotty

sshpass is not on the container and is needed for gotty to run along with the permission change to itself.

The next issue I had was that gotty dynamically generates ports from TCP 9000 and up.

Unfortunately, Docker can't do this without using the host’s networking directly. Here is a example what I had to do.

version: '3'
services:
  db:
    restart: always
    image: postgres:latest
    env_file: .env-pgsql
    network_mode: "host"
    expose:
      - 5432
  webapp:
    restart: always
    env_file: .env
    build: .
    network_mode: "host"
    extra_hosts:
      - "db:127.0.0.1"
    ports:
      - "5000:5000"
    depends_on:
      - db
  nginx:
    restart: always
    image: nginx:latest
    network_mode: "host"
    ports:
      - "80:80"
    volumes:
      - ./nginx:/etc/nginx/conf.d
    depends_on:
      - webapp

With these we can connect with gotty once we do a manual connection to accept the rsa key.

The last change for this would be adding the docker container to the .travis.yml for testing.

optional new folder structure

I also wanted to change the layout of by keeping all the docker stuff in one folder. Similar to this picture image

In this case I changed the container enms to webapp because in the .env file I added this line COMPOSE_PROJECT_NAME=enms so the names would look like enms_webapp_1',enms_db_1`, etc. when you do a docker ps.

Finally, I also created a dev and prod compose file. The only different is dev compose file with the different being we mount the enms libary into the site packages directly so live edits can be preformed and has vim installed

example:

    volumes:
      - ../eNMS:/usr/local/lib/python3.6/site-packages/eNMS
afourmy commented 5 years ago

Hello @jmcgrath207 Yes I am aware that gotty doesn't work with Docker. I tried to fix it but couldn't make it work (I wasn't aware of this network_mode: host option). If you managed to fix it, you're welcome to submit a PR :) You can also change the folder structure if you want.

Thanks !

afourmy commented 3 years ago

docker support was removed so this is no longer relevant