2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# Using Docker Images During Development
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								We've created a special `docker-compose.dev.yml`  override file that should configure docker images to be easier to use
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								during development.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Normally, you'd rebuild your images from scratch with `docker-compose build`  (or `docker-compose up --build` ). However,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								this takes way too long for development. It has to copy the entire repo to each image and rebuild it there.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The `docker-compose.dev.yml`  file bypasses this problem by mounting binaries, startup scripts, and other data to
							 
						 
					
						
							
								
									
										
										
										
											2020-08-27 15:52:16 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								special, slimmed down images (of which the Dockerfile is usually defined in `<service>/debug/Dockerfile` ). 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These dev images will use your _locally built code_ , so you'll need to build locally with gradle first
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								(and every time you want to update the instance). Building locally should be much faster than building on Docker.
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								We highly recommend you just invoke the `docker/dev.sh`  script we've included. It is pretty small if you want to read it
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								to see what it does, but it ends up using our `docker-compose.dev.yml`  file.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Debugging
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The default dev images, while set up to use your local code, do not enable debugging by default. To enable debugging,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								you need to make two small edits (don't check these changes in!).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  Add the JVM debug flags to the environment file for the service. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  Assign the port in the docker-compose file. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-13 16:10:51 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For example, to debug `datahub-gms` :
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 15:16:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
									
										
										
										
											2020-10-28 10:19:55 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# Add this line to docker/datahub-gms/env/docker.env. You can change the port and/or change suspend=n to y.
  
						 
					
						
							
								
									
										
										
										
											2020-09-10 16:04:05 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-05 00:12:12 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```yml
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# Change the definition in docker/docker-compose.dev.yml to this
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  datahub-gms:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    image: linkedin/datahub-gms:debug
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    build:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      context: datahub-gms/debug
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      dockerfile: Dockerfile
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ports:             # < ---  Add  this  line 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  "5005:5005"    # < ---  And  this  line .  Must  match  port  from  environment  file . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    volumes:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  ./datahub-gms/start.sh:/datahub/datahub-gms/scripts/start.sh
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  ../gms/war/build/libs/:/datahub/datahub-gms/bin
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-12 11:27:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								## Tips for People New To Docker
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-12 11:27:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Accessing Logs
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								It is highly recommended you use [Docker Desktop's dashboard ](https://www.docker.com/products/docker-desktop ) to access service logs. If you double click an image it will pull up the logs for you.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								### Conflicting containers
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If you ran `docker/quickstart.sh`  before, your machine may already have a container for DataHub. If you want to run
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`docker/dev.sh`  instead, ensure that the old container is removed by running `docker container prune` . The opposite also 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								applies.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								>  Note this only removes containers, not images. Should still be fast to switch between these once you've launched both
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								>  at least once.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Running a specific service
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`docker-compose up`  will launch all services in the configuration, including dependencies, unless they're already 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								running. If you, for some reason, wish to change this behavior, check out these example commands.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-26 18:20:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								docker-compose -p datahub -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.dev.yml up datahub-gms
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Will only start `datahub-gms`  and its dependencies.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-02-01 13:51:15 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								docker-compose -p datahub -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.dev.yml up --no-deps datahub-gms
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 16:38:53 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Will only start `datahub-gms` , without dependencies.