A R Karthick | e3bde96 | 2016-09-27 15:06:35 -0700 | [diff] [blame^] | 1 | # Docker container Makefile for XOS |
| 2 | # |
| 3 | # Targets: |
| 4 | # |
| 5 | # `base` - XOS prerequistie files, no XOS code, builds xosproject/xos-base |
| 6 | # `build` - base + XOS code, git pulled in Dockerfile from main repo, |
| 7 | # builds xosproject/xos |
| 8 | # `custom` - base + XOS code, git pulled in Dockerfile from selectable repo, |
| 9 | # builds xosproject/xos |
| 10 | # `devel` - base + XOS code from local directory, builds xosproject/xos |
| 11 | # `test` - xosproject/xos + nodejs testing frameworks, builds |
| 12 | # xosproject/xos-test |
| 13 | # |
| 14 | |
| 15 | NO_DOCKER_CACHE ?= false |
| 16 | |
| 17 | CONTAINER_NAME ?= xos-server |
| 18 | IMAGE_NAME ?= xosproject/xos |
| 19 | |
| 20 | XOS_GIT_REPO ?= https://github.com/opencord/xos.git |
| 21 | XOS_GIT_BRANCH ?= master |
| 22 | |
| 23 | XOS_GIT_COMMIT_HASH ?= $(shell git log --pretty=format:'%H' -n 1 || echo -n "unknown" ) |
| 24 | XOS_GIT_COMMIT_DATE ?= $(shell git log --pretty=format:'%ad' -n 1 || echo -n "unknown" ) |
| 25 | |
| 26 | TOSCA_CONFIG_PATH ?= /opt/xos/configurations/opencloud/opencloud.yaml |
| 27 | |
| 28 | BUILD_ARGS = |
| 29 | ifdef http_proxy |
| 30 | BUILD_ARGS += --build-arg http_proxy=${http_proxy} |
| 31 | endif |
| 32 | ifdef https_proxy |
| 33 | BUILD_ARGS += --build-arg https_proxy=${https_proxy} |
| 34 | endif |
| 35 | |
| 36 | base: |
| 37 | sudo docker build --no-cache=${NO_DOCKER_CACHE} --rm \ |
| 38 | -f Dockerfile.base -t xosproject/xos-base ${BUILD_ARGS} . |
| 39 | |
| 40 | build: |
| 41 | sudo docker build --no-cache=${NO_DOCKER_CACHE} --rm \ |
| 42 | -f Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . |
| 43 | |
| 44 | custom: |
| 45 | docker build --no-cache=${NO_DOCKER_CACHE} --rm \ |
| 46 | --build-arg XOS_GIT_REPO=${XOS_GIT_REPO} \ |
| 47 | --build-arg XOS_GIT_BRANCH=${XOS_GIT_BRANCH} \ |
| 48 | -f Dockerfile -t ${IMAGE_NAME} ${BUILD_ARGS} . |
| 49 | |
| 50 | devel: |
| 51 | sudo docker build --no-cache=${NO_DOCKER_CACHE} --rm \ |
| 52 | --build-arg XOS_GIT_COMMIT_HASH="${XOS_GIT_COMMIT_HASH}" \ |
| 53 | --build-arg XOS_GIT_COMMIT_DATE="${XOS_GIT_COMMIT_DATE}" \ |
| 54 | -f Dockerfile.devel -t ${IMAGE_NAME} ${BUILD_ARGS} ../.. |
| 55 | |
| 56 | test: |
| 57 | sudo docker build --no-cache=${NO_DOCKER_CACHE} --rm \ |
| 58 | -f Dockerfile.test -t xosproject/xos-test ${BUILD_ARGS} ../.. |
| 59 | |
| 60 | run: |
| 61 | sudo docker run -d --name ${CONTAINER_NAME} -p 80:8000 \ |
| 62 | ${IMAGE_NAME} |
| 63 | |
| 64 | runtosca: |
| 65 | sudo docker exec -it ${CONTAINER_NAME} \ |
| 66 | /usr/bin/python /opt/xos/tosca/run.py padmin@vicci.org ${TOSCA_CONFIG_PATH} |
| 67 | |
| 68 | stop: |
| 69 | sudo docker stop ${CONTAINER_NAME} |
| 70 | |
| 71 | rm: |
| 72 | sudo docker rm ${CONTAINER_NAME} |
| 73 | |
| 74 | rmi: |
| 75 | sudo docker rmi `docker images | grep "^<none>" | awk '{print $$3}'` |
| 76 | |