forked from jchaney/owncloud
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
136 lines (116 loc) · 5.22 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
## For more examples of a Makefile based Docker container deployment see: https://github.com/ypid/docker-makefile
DOCKER_RUN_OPTIONS ?= --env "TZ=Europe/Berlin"
docker_owncloud_http_port ?= 80
docker_owncloud_https_port ?= 443
docker_owncloud_in_root_path ?= 1
docker_owncloud_permanent_storage ?= /tmp/owncloud
docker_owncloud_ssl_cert ?= /etc/ssl/certs/ssl-cert-snakeoil.pem
docker_owncloud_ssl_key ?= /etc/ssl/private/ssl-cert-snakeoil.key
docker_owncloud_servername ?= localhost
docker_owncloud_mariadb_user ?= owncloud-production
image_owncloud ?= jchaney/owncloud
image_mariadb ?= mariadb
.PHONY: default start stop run build build-dev owncloud owncloud-https owncloud-mariadb owncloud-mariadb-get-pw owncloud-mariadb-cli owncloud-production owncloud-dev rm-containers rm-container-tmp-data
default:
@echo 'See Makefile and README.md'
start:
docker start owncloud
stop:
docker stop owncloud owncloud-https owncloud-mariadb owncloud-production owncloud-dev
run: owncloud
rm-containers:
docker rm --force owncloud owncloud-https owncloud-mariadb owncloud-production owncloud-dev
rm-container-tmp-data:
rm -rf "$(docker_owncloud_permanent_storage)" "$(docker_owncloud_permanent_storage)-dev" || echo "You need root permissions for this"
build:
docker build --no-cache=true --tag $(image_owncloud) .
build-dev:
docker build --no-cache=false --tag $(image_owncloud) .
owncloud:
-@docker rm --force "$@"
docker run --detach \
--name "$@" \
$(DOCKER_RUN_OPTIONS) \
--volume "$(docker_owncloud_permanent_storage)/data:/var/www/owncloud/data" \
--volume "$(docker_owncloud_permanent_storage)/additional_apps:/var/www/owncloud/apps_persistent" \
--volume "$(docker_owncloud_permanent_storage)/config:/owncloud" \
--publish $(docker_owncloud_http_port):80 \
--publish $(docker_owncloud_https_port):443 \
--env "OWNCLOUD_IN_ROOTPATH=$(docker_owncloud_in_root_path)" \
$(image_owncloud)
# make-ssl-cert generate-default-snakeoil
owncloud-https:
-@docker rm --force "$@"
docker run --detach \
--name "$@" \
$(DOCKER_RUN_OPTIONS) \
--publish $(docker_owncloud_http_port):80 \
--publish $(docker_owncloud_https_port):443 \
--volume "$(docker_owncloud_permanent_storage)/data:/var/www/owncloud/data" \
--volume "$(docker_owncloud_permanent_storage)/additional_apps:/var/www/owncloud/apps_persistent" \
--volume "$(docker_owncloud_permanent_storage)/config:/owncloud" \
--volume "$(docker_owncloud_ssl_cert):$(docker_owncloud_ssl_cert):ro" \
--volume "$(docker_owncloud_ssl_key):$(docker_owncloud_ssl_key):ro" \
--env "OWNCLOUD_IN_ROOTPATH=$(docker_owncloud_in_root_path)" \
--env "OWNCLOUD_SERVERNAME=$(docker_owncloud_servername)" \
--env "SSL_CERT=$(docker_owncloud_ssl_cert)" \
--env "SSL_KEY=$(docker_owncloud_ssl_key)" \
$(image_owncloud)
owncloud-production: owncloud-mariadb
-@docker rm --force "$@"
docker run --detach \
--name "$@" \
$(DOCKER_RUN_OPTIONS) \
--link owncloud-mariadb:db \
--publish $(docker_owncloud_http_port):80 \
--publish $(docker_owncloud_https_port):443 \
--volume "$(docker_owncloud_permanent_storage)/data:/var/www/owncloud/data" \
--volume "$(docker_owncloud_permanent_storage)/additional_apps:/var/www/owncloud/apps_persistent" \
--volume "$(docker_owncloud_permanent_storage)/config:/owncloud" \
--volume "$(docker_owncloud_ssl_cert):$(docker_owncloud_ssl_cert):ro" \
--volume "$(docker_owncloud_ssl_key):$(docker_owncloud_ssl_key):ro" \
--env "OWNCLOUD_IN_ROOTPATH=$(docker_owncloud_in_root_path)" \
--env "OWNCLOUD_SERVERNAME=$(docker_owncloud_servername)" \
--env "SSL_CERT=$(docker_owncloud_ssl_cert)" \
--env "SSL_KEY=$(docker_owncloud_ssl_key)" \
--env "DB_ENV_MYSQL_USER=overwrite" \
--env "DB_ENV_MYSQL_PASSWORD=overwrite" \
--env "DB_ENV_MYSQL_DATABASE=overwrite" \
--env "DB_ENV_MYSQL_ROOT_PASSWORD=overwrite" \
$(image_owncloud)
owncloud-mariadb:
-@docker rm --force "$@"
docker run --detach \
--name "$@" \
$(DOCKER_RUN_OPTIONS) \
--volume $(docker_owncloud_permanent_storage)/db:/var/lib/mysql \
--env "MYSQL_ROOT_PASSWORD=$(shell pwgen --secure 40 1)" \
--env "MYSQL_USER=$(docker_owncloud_mariadb_user)" \
--env "MYSQL_DATABASE=$(docker_owncloud_mariadb_user)" \
--env "MYSQL_PASSWORD=$(shell pwgen --secure 40 1)" \
$(image_mariadb)
owncloud-mariadb-get-pw:
docker exec owncloud-mariadb \
sh -c '(env | egrep "^MYSQL_USER="; \
env | egrep "^MYSQL_(DATABASE|PASSWORD)="; \
) | sed "s/=/: /"; \
echo "Database host: db"'
owncloud-mariadb-cli:
docker run --rm --interactive --tty \
--name "$@" \
$(DOCKER_RUN_OPTIONS) \
--link owncloud-mariadb:mysql \
$(image_mariadb) \
sh -c 'mysql -h"$$MYSQL_PORT_3306_TCP_ADDR" -P"$$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
owncloud-dev:
-@docker rm --force "$@"
docker run --detach \
--name "$@" \
$(DOCKER_RUN_OPTIONS) \
--volume "$(docker_owncloud_permanent_storage)-dev/data:/var/www/owncloud/data" \
--volume "$(docker_owncloud_permanent_storage)-dev/additional_apps:/var/www/owncloud/apps_persistent" \
--volume "$(docker_owncloud_permanent_storage)-dev/config:/owncloud" \
--publish $(docker_owncloud_http_port):80 \
--publish ""$(docker_owncloud_https_port):443 \
--env "OWNCLOUD_IN_ROOTPATH=$(docker_owncloud_in_root_path)" \
$(image_owncloud)