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

  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.




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

Search: