Skip to content

Commit

Permalink
Close #4472
Browse files Browse the repository at this point in the history
  • Loading branch information
francbartoli committed Jun 12, 2019
1 parent c815569 commit 115f1fd
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 78 deletions.
1 change: 0 additions & 1 deletion docker-compose-geoserver-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ services:
depends_on:
- data-dir-conf
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.async.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ services:
- rabbitmq
# command: celery worker --app=geonode.celery_app:app -B -l INFO
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
env_file:
Expand All @@ -74,7 +73,6 @@ services:
- rabbitmq
- data-dir-conf
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env
Expand All @@ -96,7 +94,6 @@ services:
# command: paver start_django -b 0.0.0.0:8000
# command: uwsgi --ini uwsgi.ini
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
env_file:
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ services:
- db
- data-dir-conf
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/production/geoserver.env
Expand All @@ -49,7 +48,6 @@ services:
# command: paver start_django -b 0.0.0.0:8000
# command: uwsgi --ini uwsgi.ini
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
env_file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ services:
- elasticsearch
- rabbitmq
command: django-admin.py runserver 0.0.0.0:8000 --settings=geonode.settings
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- GEONODE_INSTANCE_NAME=geonode
- GEONODE_LB_HOST_IP=<host-server-public-ip>
Expand Down Expand Up @@ -98,8 +96,6 @@ services:
- elasticsearch
- rabbitmq
command: celery worker --app=geonode.celery_app:app -B -l INFO
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- GEONODE_INSTANCE_NAME=geonode
- GEONODE_LB_HOST_IP=<host-server-public-ip>
Expand Down Expand Up @@ -136,7 +132,6 @@ services:
depends_on:
- db
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- geoserver-data-dir:/geoserver_data/data
environment:
- GEONODE_LB_HOST_IP=<host-server-public-ip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,13 @@ Launch the stack with the build of GeoNode so any changes you did will be immedi
.. note::
**docker-compose.override.localhost.yml** contains environment variables to allow you run the instances on *localhost*. You can use this file as template in order to run on other public addresses.

.. note::
**For Windows users**: In case you're using the native Docker for Windows (on Hyper-V) you will probably be affected by an error related to mounting the /var/run/docker.sock volume. It's due to a `problem with the current version of Docker Compose <https://github.com/docker/for-win/issues/1829>`_ for Windows.
In this case you need to set the **COMPOSE_CONVERT_WINDOWS_PATHS** environmental variable:

.. code-block:: none

set COMPOSE_CONVERT_WINDOWS_PATHS=1

before running docker-compose up

Running GeoNode stack on docker ip address
==========================================

If you want to navigate the application from the address of the Docker socket than run simply::

docker-compose up --build

.. note::
**For Windows users**: In case you're using the native Docker for Windows (on Hyper-V) you will probably be affected by an error related to mounting the /var/run/docker.sock volume. It's due to a `problem with the current version of Docker Compose <https://github.com/docker/for-win/issues/1829>`_ for Windows.
In this case you need to set the **COMPOSE_CONVERT_WINDOWS_PATHS** environmental variable:

.. code-block:: none

set COMPOSE_CONVERT_WINDOWS_PATHS=1

before running docker-compose up

GeoNode will be available at the ip address of the ``docker0`` interface::

ifconfig -a
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Several options will be shown to decide what kind of machine driver is going to

sudo docker run -e CATTLE_AGENT_IP="<host-server-public-ip>" -e CATTLE_HOST_LABELS='geonodehost=<host label value>' --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.9 http://<rancher-server-ip>:8080/v1/scripts/<registrationToken>
# sudo can be avoided if the user has been privileged

6. Click on the **Close** button.

After some minutes the new host should be registered and available in the active status under the menu **Infrastructure** => **Hosts**.
Expand Down
48 changes: 2 additions & 46 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import re
import ast

import docker

from invoke import task

BOOTSTRAP_IMAGE_CHEIP = 'codenvy/che-ip:nightly'
Expand Down Expand Up @@ -117,41 +115,6 @@ def initialized(ctx):
ctx.run('date > /mnt/volumes/statics/geonode_init.lock')


def _docker_host_ip():
client = docker.from_env(version='1.24')
ip_list = client.containers.run(BOOTSTRAP_IMAGE_CHEIP,
network_mode='host'
).split("\n")
if len(ip_list) > 1:
print("Docker daemon is running on more than one \
address {0}".format(ip_list))
print("Only the first address:{0} will be returned!".format(
ip_list[0]
))
else:
print("Docker daemon is running at the following \
address {0}".format(ip_list[0]))
return ip_list[0]


def _container_exposed_port(component, instname):
client = docker.from_env(version='1.24')
try:
ports_dict = json.dumps(
[c.attrs['Config']['ExposedPorts'] for c in client.containers.list(
filters={
'label': 'org.geonode.component={0}'.format(component),
'status': 'running'
}
) if '{0}'.format(instname) in c.name][0]
)
for key in json.loads(ports_dict):
port = re.split('/tcp', key)[0]
except BaseException:
port = 80
return port


def _update_db_connstring():
user = os.getenv('GEONODE_DATABASE', 'geonode')
pwd = os.getenv('GEONODE_DATABASE_PASSWORD', 'geonode')
Expand Down Expand Up @@ -182,19 +145,12 @@ def _localsettings():


def _geonode_public_host_ip():
gn_pub_hostip = os.getenv('GEONODE_LB_HOST_IP', '')
if not gn_pub_hostip:
gn_pub_hostip = _docker_host_ip()
gn_pub_hostip = os.getenv('GEONODE_LB_HOST_IP', 'localhost')
return gn_pub_hostip


def _geonode_public_port():
gn_pub_port = os.getenv('GEONODE_LB_PORT', '')
if not gn_pub_port:
gn_pub_port = _container_exposed_port(
'nginx',
os.getenv('GEONODE_INSTANCE_NAME', 'geonode')
)
gn_pub_port = os.getenv('GEONODE_LB_PORT', '80')
return gn_pub_port


Expand Down

0 comments on commit 115f1fd

Please sign in to comment.