Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you're able, I'd be very interested in seeing some examples.


  SHELL=/bin/bash
  VERSION=1.0
  
  build: clean
  	docker build -t webservice:$(VERSION).$$(date +"%y-%m-%d") .
  
  shell:
  	docker run -it -v $$(pwd)/src:/opt/app \
  	-p 8888:8888 \
  	--name webservice \
  	-e SECRET1=$$SECRET1 \
  	-e SECRET2=$$SECRET2 \
  	webservice:$(VERSION).$$(date +"%y-%m-%d") \
  	/bin/bash
  
  run:
  	docker run -it  \
  	-p 8888:8888 \
  	--name webservice \
  	-e SECRET1=$$SECRET1 \
  	-e SECRET2=$$SECRET2 \
  	webservice:$(VERSION).$$(date +"%y-%m-%d")
  
  tag:
  	docker tag webservice:$(VERSION).$$(date +"%y-%m-%d") webservice:latest
  
  push: tag
  	docker push webservice:$(VERSION).$$(date +"%y-%m-%d")
  	docker push webservice:latest
  
  clean:
  	-docker kill webservice
  	-docker rm --force webservice
  
  test:
  	docker run -it \
  	--name webservice \
  	webservice:$(VERSION).$$(date +"%y-%m-%d") \
  	python3 tests.py
  
Couple of notes:

- I do major.minor.yy-mm-dd versioning, so this handles that automatically

- shell is for dropping you into a prompt with your present directory mapped to the working directory. I find this super helpful for debugging and testing containers

- run is for testing your CMD and entrypoint scripts


Tidy and to the point.

Thanks for sharing! I'll be using this as inspiration in the future.


Not the OP, doing a bit less that it sounds like the OP is doing, but we built out a relatively handy make-based build system for building a set of images in correct dependency order.

Another member of the team subsequently taught make about the reverse dependencies so that you can split jobs across Travis nodes by the top-ish level image they depend on.

My favorite addition was the ability to generate a dependency graph using graphviz straight from the Dockerfiles.

N.B. Project is now moribund, the team was disbanded. May not build at all. Don't know if any of the forks are active.


That's pretty interesting about Travis. Make is great because you can do as much or as little with it as you want, but it generally always improves organization.


Thanks for chiming in. That all sounds very interesting and this thread has got my gears turning.

I regret not considering Make for Docker administration months/years ago. I've taken to using bash scripts or, worse, tagged bash comments to recall commonly used complex commands.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: