-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
51 lines (44 loc) · 1.77 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
CONTEXT = ansibleplaybookbundle
VERSION = v0.1
IMAGE_NAME = jenkins-apb
TARGET = centos7
REGISTRY = docker-registry.default.svc.cluster.local
OC_USER = developer
OC_PASS = developer
APB_APP = jenkins
# Allow user to pass in OS build options
ifeq ($(TARGET),rhel7)
DFILE := Dockerfile.${TARGET}
else
DFILE := Dockerfile
endif
all: build
build:
docker build -t ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION} -t ${CONTEXT}/${IMAGE_NAME} -f ${DFILE} .
@if docker images ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION}; then touch build; fi
lint:
dockerfile_lint -f Dockerfile
# dockerfile_lint -f Dockerfile.rhel7
ansible-test:
docker build -t ${IMAGE_NAME}-test -f Dockerfile.tox .
docker run --rm -it ${IMAGE_NAME}-test
openshift-test:
$(eval PROJ_RANDOM=test-$(shell shuf -i 100000-999999 -n 1))
oc login --token=${OC_PASS}
oc new-project ${PROJ_RANDOM}
docker login -u ${OC_USER} -p ${OC_PASS} ${REGISTRY}:5000
docker tag ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION} ${REGISTRY}:5000/${PROJ_RANDOM}/${IMAGE_NAME}
docker push ${REGISTRY}:5000/${PROJ_RANDOM}/${IMAGE_NAME}
oc create sa apb
oc adm policy add-role-to-user admin -z apb
oc run ${IMAGE_NAME} --image=${REGISTRY}:5000/${PROJ_RANDOM}/${IMAGE_NAME} --restart=Never --attach=true --overrides='{"apiVersion":"v1","spec":{"serviceAccountName":"apb"}}' -- provision -e namespace=${PROJ_RANDOM}
oc rollout status -w dc/${APB_APP}
oc status
sleep 5
oc describe pod `oc get pod --template '{{(index .items 0).metadata.name }}'`
curl `oc get svc/${APB_APP} --template '{{.spec.clusterIP}}:{{index .spec.ports 0 "port"}}'`
oc exec `oc get pod --template '{{(index .items 0).metadata.name }}'` ps aux
#run:
# docker run -tdi -u $(shell shuf -i 1000010000-1000020000 -n 1) ${CONTEXT}/${IMAGE_NAME}:${TARGET}-${VERSION}
clean:
rm -f build