Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/docker network #777

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .env-jenkins-docker
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=localhost
POSTGRES_HOST=protectedplanet-db
POSTGRES_DBNAME=pp_development
POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology
REDIS_URL=redis://localhost:6379/0
ELASTIC_SEARCH_URL=http://elastic:elastic@localhost:9200
WEBPACKER_DEV_SERVER_HOST=localhost
REDIS_URL=redis://protectedplanet-redis:6379/0
ELASTIC_SEARCH_URL=http://elastic:elastic@protectedplanet-elasticsearch:9200
WEBPACKER_DEV_SERVER_HOST=protectedplanet-webpacker
xpack.security.enabled=false
discovery.type=single-node
RAILS_ENV=development
NODE_ENV=development
PP_HOST=localhost:3000

API_PATH=.
SSH_AUTH_SOCK=/ssh-agent
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pipeline {
def buildProject() {
sh 'echo "Building Project.............."'
sh "cp .env-jenkins-docker .env"
sh "docker-compose -f ${COMPOSE_FILE} --project-name=${JOB_NAME} build"
sh "docker-compose -f ${COMPOSE_FILE} --project-name=${JOB_NAME} build web db redis sidekiq elasticsearch kibana webpacker"
}

def prepare() {
Expand Down
55 changes: 41 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ services:
- protectedplanet_node_modules:/ProtectedPlanet/node_modules
- protectedplanet_import_data:/import_data
- protectedplanet_bundler:/usr/local/bundle
- ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}
network_mode: host
# - /run/host-services/ssh-auth.sock:/ssh-agent # Use this setting for Mac OS X and comment out ${SSH_AUTH_SOCK}:/ssh-agent below
- ${SSH_AUTH_SOCK}:/ssh-agent
ports:
- "3000:3000"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "3000" (without host port), so it won't conflict with host port. This is Jenkins test, no one will connect from the host.

networks:
- protectedplanet
environment:
- SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
- SSH_AUTH_SOCK=/ssh-agent
env_file:
- '.env'
depends_on:
Expand All @@ -25,7 +29,10 @@ services:
db:
container_name: protectedplanet-db
image: kartoza/postgis:11.5-2.5
network_mode: host
ports:
- "5432:5432"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "5432" (without host port), so it won't conflict with host port. This is Jenkins test, no one will connect from the host.

networks:
- protectedplanet
env_file:
- '.env'
volumes:
Expand All @@ -34,7 +41,10 @@ services:
redis:
container_name: protectedplanet-redis
image: redis
network_mode: host
ports:
- "6379:6379"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "6379" (without host port), so it won't conflict with host port. This is Jenkins test, no one will connect from the host.

networks:
- protectedplanet
env_file:
- '.env'
volumes:
Expand All @@ -45,7 +55,8 @@ services:
- .:/ProtectedPlanet
- protectedplanet_node_modules:/ProtectedPlanet/node_modules
- protectedplanet_import_data:/import_data
network_mode: host
networks:
- protectedplanet
depends_on:
- db
- redis
Expand All @@ -65,18 +76,24 @@ services:
memlock:
soft: -1
hard: -1
network_mode: host
ports:
- "9200:9200"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "9200" (without host port), so it won't conflict with host port. This is Jenkins test, no one will connect from the host.

networks:
- protectedplanet
env_file:
- '.env'
volumes:
- 'protectedplanet_es_data:/usr/share/elasticsearch/data'
kibana:
image: docker.elastic.co/kibana/kibana:8.6.0
environment:
- ELASTICSEARCH_HOSTS=http://localhost:9200
- ELASTICSEARCH_HOSTS=http://protectedplanet-elasticsearch:9200
env_file:
- '.env'
network_mode: host
ports:
- "5601:5601"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "5601" (without host port), so it won't conflict with host port. This is Jenkins test, no one will connect from the host.

networks:
- protectedplanet

webpacker:
container_name: protectedplanet-webpacker
Expand All @@ -88,19 +105,26 @@ services:
- .:/ProtectedPlanet
- protectedplanet_node_modules:/ProtectedPlanet/node_modules
- protectedplanet_bundler:/usr/local/bundle
network_mode: host
ports:
- "3035:3035"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "3035" (without host port), so it won't conflict with host port. This is Jenkins test, no one will connect from the host.

networks:
- protectedplanet

api:
container_name: protectedplanet-api
build:
context: ${API_PATH}
command: /bin/bash -l -c "bundle exec rackup"
command: /bin/bash -l -c "bundle exec rackup --host 0.0.0.0"
volumes:
- ${API_PATH}:/ProtectedPlanetApi
- ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}
network_mode: host
# - /run/host-services/ssh-auth.sock:/ssh-agent # Use this setting for Mac OS X and comment out ${SSH_AUTH_SOCK}:/ssh-agent below
- ${SSH_AUTH_SOCK}:/ssh-agent
ports:
- "9292:9292"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to "9292" (without host port), so it won't conflict with host port. This is Jenkins test, no one will connect from the host.

networks:
- protectedplanet
environment:
- SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
- SSH_AUTH_SOCK=/ssh-agent
env_file:
- ${API_PATH}/.env
depends_on:
Expand All @@ -109,6 +133,9 @@ services:
tty: true
profiles: ['api']

networks:
protectedplanet:
driver: bridge

volumes:
protectedplanet_pg_data:
Expand Down
10 changes: 9 additions & 1 deletion docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ docker exec -it protectedplanet-web rake search:reindex
## Step 5: API setup (optional)
The [Protected Planet API](https://github.com/unepwcmc/protectedplanet-api) is a separate Sinatra/Grape application that uses the same database and is included as a service in the docker-compose.yml.

To use this service, you need to add the path to your local protectedplanet-api directory in your .env file under the `API_PATH` key.
To use this service, you need to:
- add the path to your local protectedplanet-api directory in your .env file under the `API_PATH` key.
- set the environment variables in the pp-api .env to match the PP docker configuration, e.g:
```
POSTGRES_HOST=protectedplanet-db
POSTGRES_PASSWORD=postgres
```

The api service has an 'api' profile and so does not start automatically with `docker compose up`. You can either run it alongside all of the standard ProtectedPlanet services with:
```
Expand Down Expand Up @@ -113,6 +119,8 @@ sudo docker exec -it protectedplanet-api cap staging deploy
### Troubleshooting:
- `SSH_AUTH_SOCK` not found: make sure `echo ${SSH_AUTH_SOCK}` returns a path to your ssh agent

- For Mac OS X Please make sure you use `/run/host-services/ssh-auth.sock:/ssh-agent` for ssh agent path in docker-compose.yml file

- if yarn integrity problems appear: temporary fix `docker run web yarn install`

- if CMS seeds downloading fails, remove `db/cms_seeds` and retry
Expand Down