-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile_hugo
1971 lines (1700 loc) · 89 KB
/
Makefile_hugo
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-db-qgis-styles
-@make backup-db-qgis-project
@make backup-db
@make backup-all-databases
-@make backup-mergin-base-db-schema
@make backup-node-red
@make backup-mosquitto
@make backup-jupyter
# We need to declare phony here since the docs dir exists
# otherwise make tries to execute the docs file directly
.PHONY: docs
docs: ## Generate documentation and place results in docs folder.
@echo
@echo "------------------------------------------------------------------"
@echo "Making sphinx docs"
@echo "------------------------------------------------------------------"
$(MAKE) -C sphinx html
@cp -r sphinx/build/html/* docs
$(MAKE) -C sphinx latexpdf
@cp sphinx/build/latex/osgs.pdf osgs-manual.pdf
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, scp 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-scp
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 validemail@yourdomain.org $$EMAIL init-letsencrypt.sh .env
make site-config
make enable-hugo
make configure-scp
make configure-htpasswd
make deploy
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
#------------------ 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 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
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"
@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
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose run --rm -v ${PWD}/backups:/backups nginx sh -c "tar cvfz /backups/hugo-backup.tar.gz /hugo"
@cp backups/hugo-backup.tar.gz backups/hugo-backup-$$(date +%Y-%m-%d).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 wist 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 content dir."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
-@mkdir -p backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose run --rm -v ${PWD}/backups:/backups nginx sh -c "cd /hugo && tar xvfz /backups/hugo-backup.tar.gz --strip 1"
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
#----------------- SCP --------------------------
deploy-scp: enable-scp configure-scp start-scp ## Deploy the Secure Copy service.
enable-scp: ## Enable the Secure Copy service.
@make check-env
@echo "scp" >> enabled-profiles
configure-scp: ## Configure the Secure Copy service.
@make check-env
@echo "------------------------------------------------------------------"
@echo "Copying .ssh/authorized keys to all scp shares."
@echo "------------------------------------------------------------------"
@cat ~/.ssh/authorized_keys > conf/scp_conf/geoserver_data
@cat ~/.ssh/authorized_keys > conf/scp_conf/qgis_projects
@cat ~/.ssh/authorized_keys > conf/scp_conf/qgis_fonts
@cat ~/.ssh/authorized_keys > conf/scp_conf/qgis_svg
@cat ~/.ssh/authorized_keys > conf/scp_conf/hugo_static
@cat ~/.ssh/authorized_keys > conf/scp_conf/hugo_data
@cat ~/.ssh/authorized_keys > conf/scp_conf/odm_data
@cat ~/.ssh/authorized_keys > conf/scp_conf/general_data
@cat ~/.ssh/authorized_keys > conf/scp_conf/jupyter_data
start-scp: ## Start the Secure Copy service.
@make check-env
@echo "------------------------------------------------------------------"
@echo "Starting SCP"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d scp
stop-scp: ## Stop the Secure Copy services.
@echo
@echo "------------------------------------------------------------------"
@echo "Stopping SCP"
@echo "------------------------------------------------------------------"
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill scp
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm scp
disable-scp: ## Disable the Secure Copy service.
# Remove from enabled-profiles
@sed -i '/db/d' enabled-profiles
scp-logs: ## Show the logs for the Secure Copy service.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Polling SCP logs"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f scp
scp-shell: ## Create a shell inside the Secure Copy container for debugging.
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Creating SCP shell"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec scp sh
#----------------- 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
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"
@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
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
make stop-qgis-desktop
make start-qgis-desktop
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
disable-qgis-server:
@make check-env
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill qgis-server
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm qgis-server
@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"
@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
reinitialise-qgis-server:rm-qgis-server start-qgis-server
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting QGIS Server and Nginx"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f qgis-server
#----------------- 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 Server"
@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 Server and Nginx"
@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
disable-qgis-desktop:
@make check-env
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose kill qgis-desktop
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm qgis-desktop
@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"
@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
reinitialise-qgis-desktop:stop-qgis-desktop start-qgis-desktop
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restarting QGIS Desktop and Nginx"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart nginx
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f qgis-desktop
#----------------- 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/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 reinitialise-mapproxy"
start-mapproxy:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting Mapproxy"
@echo "------------------------------------------------------------------"
@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
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"
@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
reinitialise-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
#----------------- 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;
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
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"
@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
reinitialise-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
backup-db-qgis-styles: ## Backup QGIS Styles in the gis database
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up QGIS styles stored in gis db"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump -f /tmp/QGISStyles.sql -t layer_styles gis
@docker cp osgisstack_db_1:/tmp/QGISStyles.sql backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/QGISStyles.sql
@cp backups/QGISStyles.sql backups/QGISStyles-$$(date +%Y-%m-%d).sql
@ls -lah backups/*.sql
restore-db-qgis-styles:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring QGIS styles to gis db"
@echo "------------------------------------------------------------------"
@docker cp backups/QGISStyles.sql osgisstack_db_1:/tmp/
# - at start of next line means error will be ignored (in case QGIS project table isnt already there)
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "drop table layer_styles;" gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -f /tmp/QGISStyles.sql -d gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec db rm /tmp/QGISStyles.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "select name from layer_styles;" gis
backup-db-qgis-project:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up QGIS project stored in db"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump -f /tmp/QGISProject.sql -t qgis_projects gis
@docker cp osgisstack_db_1:/tmp/QGISProject.sql backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/QGISProject.sql
@cp backups/QGISProject.sql backups/QGISProject-$$(date +%Y-%m-%d).sql
@ls -lah backups/*.sql
restore-db-qgis-project:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring QGIS project to db"
@echo "------------------------------------------------------------------"
@docker cp backups/QGISProject.sql osgisstack_db_1:/tmp/
# - at start of next line means error will be ignored (in case QGIS project table isnt already there)
-@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "drop table qgis_projects;" gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -f /tmp/QGISProject.sql -d gis
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec db rm /tmp/QGISProject.sql
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "select name from qgis_projects;" gis
backup-db: ## Backup the gis database
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up entire GIS postgres db"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump -Fc -f /tmp/osgisstack-gis-database.dmp gis
@docker cp osgisstack_db_1:/tmp/osgisstack-gis-database.dmp backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/osgisstack-gis-database.dmp
@cp backups/osgisstack-gis-database.dmp backups/osgisstack-gis-database-$$(date +%Y-%m-%d).dmp
@ls -lah backups/osgisstack-gis-database*
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-all-databases: ## Backup all postgresql databases
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up all postgres databases"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dumpall -f /tmp/osgisstack-all-databases.dmp
@docker cp osgisstack_db_1:/tmp/osgisstack-all-databases.dmp .
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/osgisstack-all-databases.dmp
@cp backups/osgisstack-all-databases.dmp backups/osgisstack-all-databases-$$(date +%Y-%m-%d).dmp
@ls -lah backups/osgisstack-all-databases*
restore-db: ## Restore the gis database from a back up
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring the entire GIS postgres db from a backup"
@echo "------------------------------------------------------------------"
@echo "This will irrevocably delete any pre-existing data in your database."
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@docker cp backups/osgisstack-gis-database.dmp osgisstack_db_1:/tmp/
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db psql -c "DROP DATABASE IF EXISTS gis WITH (FORCE);"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_restore -C -d postgres /tmp/osgisstack-gis-database.dmp
backup-mergin-base-db-schema:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up mergin base schema from postgres db"
@echo "------------------------------------------------------------------"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db pg_dump -Fc -f /tmp/mergin-base-schema.dmp -n mergin_sync_base_do_not_touch gis
@docker cp osgisstack_db_1:/tmp/mergin-base-schema.dmp backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose exec -u postgres db rm /tmp/mergin-base-schema.dmp
@cp backups/mergin-base-schema.dmp backups/mergin-base-schema-$$(date +%Y-%m-%d).dmp
@ls -lah backups/*.dmp
#----------------- 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"
@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 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
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose rm jupyter
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose up -d jupyter
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose logs -f jupyter
backup-jupyter:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up jupyter data to ./backups"
@echo "------------------------------------------------------------------"
-@mkdir -p backups
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose run --entrypoint /bin/bash --rm -w / -v $${PWD}/backups:/backups jupyter -c "/bin/tar cvfz /backups/jupyter-backup.tar.gz /home"
@cp backups/jupyter-backup.tar.gz backups/jupyter-backup-$$(date +%Y-%m-%d).tar.gz
@ls -lah backups/jupyter*.tar.gz
restore-jupyter:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Restore last backup of jupyter from /backups/jupyter-backup.tar.gz"
@echo "If you wish to restore an older backup, first copy it to /backups/jupyter-backup.tar.gz"
@echo "Note: Restoring will OVERWRITE all data currently in your jupyter home dir."
@echo "------------------------------------------------------------------"
@echo -n "Are you sure you want to continue? [y/N] " && read ans && [ $${ans:-N} = y ]
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose run --entrypoint /bin/bash --rm -w / jupyter -c "rm -rf /home/*"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose run --entrypoint /bin/bash --rm -w / -v ${PWD}/backups:/backups jupyter -c "cd /home && tar xvfz /backups/jupyter-backup.tar.gz --strip 1"
@COMPOSE_PROFILES=$(shell paste -sd, enabled-profiles) docker-compose restart jupyter
#----------------- survey solutions --------------------------
deploy-surveysolutions: enable-surveysolutions configure-surveysolutions start-surveysolutions
enable-surveysolutions:
@make check-env
-@cd conf/nginx_conf/locations; ln -s surveysolutions.conf.available surveysolutions.conf
@echo "surveysolutions" >> enabled-profiles
configure-surveysolutions:
@echo
@echo "------------------------------------------------------------------"
@echo "Configuring SurveySolutions"
@echo "------------------------------------------------------------------"
@echo "Please edit .env and set the database password in the XXXXXX area"
@echo "of the HQ_URL string"
start-surveysolutions:
@make check-env
@echo
@echo "------------------------------------------------------------------"
@echo "Starting SurveySolutions"
@echo "------------------------------------------------------------------"