Created
June 17, 2016 05:39
-
-
Save TakesxiSximada/cb81d09c0093c05b30c272f79b0e4083 to your computer and use it in GitHub Desktop.
docker環境用Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
COMPOSE_YAML := compose.yml | |
VOLUME_YAML := volumes.yml | |
MACHINE:= docker-machine | |
COMPOSE := docker-compose -f $(COMPOSE_YAML) | |
VOLUME := docker-volume | |
VOLUME_OPTIONS := --conf $(VOLUME_YAML) -m $(DOCKER_MACHINE_NAME) | |
INFRA_SERVICES := redis mysql fakes3 | |
.PHONY: help | |
help: | |
@# Usageを表示します。 | |
@./usage | |
.PHONY: ssh | |
ssh: | |
@# docker-machine ssh します。 | |
@$(MACHINE) ssh $(DOCKER_MACHINE_NAME) | |
.PHONY: rm | |
rm: | |
@## target="" args="arg1 arg2" | |
@# コンテナを削除します。 | |
@$(COMPOSE) rm $(args) $(target) | |
.PHONY: ps | |
ps: | |
@# コンテナを確認します | |
@$(COMPOSE) ps | |
.PHONY: warmup | |
warmup: | |
@# ミドルウェアをデーモンモードで起動します。 | |
@$(COMPOSE) up -d $(INFRA_SERVICES) | |
.PHONY: cooldown | |
cooldown: | |
@# ミドルウェアを停止します。 | |
@$(COMPOSE) stop $(INFRA_SERVICES) | |
.PHONY: up | |
up: | |
@## target="TARGET1 TARGET2 ..." | |
@# targetsで指定したサービスをupで起動します。 | |
@# 起動中のtargetsは一度停止してからupされます。 | |
make stop target=$(target) | |
$(COMPOSE) up $(target) | |
.PHONY: run | |
run: | |
@## target="TARGET1 TARGET2 ..." command="/bin/bash" | |
@# targetsで指定したサービスをrunで起動します。 | |
@# 起動中のtargetsは一度停止してからrunされます。 | |
@make stop target=$(target) | |
@$(COMPOSE) run --service-port $(target) $(command) | |
.PHONY: debug | |
debug: | |
@## target=TARGET | |
@# targetsで指定したサービスをrun --service-port /bin/bashで起動します。 | |
@# 起動中のtargetsは一度停止してから開始されます。 | |
@make stop target=$(target) | |
@make run target=$(target) command=/bin/bash | |
.PHONY: start | |
start: | |
@## target="TARGET1 TARGET2 ..." | |
@# targetで指定したサービスを起動します。 | |
@# targetを指定しない場合は全てのサービスが対象になります。 | |
@docker-compose -f $(COMPOSE_YAML) start $(target) | |
.PHONY: stop | |
stop: | |
@## target="TARGET1 TARGET2 ..." | |
@# targetで指定したサービスを停止します。 | |
@# targetを指定しない場合は全てのサービスが対象になります。 | |
@docker-compose -f $(COMPOSE_YAML) stop $(target) | |
.PHONY: kill | |
kill: | |
@## target="TARGET1 TARGET2 ..." | |
@# targetで指定したサービスをkillします。 | |
@# targetを指定しない場合は全てのサービスが対象になります。 | |
@docker-compose -f $(COMPOSE_YAML) kill $(target) | |
.PHONY: pull | |
pull: | |
@# docker-compose pullします。 | |
@$(COMPOSE) pull | |
.PHONY: build | |
build: | |
@# docker-compose buildします。 | |
@docker-compose -f $(COMPOSE_YAML) build | |
.PHONY: sync-usage | |
sync-usage: | |
@# usageコマンドを同期します。 | |
@curl -L -o usage https://gist.githubusercontent.com/TakesxiSximada/2383ffddc7db85fb5bb77cfe3b3568ea/raw/fd089204c756c03074117ff9a5ca30d1f847bd45/usage | |
@chmod 755 ./usage | |
@git commit -m "sync usage" ./usage | |
.PHONY: sync-start-django | |
sync-start-django: | |
@# start-django.shを同期します。 | |
@curl -L -o start-django.sh https://gist.githubusercontent.com/TakesxiSximada/7406ab83b4a859b7042e1c9bae68f407/raw/e504b876827e9d8d297f5fef7eb174cc790a0b48/start-django.sh | |
@git commit -m "sync start-django.sh" ./start-django.sh | |
.PHONY: sync-kytea | |
sync-kytea: | |
@# start-django.shを同期します。 | |
@curl -L -o kytea-0.4.7.tar.gz http://www.phontron.com/kytea/download/kytea-0.4.7.tar.gz | |
@echo "kyteaのtarballは大きいのでcommitしません" | |
.PHONY: create | |
create: | |
@# docker-volume環境構築 | |
$(VOLUME) directory $(VOLUME_OPTIONS) | |
$(VOLUME) add $(VOLUME_OPTIONS) | |
$(VOLUME) mount $(VOLUME_OPTIONS) | |
.PHONY: destroy | |
destroy: | |
@# docker-volume環境構築 | |
-$(VOLUME) umount $(VOLUME_OPTIONS) | |
-$(VOLUME) remove $(VOLUME_OPTIONS) | |
.PHONY: recreate | |
recreate: destroy create | |
@# docker-volume環境の再構築 | |
.PHONY: attach | |
attach: | |
@## name=VOLUME-NAME | |
@# docker-volumeをattachする | |
@# nameにはvolume名(docker-volume.ymlのsection名を指定する) | |
$(VOLUME) directory $(VOLUME_OPTIONS) | |
$(VOLUME) add $(name) $(VOLUME_OPTIONS) | |
.PHONY: test | |
test: | |
@# テストを実行します。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment