-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMakefile
159 lines (117 loc) · 3.92 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
SHELL:=/bin/bash
# Set the project name to the path - making underscore the path separator.
# Remove the leading slash and use lowercase since docker-compose will.
project_name=$(shell PWD_var=$$(pwd); PWD_no_lead_slash=$${PWD_var:1}; echo $${PWD_no_lead_slash//\//_} | awk '{print tolower($$0)}' | cat)
docker_compose_dev = docker-compose --project-directory build/docker/dev -f build/docker/dev/docker-compose.yml -p $(project_name)
IMG_REPO?=jcrattzama/data_cube_notebooks
IMG_VER?=
ODC_VER?=1.8.3
DEV_OUT_IMG?=${IMG_REPO}:odc${ODC_VER}${IMG_VER}
export UID:=$(shell id -u)
.PHONY: build
## Common ##
dev-build-no-cache:
$(docker_compose_dev) build --no-cache
dev-build:
$(docker_compose_dev) build
# Start the notebooks environment
dev-up:
$(docker_compose_dev) up -d --build
# Start without rebuilding the Docker image
# (use when dependencies have not changed for faster starts).
dev-up-no-build:
$(docker_compose_dev) up -d
# Stop the notebooks environment
dev-down:
$(docker_compose_dev) down --remove-orphans
dev-restart: dev-down dev-up
dev-restart-no-build: dev-down dev-up-no-build
# List the running containers.
dev-ps:
$(docker_compose_dev) ps
# Start an interactive shell
dev-ssh:
$(docker_compose_dev) exec jupyter bash
# Delete everything
dev-clear:
$(docker_compose_dev) stop
$(docker_compose_dev) rm -fs
dev-push:
docker push ${DEV_OUT_IMG}
dev-pull:
docker pull ${DEV_OUT_IMG}
## End Common ##
## ODC Docker Network ##
# Create the `odc` network on which everything runs.
create-odc-network:
docker network create odc
delete-odc-network:
docker network rm odc
## End ODC Docker Network ##
## ODC DB ##
# Create the persistent volume for the ODC database.
create-odc-db-volume:
docker volume create odc-db-vol
# Delete the persistent volume for the ODC database.
delete-odc-db-volume:
docker volume rm odc-db-vol
recreate-odc-db-volume: delete-odc-db-volume create-odc-db-volume
# Create the ODC database Docker container.
# The `-N` argument sets the maximum number of concurrent connections (`max_connections`).
# The `-B` argument sets the shared buffer size (`shared_buffers`).
create-odc-db:
docker run -d \
-e POSTGRES_DB=datacube \
-e POSTGRES_USER=dc_user \
-e POSTGRES_PASSWORD=localuser1234 \
--name=odc-db \
--network="odc" \
-v odc-db-vol:/var/lib/postgresql/data \
postgres:10-alpine \
-N 1000 \
-B 2048MB
start-odc-db:
docker start odc-db
stop-odc-db:
docker stop odc-db
odc-db-ssh:
docker exec -it odc-db bash
dev-odc-db-init:
$(docker_compose_dev) exec jupyter datacube system init
restart-odc-db: stop-odc-db start-odc-db
delete-odc-db:
docker rm odc-db
recreate-odc-db: stop-odc-db delete-odc-db create-odc-db
recreate-odc-db-and-vol: stop-odc-db delete-odc-db recreate-odc-db-volume create-odc-db
## End ODC DB ##
## Adding Data ##
# Add a product definition for landsat level 1
dev-add-product-def:
$(docker_compose_dev) exec jupyter datacube product add \
https://raw.githubusercontent.com/opendatacube/datacube-dataset-config/master/products/ls_usgs_level1_scene.yaml
# Index a dataset (just an example, you can change the extents)
dev-index:
$(docker_compose_dev) exec jupyter bash -c \
"cd /opt/odc/scripts && python3 ./autoIndex.py \
--start_date '2019-01-01' \
--end_date '2020-01-01' \
--extents '146.30,146.83,-43.54,-43.20'"
## End Adding Data ##
## Docker Misc ##
sudo-ubuntu-install-docker:
sudo apt-get update
sudo apt install -y docker.io
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo systemctl start docker
sudo systemctl enable docker
# The following steps are for enabling use
# of the `docker` command for the current user
# without using `sudo`
getent group docker || sudo groupadd docker
sudo usermod -aG docker ${USER}
## End Docker Misc ##
## CI ##
test-ci-local:
gitlab-runner exec shell build-no-cache
## End CI ##