-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (80 loc) · 2.81 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
NAME = madharjan/docker-odoo
VERSION = 12.0
DEBUG ?= true
DOCKER_USERNAME ?= $(shell read -p "DockerHub Username: " pwd; echo $$pwd)
DOCKER_PASSWORD ?= $(shell stty -echo; read -p "DockerHub Password: " pwd; stty echo; echo $$pwd)
DOCKER_LOGIN ?= $(shell cat ~/.docker/config.json | grep "docker.io" | wc -l)
.PHONY: all build run test stop clean tag_latest release clean_images
all: build
docker_login:
ifeq ($(DOCKER_LOGIN), 1)
@echo "Already login to DockerHub"
else
@docker login -u $(DOCKER_USERNAME) -p $(DOCKER_PASSWORD)
endif
build:
sed -i -e "s/VERSION=.*/VERSION=$(VERSION)/g" bin/odoo-systemd-unit
docker build \
--build-arg ODOO_VERSION=$(VERSION) \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg DEBUG=${DEBUG} \
-t $(NAME):$(VERSION) --rm .
run:
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi
rm -rf /tmp/odoo
mkdir -p /tmp/odoo/etc/
mkdir -p /tmp/odoo/addons/
mkdir -p /tmp/odoo/lib/
docker run -d \
-e POSTGRESQL_USERNAME=odoo \
-e POSTGRESQL_PASSWORD=odoo \
--name odoo-postgresql madharjan/docker-postgresql:9.5
sleep 2
docker run -d \
-e POSTGRESQL_USERNAME=odoo \
-e POSTGRESQL_PASSWORD=odoo \
--name odoo-postgresql_default madharjan/docker-postgresql:9.5
sleep 2
docker run -d \
--link odoo-postgresql:postgresql \
-e DEBUG=$(DEBUG) \
-e ODOO_ADMIN_PASSWORD=Pa55w0rd \
-e [email protected] \
-v /tmp/odoo/etc:/etc/odoo \
-v /tmp/odoo/addons:/opt/odoo/extra \
-v /tmp/odoo/lib:/var/lib/odoo \
--name odoo $(NAME):$(VERSION)
sleep 2
docker run -d \
--link odoo-postgresql:postgresql \
-e DISABLE_ODOO=1 \
-e DEBUG=$(DEBUG) \
--name odoo_no_odoo $(NAME):$(VERSION)
sleep 2
docker run -d \
--link odoo-postgresql_default:postgresql \
-e DEBUG=$(DEBUG) \
--name odoo_default $(NAME):$(VERSION)
sleep 5
test:
sleep 190
./bats/bin/bats test/tests.bats
stop:
docker exec odoo /bin/bash -c "sv stop odoo" 2> /dev/null || true
sleep 6
docker exec odoo /bin/bash -c "rm -rf /etc/odoo/*" 2> /dev/null || true
docker exec odoo /bin/bash -c "rm -rf /var/lib/odoo/*" 2> /dev/null || true
docker stop odoo odoo_no_odoo odoo_default odoo-postgresql odoo-postgresql_default 2> /dev/null || true
clean: stop
docker rm odoo odoo_no_odoo odoo_default odoo-postgresql odoo-postgresql_default 2> /dev/null || true
rm -rf /tmp/odoo || true
docker images | grep "<none>" | awk '{print$3 }' | xargs docker rmi 2> /dev/null || true
publish: docker_login run test clean
docker push $(NAME)
tag_latest:
docker tag $(NAME):$(VERSION) $(NAME):latest
release: docker_login run test clean tag_latest
docker push $(NAME)
clean_images: clean
docker rmi $(NAME):latest $(NAME):$(VERSION) 2> /dev/null || true
docker logout