-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
2306 lines (2017 loc) · 107 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
SHELL := /bin/bash
help:
@echo " ___ ____ ____ ____"
@echo " / _ \/ ___| / ___/ ___|"
@echo "| | | \___ \| | _\___ \ "
@echo "| |_| |___) | |_| |___) | "
@echo " \___/|____/ \____|____/ "
@echo
@echo "Open Source GIS Stack"
@echo "Brought to you by Kartoza (Pty) Ltd."
@echo
@echo "Help for using this Makefile"
@echo
@echo "For detailed help please visit:"
@echo "https://kartoza.github.io/osgs/introduction.html"
@echo
@echo "------------------------------------------------------------------"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m - %s\n", $$1, $$2}'
compose-diagram: ## Generate a diagram of the docker-compose file
@echo ""
@echo "Generating diagram of docker architecture"
@echo ""
@docker run --rm -it --name dcv -v $(pwd):/input pmsipilot/docker-compose-viz render -m image docker-compose.yml
backup-everything: ## Sequentially run through all backup scripts
@make backup-hugo
@make backup-mapproxy
-@make backup-db-qgis-styles
-@make backup-db-qgis-projects
@make backup-db-gis
@make backup-all-databases
-@make backup-mergin-base-db-schema
@make backup-node-red
@make backup-mosquitto
@make backup-jupyter
@make backup-metabase
@make backup-file-browser
restore-everything:
@make restore-hugo
@make restore-mapproxy
-@make restore-db-qgis-styles
-@make restore-db-qgis-projects
@make restore-db-gis
@make restore-all-databases
-@make restore-mergin-base-db-schema
@make restore-node-red
@make restore-mosquitto
@make restore-jupyter
@make restore-metabase
@make restore-file-browser
# We need to declare phony here since the docs dir exists
# otherwise make tries to execute the docs file directly
.PHONY: docs
docs: htmldocs pdfdocs## Generate documentation and place results in docs folder.
pdfdocs:
@echo
@echo "------------------------------------------------------------------"
@echo "Making sphinx PDF docs"
@echo "------------------------------------------------------------------"
$(MAKE) -C sphinx latexpdf
@cp sphinx/build/latex/osgs.pdf osgs-manual.pdf
htmldocs: ## Generate documentation and place results in docs folder.
@echo
@echo "------------------------------------------------------------------"
@echo "Making sphinx HTML docs"
@echo "------------------------------------------------------------------"
$(MAKE) -C sphinx html
@cp -r sphinx/build/html/* docs
ps: ## List all running docker contains
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Current status"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose ps
deploy: configure ## Deploy the initial stack including nginx and hugo-watcher
@echo
@echo "------------------------------------------------------------------"
@echo "Starting basic nginx site"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f
copy-overrides: ## Copy the docker overrides example if it does not already exist
@echo
@echo "------------------------------------------------------------------"
@echo "Copying overrides"
@echo "------------------------------------------------------------------"
@if [ -f "docker-compose.override.yml" ]; then echo "Docker composer override already exists."; exit 0; fi
@cp docker-compose.override.yml.example docker-compose.override.yml
disable-all-services: ## Disable all services - does not actually stop them
@echo
@echo "------------------------------------------------------------------"
@echo "Disabling services"
@echo "This will remove any symlinks in conf/nginx_conf/locations and conf/nginx_conf/upstreams"
@echo "effectively disabling all services exposed by nginx"
@echo "------------------------------------------------------------------"
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@find ./conf/nginx_conf/locations -maxdepth 1 -type l -delete
@find ./conf/nginx_conf/upstreams -maxdepth 1 -type l -delete
@echo "" > enabled-profiles
prepare-templates: ## Prepare templates
@echo
@echo "------------------------------------------------------------------"
@echo "Preparing templates"
@echo "This will replace any local configuration changes you have made"
@echo "in .env, conf/nginx_conf/servername.conf"
@echo "------------------------------------------------------------------"
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@cp .env.example .env
@cp conf/nginx_conf/servername.conf.example conf/nginx_conf/servername.conf
@echo "Please enter your valid domain name for the site."
@echo "e.g. example.org or subdomain.example.org:"
@read -p "Domain name: " DOMAIN; \
rpl example.org $$DOMAIN conf/nginx_conf/servername.conf .env;
@echo "We are going to set up a self signed certificate now."
configure:
@echo "Please run either make configure-ssl-self-signed or make configure-letsencrypt-ssl"
configure-ssl-self-signed: disable-all-services prepare-templates ## Create a self signed cert for local testing
@mkdir -p ./certbot/certbot/conf/
@openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./certbot/certbot/conf/nginx-selfsigned.key -out ./certbot/certbot/conf/nginx-selfsigned.crt
@cp conf/nginx_conf/ssl/certificates.conf.selfsigned.example conf/nginx_conf/ssl/ssl.conf
make site-config
make enable-hugo
make configure-htpasswd
make deploy
#@rpl "BEGIN CERTIFICATE" "BEGIN TRUSTED CERTIFICATE" ./certbot/certbot/conf/nginx-selfsigned.crt
#@rpl "END CERTIFICATE" "END TRUSTED CERTIFICATE" ./certbot/certbot/conf/nginx-selfsigned.crt
#@rpl "BEGIN PRIVATE KEY" "TRUSTED CERTIFICATE" ./certbot/certbot/conf/nginx-selfsigned.key
#@rpl "END PRIVATE KEY" "TRUSTED CERTIFICATE" ./certbot/certbot/conf/nginx-selfsigned.key
configure-letsencrypt-ssl: disable-all-services prepare-templates ## Create a certbot SSL certificate for use in production
@make check-env
@echo "Do you want to set up SSL using letsencrypt?"
@echo "This is recommended for production!"
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@cp conf/nginx_certbot_init_conf/nginx.conf.example conf/nginx_certbot_init_conf/nginx.conf
@cp init-letsencrypt.sh.example init-letsencrypt.sh
@cp conf/nginx_conf/ssl/certificates.conf.example conf/nginx_conf/ssl/ssl.conf
@rpl example.org $(shell grep DOMAIN .env| sed 's/DOMAIN=//') \
conf/nginx_certbot_init_conf/nginx.conf \
conf/nginx_conf/ssl/ssl.conf \
init-letsencrypt.sh;
@read -p "Valid Contact Person Email Address: " EMAIL; \
rpl [email protected] $$EMAIL init-letsencrypt.sh .env
make configure-htpasswd
./init-letsencrypt.sh
site-config: ## Configure the hugo static site
@echo "------------------------------------------------------------------"
@echo "Configure your static site content management system"
@echo "You should only do this once per site deployment"
@echo "------------------------------------------------------------------"
@echo "This will replace any local configuration changes you have made"
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@cp ./conf/hugo_conf/config.yaml.example ./conf/hugo_conf/config.yaml
@rpl -q {{siteDomain}} $(shell grep DOMAIN .env| sed 's/DOMAIN=//') $(shell pwd)/conf/hugo_conf/config.yaml
@echo "Please enter the title of your website (default 'Geoservices')"
@read -p "Site Title: " result; \
SITETITLE=$${result:-"Geoservices"} && \
rpl -q {{siteTitle}} "$$SITETITLE" $(shell pwd)/conf/hugo_conf/config.yaml
@echo "Please enter the name of the website owner (default 'Kartoza')"
@read -p "Site Owner: " result; \
SITEOWNER=$${result:-"Kartoza"} && \
rpl -q {{ownerName}} "$$SITEOWNER" $(shell pwd)/conf/hugo_conf/config.yaml
@echo "Please supply the URL of the site owner (default 'www.kartoza.com')."
@read -p "Owner URL: " result; \
OWNERURL=$${result:-"www.kartoza.com"} && \
rpl -q {{ownerDomain}} "$$OWNERURL" $(shell pwd)/conf/hugo_conf/config.yaml
@echo "Please supply a valid public URL to the Website Logo."
@echo "Be sure to include the protocol prefix (e.g. https://)"
@read -p "Logo URL: " result; \
LOGOURL=$${result:-"img/Circle-icons-stack.svg"} && \
rpl -q {{logoURL}} "$$LOGOURL" $(shell pwd)/conf/hugo_conf/config.yaml
# Used by configure-htpasswd to see if we have already set a password...
HTUSERCONFIGURED = $(shell cat .env | grep -o 'NGINX_AUTH_USER')
HTPASSWDCONFIGURED = $(shell cat .env | grep 'NGINX_AUTH_PWD')
configure-htpasswd: ## Set up a password authentiation for password protected ares of the site
@make check-env
@echo "------------------------------------------------------------------"
@echo "Configuring password controlled file sharing are for your site"
@echo "Accessible at /downloads/"
@echo "Access credentials will be stored in .env"
@echo "------------------------------------------------------------------"
#Sometimes docker will make a directory if the pwd file does not
#exist when it starts
@if [ -d "conf/nginx_conf/htpasswd" ]; then rm -rf conf/nginx_conf/htpasswd; fi
@if [ -f "conf/nginx_conf/htpasswd" ]; then echo "htpasswd file already exists, skipping"; exit 0; fi
# bcrypt encrypted pwd, be sure to use nginx:alpine nginx image
# keep unindented or make will treat ifeq as bash rather than make cmd and fail
ifeq ($(HTUSERCONFIGURED),NGINX_AUTH_USER)
@echo "Web user password is already configured. Please see .env"
@echo "Current password for web user is:"
@echo $(HTPASSWDCONFIGURED)
else
@export PASSWD=$$(pwgen 20 1); \
htpasswd -cbB conf/nginx_conf/htpasswd web $$PASSWD; \
echo "#User account for protected areas of the site using httpauth" >> .env; \
echo "#You can add more accounts to conf/nginx_conf/htpasswd using the htpasswd tool" >> .env; \
echo "NGINX_AUTH_USER=web" >> .env; \
echo "NGINX_AUTH_PWD=$$PASSWD" >> .env; \
echo "File sharing htpasswd set to $$PASSWD"
endif
@make enable-downloads
refresh-letsencrypt: ## Manually refresh the letsencrypt certbot SSL certificate.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Refreshing letsencrypt certbot SSL certificate"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d certbot
@make restart
#------------------ Nginx ------------------------
start-nginx: ## Start the Nginx docker container.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting NGINX"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d nginx
stop-nginx: ## Stop the Nginx docker container.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping NGINX"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose stop nginx
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm nginx
restart-nginx: ## Restart the Nginx docker container.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting NGINX"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
make nginx-logs
nginx-shell: ## Create an shell in the Nginx docker container for debugging.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating nginx shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec nginx /bin/sh
nginx-logs: ## Display the logs of Nginx. Press Ctrl-C to exit.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Tailing logs of nginx. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f nginx
#----------------- Hugo --------------------------
deploy-hugo: enable-hugo site-config start-hugo
enable-hugo: ## Enable the Hugo static content management system.
-@cd conf/nginx_conf/locations; ln -s hugo.conf.available hugo.conf
@echo "hugo" >> enabled-profiles
start-hugo: ## Start the Hugo static content management system.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting Hugo"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d
stop-hugo: ## Stop the Hugo static content management system.
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping Hugo"
@echo "------------------------------------------------------------------"
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill hugo-watcher
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm hugo-watcher
restart-hugo:
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting Hugo"
@echo "------------------------------------------------------------------"
@make stop-hugo
@echo "------------------------------------------------------------------"
@echo "Starting Hugo"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d hugo-watcher
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
@make hugo-logs
disable-hugo: ## Disable the Hugo static content management system.
@cd conf/nginx_conf/locations; rm hugo.conf
# Remove from enabled-profiles
@sed -i '/hugo/d' enabled-profiles
hugo-logs: ## Display the logs of the hugo-watcher process-
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling hugo logs. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f hugo-watcher
hugo-shell: ## Create a shell in the Hugo container for debugging.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating hugo shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec hugo-watcher bash
backup-hugo: ## Create backups of the Hugo content folder.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating a backup of hugo"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@sudo sh -c "cd /var/lib/docker/volumes/osgisstack_hugo_site/; chown -R 1000:1000 _data/; chmod -R ug+rwX _data/"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec hugo-watcher bash -c "cd ..; tar -czvf hugo-backup.tar.gz src"
@docker cp osgisstack_hugo-watcher_1:hugo-backup.tar.gz backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec hugo-watcher bash -c "rm ../hugo-backup.tar.gz"
@cp backups/hugo-backup.tar.gz backups/hugo-backup-$$(date +%Y-%m-%d).tar.gz
@ls -lah backups/hugo*.tar.gz
restore-hugo: ## Restore the last backup of the Hugo content folder.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restore last backup of hugo from /backups/hugo-backup.tar.gz"
@echo "If you wish to restore an older backup, first copy it to /backups/hugo-backup.tar.gz"
@echo "Note: Restoring will OVERWRITE all data currently in your hugo_site directory."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@docker cp backups/hugo-backup.tar.gz osgisstack_hugo-watcher_1:/
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec hugo-watcher bash -c "cd .. ; tar -zxvf hugo-backup.tar.gz"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec hugo-watcher bash -c "rm ../hugo-backup.tar.gz"
get-hugo-theme:
@echo
@echo "------------------------------------------------------------------"
@echo "Getting hugo theme"
@echo "------------------------------------------------------------------"
@export THEME=clarity; wget -O - https://github.com/gohugoio/hugoThemes | grep '<a data-skip-pjax="true" href="' | grep -o "<span title=\".*\">" | sed 's/<span title="//g' | sed 's/"><a data-skip-pjax="true" href="/ /g' | sed 's/">//g' | sed 's/\/tree\//\/archive\//g' | awk '{print $1 , "https://github.com"$4".zip" }' > themes.txt ; egrep "${THEME}" themes.txt | awk '{print $2}' | xargs wget -O ${THEME}.zip
#----------------- GeoServer --------------------------
deploy-geoserver: enable-geoserver configure-geoserver-passwd start-geoserver ## Deploy the GeoServer service.
enable-geoserver: ## Enable the Geoserver service.
@make check-env
-@cd conf/nginx_conf/locations; ln -s geoserver.conf.available geoserver.conf
@echo "geoserver" >> enabled-profiles
configure-geoserver-passwd:
@make check-env
@export PASSWD=$$(pwgen 20 1); \
rpl GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver GEOSERVER_ADMIN_PASSWORD=$$PASSWD .env; \
echo "GeoServer password set to $$PASSWD"
start-geoserver:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting GeoServer"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
stop-geoserver:
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping GeoServer"
@echo "------------------------------------------------------------------"
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill geoserver
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm geoserver
restart-geoserver:
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting GeoServer"
@echo "------------------------------------------------------------------"
@make stop-geoserver
@echo "------------------------------------------------------------------"
@echo "Starting GeoServer"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d geoserver
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
@make geoserver-logs
disable-geoserver:
@make check-env
@cd conf/nginx_conf/locations; rm geoserver.conf
# Remove from enabled-profiles
@sed -i '/geoserver/d' enabled-profiles
geoserver-logs:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling Geoserver logs. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f geoserver
geoserver-shell:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating Geoserver shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec geoserver bash
#----------------- QGIS Server --------------------------
deploy-qgis-server: enable-qgis-server start-qgis-server
enable-qgis-server:
@make check-env
-@cd conf/nginx_conf/locations; ln -s qgis-server.conf.available qgis-server.conf
-@cd conf/nginx_conf/upstreams; ln -s qgis-server.conf.available qgis-server.conf
@echo "qgis-server" >> enabled-profiles
@touch conf/pg_conf/pg_service.conf
start-qgis-server:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting QGIS Server"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d --scale qgis-server=10 --remove-orphans
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
stop-qgis-server:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping QGIS Server and Nginx"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill qgis-server
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm qgis-server
restart-qgis-server: ## Stop and restart the QGIS server containers
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting QGIS Server containers"
@echo "------------------------------------------------------------------"
# Need to flush this completely for it to work on restart
@touch conf/pg_conf/pg_service.conf
make stop-qgis-server
make start-qgis-server
disable-qgis-server:
@make check-env
@cd conf/nginx_conf/locations; rm qgis-server.conf
@cd conf/nginx_conf/upstreams; rm qgis-server.conf
# Remove from enabled-profiles
@sed -i '/qgis/d' enabled-profiles
qgis-server-logs:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling QGIS Server logs. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f qgis-server
qgis-server-shell:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating QGIS Server shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec qgis-server bash
#----------------- QGIS Desktop --------------------------
deploy-qgis-desktop: enable-qgis-desktop start-qgis-desktop ## Run QGIS Desktop in your web browser
enable-qgis-desktop:
@make check-env
-@cd conf/nginx_conf/locations; ln -s qgis-desktop.conf.available qgis-desktop.conf
#-@cd conf/nginx_conf/upstreams; ln -s qgis-desktop.conf.available qgis-desktop.conf
@echo "qgis-desktop" >> enabled-profiles
start-qgis-desktop:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting QGIS Desktop"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d qgis-desktop
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
stop-qgis-desktop:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping QGIS Desktop"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill qgis-desktop
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm qgis-desktop
restart-qgis-desktop:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting QGIS Desktop"
@echo "------------------------------------------------------------------"
@make stop-qgis-desktop
@make start-qgis-desktop
@make qgis-desktop-logs
disable-qgis-desktop:
@make check-env
@cd conf/nginx_conf/locations; rm qgis-desktop.conf
#@cd conf/nginx_conf/upstreams; rm qgis-desktop.conf
# Remove from enabled-profiles
@sed -i '/qgis/d' enabled-profiles
qgis-desktop-logs:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling QGIS Desktop logs. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f qgis-desktop
qgis-desktop-shell:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating QGIS Desktop shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec qgis-desktop bash
#----------------- Mapproxy --------------------------
deploy-mapproxy: enable-mapproxy configure-mapproxy start-mapproxy
enable-mapproxy:
@make check-env
-@cd conf/nginx_conf/locations; ln -s mapproxy.conf.available mapproxy.conf
@echo "mapproxy" >> enabled-profiles
configure-mapproxy:
@make check-env
@echo "=========================:"
@echo "Mapproxy configurations:"
@echo "=========================:"
@cp conf/mapproxy_conf/mapproxy.yaml.example conf/mapproxy_conf/mapproxy.yaml
@cp conf/mapproxy_conf/base/osgs-osm.yaml.example conf/mapproxy_conf/base/osgs-osm.yaml
@cp conf/mapproxy_conf/base/owntracks-today.yaml.example conf/mapproxy_conf/base/owntracks-today.yaml
@cp conf/mapproxy_conf/seed.yaml.example conf/mapproxy_conf/seed.yaml
@echo "We have created template mapproxy.yaml and seed.yaml"
@echo "configuration files in conf/mapproxy_conf."
@echo "You will need to hand edit those files and then "
@echo "restart mapproxy for those edits to take effect."
@echo "see: make restart-mapproxy"
start-mapproxy:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting Mapproxy"
@echo "------------------------------------------------------------------"
# Nasty hack for permissions issue - see https://github.com/kartoza/docker-mapproxy/issues/16
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose run --entrypoint /bin/chown --rm -w / -u root mapproxy 1000:1000 /mapproxy/cache_data
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
stop-mapproxy:
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping Mapproxy"
@echo "------------------------------------------------------------------"
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill mapproxy
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm mapproxy
restart-mapproxy:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting Mapproxy and clearing its cache"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill mapproxy
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm mapproxy
@rm -rf conf/mapproxy_conf/cache_data/*
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d mapproxy
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f mapproxy
disable-mapproxy:
@make check-env
@cd conf/nginx_conf/locations; rm mapproxy.conf
# Remove from enabled-profiles
@sed -i '/mapproxy/d' enabled-profiles
mapproxy-logs:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling Mapproxy logs. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f mapproxy
mapproxy-shell:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating Mapproxy shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec mapproxy bash
backup-mapproxy:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up Mapproxy configuration files"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@cp conf/mapproxy_conf/mapproxy.yaml backups/mapproxy.yaml
@cp backups/mapproxy.yaml backups/mapproxy-$$(date +%Y-%m-%d).yaml
@cp conf/mapproxy_conf/seed.yaml backups/seed.yaml
@cp backups/seed.yaml backups/seed-$$(date +%Y-%m-%d).yaml
@ls -lah backups/*.yaml
restore-mapproxy:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restore last backup of the mapproxy configuration files from /backups/mapproxy.yaml and /backups/seed.yaml"
@echo "If you wish to restore an older backup of the files, first copy them to /backups/mapproxy.yaml and /backups/seed.yaml"
@echo "Note: Restoring will OVERWRITE your current mapproxy.yaml and seed.yaml Mapproxy configuration files."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@cp backups/mapproxy.yaml conf/mapproxy_conf/mapproxy.yaml
@cp backups/seed.yaml conf/mapproxy_conf/seed.yaml
#----------------- Postgres --------------------------
deploy-postgres:enable-postgres configure-postgres start-postgres
enable-postgres:
@make check-env
@echo "db" >> enabled-profiles
configure-timezone:
@make check-env
@if grep "#TIMEZONE CONFIGURED" .env; then echo "Timezone already configured"; exit 0; else \
echo "Please enter the timezone for your server"; \
echo "See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"; \
echo "Follow exactly the format of the TZ Database Name column"; \
read -p "Server Time Zone (e.g. Etc/UTC):" TZ; \
rpl TIMEZONE=Etc/UTC TIMEZONE=$$TZ .env; \
echo "#TIMEZONE CONFIGURED" >> .env; \
fi
configure-postgres: configure-timezone
@make check-env
@echo "=========================:"
@echo "Postgres configuration:"
@echo "=========================:"
@export PASSWD=$$(pwgen 20 1); \
rpl POSTGRES_PASSWORD=docker POSTGRES_PASSWORD=$$PASSWD .env; \
echo "Postgres password set to $$PASSWD"
@echo "We are going to enable access to Postgres on your host."
@echo "Typically you would do this when you want to access the database"
@echo "from software such as QGIS that can directly connect to a Postgres"
@echo "database. There are some security implications to running on "
@echo "a publicly accessible port. People with credentials to access your "
@echo "database may use those credentials to launch arbitrary applications "
@echo "inside the database container if you do not manage the permissions carefully."
@echo "Note that the database is configured to require"
@echo "SSL secure encryption on all connections to the database. This includes"
@echo "internally between docker containers and from an external client. So be sure"
@echo "to set your client SSL mode to 'REQUIRE' (e.g. in QGIS / GeoServer / Node-Red etc.)."
@echo
@echo "If you want to allow/disallow access to this service from other hosts, please use"
@echo "firewall software such as ufw (uncomplicated firewall) to allow traffic on"
@echo "your chosen public port."
@echo
@echo "Enter to the public port to access PG from the host."
@echo
@read -p "Postgis Public Port (e.g. 5432):" PORT; \
rpl POSTGRES_PUBLIC_PORT=5432 POSTGRES_PUBLIC_PORT=$$PORT .env;
@touch conf/pg_conf/pg_service.conf
start-postgres:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting Postgres"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d
stop-postgres:
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping Postgres"
@echo "------------------------------------------------------------------"
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill db
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm db
restart-postgres:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting Postgres"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill db
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm db
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d db
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f db
disable-postgres:
@make check-env
@echo "This is currently a stub"
# Remove from enabled-profiles
@sed -i '/db/d' enabled-profiles
db-logs:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling db logs. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f db
db-shell: ## Create a bash shell in the db container
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating db bash shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db bash
db-psql-shell: ## Create a psql session in the db container connected to the gis database
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating db psql shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql gis
backup-db-qgis-styles: ## Backup QGIS Styles in the gis database
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up QGIS styles stored in the gis database"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump --clean -f /tmp/qgis-styles.sql -t public.layer_styles gis
@docker cp osgisstack_db_1:/tmp/qgis-styles.sql backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/qgis-styles.sql
@cp backups/qgis-styles.sql backups/qgis-styles-$$(date +%Y-%m-%d).sql
@ls -lah backups/qgis-styles*.sql
restore-db-qgis-styles:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring the last back up of QGIS styles to the gis database"
@echo "If you wish to restore an older backup, first copy it to /backups/qgis-styles.sql"
@echo "Note: Restoring will OVERWRITE your current public.layer_styles table in the gis database."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@docker cp backups/qgis-styles.sql osgisstack_db_1:/tmp/
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -f /tmp/qgis-styles.sql -d gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec db rm /tmp/qgis-styles.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "select stylename from layer_styles;" gis
backup-db-qgis-projects:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up QGIS projects stored in the gis database"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump --clean -f /tmp/qgis-projects.sql -t public.qgis_projects gis
@docker cp osgisstack_db_1:/tmp/qgis-projects.sql backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/qgis-projects.sql
@cp backups/qgis-projects.sql backups/qgis-projects-$$(date +%Y-%m-%d).sql
@ls -lah backups/qgis-projects*.sql
restore-db-qgis-projects:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring the last back up of QGIS projects to the gis database"
@echo "If you wish to restore an older backup, first copy it to /backups/qgis-projects.sql"
@echo "Note: Restoring will OVERWRITE your current public.qgis_projects table in the gis database."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@docker cp backups/qgis-projects.sql osgisstack_db_1:/tmp/
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -f /tmp/qgis-projects.sql -d gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec db rm /tmp/qgis-projects.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "select name from public.qgis_projects;" gis
backup-db-gis: ## Backup the gis database
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up the entire gis database"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump --clean -f /tmp/osgisstack-gis-database.sql gis
@docker cp osgisstack_db_1:/tmp/osgisstack-gis-database.sql backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/osgisstack-gis-database.sql
@cp backups/osgisstack-gis-database.sql backups/osgisstack-gis-database-$$(date +%Y-%m-%d).sql
@ls -lah backups/osgisstack-gis-database*.sql
restore-db-gis: ## Restore the gis database from a back up
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring the last back up the entire gis database"
@echo "If you wish to restore an older backup, first copy it to /backups/osgisstack-gis-database.sql"
@echo "Note: Restoring will OVERWRITE your current gis database."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@docker cp backups/osgisstack-gis-database.sql osgisstack_db_1:/tmp/
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -f /tmp/osgisstack-gis-database.sql -d gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec db rm /tmp/osgisstack-gis-database.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "\dn;" gis
list-database-sizes: ## Show the disk space used by each database
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Listing the sizes of all postgres databases"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db bash -c "psql -c '\l+' > /tmp/listing.txt; cat /tmp/listing.txt | sed 's/--//g'" | sed 's/ //g' | awk 'BEGIN { FS = "|" } {print $$1 ":" $$7}' | tail -n +4 | head -n -5
backup-db-mergin-base-schema:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up the mergin base schema from the gis database"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump --clean -f /tmp/mergin-base-schema.sql -n mergin_sync_base_do_not_touch gis
@docker cp osgisstack_db_1:/tmp/mergin-base-schema.sql backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/mergin-base-schema.sql
@cp backups/mergin-base-schema.sql backups/mergin-base-schema-$$(date +%Y-%m-%d).sql
@ls -lah backups/mergin-base-schema*.sql
restore-db-mergin-base-schema:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring the last back up of the mergin base schema to the gis database"
@echo "If you wish to restore an older backup, first copy it to /backups/mergin-base-schema.sql"
@echo "Note: Restoring will OVERWRITE your current mergin_sync_base_do_not_touch schema in the gis database."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@docker cp backups/mergin-base-schema.sql osgisstack_db_1:/tmp/mergin-base-schema.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -f /tmp/mergin-base-schema.sql -d gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec db rm /tmp/mergin-base-schema.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "\dt mergin_sync_base_do_not_touch.;" gis
backup-all-databases: ## Backup all postgresql databases
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up all postgres databases"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dumpall --clean -f /tmp/osgisstack-all-databases.sql
@docker cp osgisstack_db_1:/tmp/osgisstack-all-databases.sql backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/osgisstack-all-databases.sql
@cp backups/osgisstack-all-databases.sql backups/osgisstack-all-databases-$$(date +%Y-%m-%d).sql
@ls -lah backups/osgisstack-all-databases*.sql
restore-all-databases: ## Backup all postgresql databases
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring last back up of all postgres databases"
@echo "If you wish to restore an older backup, first copy it to /backups/osgisstack-all-databases.sql"
@echo "Note: Restoring will OVERWRITE all your current postgres databases."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@docker cp backups/osgisstack-all-databases.sql osgisstack_db_1:/tmp/
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -f /tmp/osgisstack-all-databases.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec db rm /tmp/osgisstack-all-databases.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "\l+"
#----------------- Jupyter --------------------------
deploy-jupyter: build-jupyter enable-jupyter configure-jupyter start-jupyter jupyter-token
# You need to ensure the build happens before running since we
# dont use a published docker repo
build-jupyter:
@echo
@echo "------------------------------------------------------------------"
@echo "Building Jupyter"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose build jupyter
enable-jupyter:
@make check-env
-@cd conf/nginx_conf/locations; ln -s jupyter.conf.available jupyter.conf
@echo "jupyter" >> enabled-profiles
configure-jupyter:
@echo
@echo "------------------------------------------------------------------"
@echo "Configuring Jupyter"
@echo "------------------------------------------------------------------"
start-jupyter:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting Jupyter"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d
make jupyter-token
stop-jupyter:
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping Jupyter"
@echo "------------------------------------------------------------------"
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill jupyter
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm jupyter
disable-jupyter:
@make check-env
# Remove symlinks
@cd conf/nginx_conf/locations; rm jupyter.conf
# Remove from enabled-profiles
@sed -i '/jupyter/d' enabled-profiles
jupyter-token:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Getting Jupyter token"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec jupyter bash -c "jupyter notebook list" | grep -E -i -o '=[0-9a-f]*' | sed 's/=//'
jupyter-logs:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling jupyter logs. Press Ctrl-c to exit."
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f jupyter
jupyter-shell: ## Create a bash shell in the jupyter container
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating jupyter bash shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec jupyter bash
jupyter-root-shell: ## Create a root bash shell in the jupyter container
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating jupyter root bash shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u root jupyter bash
restart-jupyter:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting jupyter"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill jupyter