##// END OF EJS Templates
multiple changes...
super-admin -
Show More
@@ -0,0 +1,12 b''
1 Put any custom overrides and compose files here.
2
3 e.g
4
5 - docker-compose-services.override.yaml
6 - docker-compose-router.override.yaml
7 - docker-compose-metrics.override.yaml
8 - docker-compose-apps.override.yaml
9
10 Passing variables to containers
11
12 .runtime.env No newline at end of file
@@ -0,0 +1,31 b''
1 version: '3.9'
2
3 services:
4
5 rhodecode:
6 ports:
7 - "10020:10020"
8 environment:
9 DB_UPGRADE: 0 # run the DB upgrade
10 SETUP_APP: 0 # run the application default settings setup, can be turned off after initial run
11
12 deploy:
13 replicas: 1
14
15 vcsserver:
16 environment:
17 {}
18 deploy:
19 replicas: 1
20
21 sshd:
22 {}
23
24 svn:
25 {}
26
27 celery-beat:
28 {}
29
30 celery:
31 {}
@@ -0,0 +1,31 b''
1 version: '3.9'
2
3 services:
4
5 promtail:
6 {}
7
8 loki:
9 labels:
10 - "traefik.enable=false"
11 # - "traefik.http.services.loki.loadbalancer.server.port=3100"
12 # - "traefik.http.services.loki.loadbalancer.server.port=9095"
13
14 prometheus:
15 {}
16
17 node-exporter:
18 {}
19
20 statsd-exporter:
21 {}
22
23 grafana:
24
25 labels:
26 # SSL + proxy prefix
27 - "traefik.http.routers.grafana-rt.service=grafana-ssl"
28 - "traefik.http.routers.grafana-rt.entrypoints=https"
29 - "traefik.http.routers.grafana-rt.rule=Host(`your-domain.com`) && PathPrefix(`/_grafana`)"
30 - "traefik.http.routers.grafana-rt.tls=true"
31 - "traefik.http.services.grafana-ssl.loadbalancer.server.port=3000" No newline at end of file
@@ -0,0 +1,43 b''
1 version: '3.9'
2
3 ## docker network create -d overlay lb-net
4 services:
5
6 traefik:
7
8 volumes:
9 # So that Traefik can listen to the Docker events
10 - /var/run/docker.sock:/var/run/docker.sock
11 # custom traefik config, enable SSL etc..
12 - $PWD/.custom/traefik_custom:/etc/traefik
13
14 portainer:
15 # Run with COMPOSE_PROFILES=portainer
16 # to access portainer set HEADER `X-Docker-Host=portainer`
17 image: portainer/portainer-ce:latest
18 restart: always
19 volumes:
20 - portainer_data:/data
21 - /var/run/docker.sock:/var/run/docker.sock
22 deploy:
23 mode: replicated
24 replicas: 1
25 placement:
26 constraints:
27 # limit swarm deploy to MANAGER only
28 - node.role == manager
29
30 networks:
31 - rhodecode_network
32 labels:
33 - "traefik.enable=true"
34 - "traefik.http.routers.portainer.entrypoints=https"
35 - "traefik.http.routers.portainer.rule=Headers(`X-Docker-Host`, `portainer`)"
36 - "traefik.http.services.portainer.loadbalancer.server.port=9000"
37
38 profiles:
39 ["portainer"]
40
41 volumes:
42 portainer_data:
43 external: true No newline at end of file
@@ -0,0 +1,24 b''
1 version: '3.9'
2 ## This is a final override file for services stack
3 ## Add your own customizations
4
5 ## docker network create -d overlay lb-net
6 services:
7
8 database:
9 {}
10
11 database-mysql:
12 {}
13
14 redis:
15 {}
16
17 elasticsearch:
18 {}
19
20 nginx:
21 {}
22
23 channelstream:
24 {} No newline at end of file
@@ -9,8 +9,8 b' RC_VERSION="4.28.0.REL20221120_SOURCE"'
9 9
10 10 # ce, or ee
11 11 RC_EDITION=ee
12 RC_IMAGE_CE="rhodecode/rhodecode-ee:$RC_VERSION"
13 RC_IMAGE_EE="rhodecode/rhodecode-ce:$RC_VERSION"
12 RC_IMAGE_CE="rhodecode/rhodecode-ce:$RC_VERSION"
13 RC_IMAGE_EE="rhodecode/rhodecode-ee:$RC_VERSION"
14 14
15 15 # Database bootstrap/access credentials
16 16 DB_NAME=rhodecode
@@ -6,8 +6,9 b''
6 6 # Source code downloaded
7 7 .source/*
8 8
9 # Custom / override wont be tracked
9 # Custom / override wont be tracked, except README file
10 10 .custom/*
11 !.custom/README.md
11 12
12 13 # LOGS
13 14 logs/*.log
@@ -19,5 +20,4 b' logs/postgres/*.log'
19 20 .idea
20 21 config/_shared/.rcmetadata.json
21 22
22 .rccontrol-bootstrap
23 23 .rccontrol.ini No newline at end of file
@@ -41,6 +41,7 b' log_format json_log_custom escape=json'
41 41 '"remote_user":"$remote_user",'
42 42 '"time_local":"$time_local",'
43 43 '"remote_addr":"$remote_addr",'
44 '"host":"$host",'
44 45 '"proxy_x_forwarded_for":"$proxy_add_x_forwarded_for",'
45 46 '"request":"$request",'
46 47 '"status": "$status",'
@@ -49,6 +50,7 b' log_format json_log_custom escape=json'
49 50 '"request_time":"$request_time",'
50 51 '"upstream_response_time":"$upstream_response_time",'
51 52 '"http_referrer":"$http_referer",'
53 '"http_scheme":"$scheme",'
52 54 '"http_user_agent":"$http_user_agent"'
53 55 '}';
54 56
@@ -56,7 +58,7 b' log_format json_log_custom escape=json'
56 58 server {
57 59 listen 80 default;
58 60 # ensure we get the proper Docker DNS resolver for load balancing.
59 resolver 127.0.0.11 ipv6=off;
61 resolver 127.0.0.11 ipv6=off valid=10s;
60 62 server_name localhost 127.0.0.1;
61 63 access_log /dev/stdout json_log_custom;
62 64 error_log /dev/stdout;
@@ -68,6 +70,11 b' server {'
68 70 # maximum number and size of buffers for large headers to read from client request
69 71 large_client_header_buffers 16 256k;
70 72
73 location /_health {
74 add_header 'Content-Type' 'application/json';
75 return 200 '{"status":"UP"}';
76 }
77
71 78 ## serve static files by nginx, recommended
72 79 location /_static/rhodecode {
73 80 gzip on;
@@ -84,6 +91,7 b' server {'
84 91
85 92 ## channelstream location handler, if channelstream live chat and notifications
86 93 ## are enable this will proxy the requests to channelstream websocket server
94 set $upstream_channelstream channelstream:8000;
87 95 location /_channelstream {
88 96 rewrite /_channelstream/(.*) /$1 break;
89 97 gzip off;
@@ -94,17 +102,18 b' server {'
94 102 proxy_read_timeout 10m;
95 103
96 104 proxy_set_header Host $host;
97 proxy_set_header X-Real-IP $remote_addr;
105 proxy_set_header Referer $http_referer;
98 106 proxy_set_header X-Url-Scheme $scheme;
99 proxy_set_header X-Forwarded-Proto $scheme;
107 proxy_set_header X-Real-IP $remote_addr;
100 108 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
109 proxy_set_header X-Forwarded-Proto $scheme;
101 110
102 111 proxy_http_version 1.1;
103 112 proxy_set_header Upgrade $http_upgrade;
104 113 proxy_set_header Connection "upgrade";
105 114
106 set $upstream_channelstream http://channelstream:8000;
107 proxy_pass $upstream_channelstream;
115 proxy_pass http://$upstream_channelstream;
116 proxy_redirect http://$upstream_channelstream/ /_channelstream;
108 117 }
109 118
110 119 # ## rate limit this endpoint to prevent login page brute-force attacks
@@ -113,16 +122,16 b' server {'
113 122 # try_files $uri @rhodecode_http;
114 123 # }
115 124
116 location / {
117 include /etc/nginx/proxy.conf;
118 try_files $uri @rhodecode_http;
119 }
120
121 location @rhodecode_http {
122 set $upstream http://rhodecode:10020;
123 include /etc/nginx/proxy.conf;
124 proxy_pass $upstream;
125 }
125 # location / {
126 # include /etc/nginx/proxy.conf;
127 # try_files $uri @rhodecode_http;
128 # }
129 #
130 # set $upstream http://rhodecode:10020;
131 # location @rhodecode_http {
132 # include /etc/nginx/proxy.conf;
133 # proxy_pass $upstream;
134 # }
126 135
127 136 ## Custom 502 error page.
128 137 ## Will be displayed while RhodeCode server is turned off
@@ -27,9 +27,9 b' proxy_set_header X-Real-IP $remote_addr;'
27 27 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28 28 proxy_set_header Proxy-host $proxy_host;
29 29
30 proxy_connect_timeout 7200;
31 proxy_send_timeout 7200;
32 proxy_read_timeout 7200;
30 proxy_connect_timeout 21600;
31 proxy_send_timeout 21600;
32 proxy_read_timeout 21600;
33 33 proxy_buffers 8 32k;
34 34
35 35 add_header X-Frame-Options SAMEORIGIN;
@@ -7,8 +7,8 b' entryPoints:'
7 7 https:
8 8 address: ":443"
9 9
10 # ssh:
11 # address: ":${RC_SSH_PORT:?must-specify-ssh-port}"
10 ssh:
11 address: ":${RC_SSH_PORT:?must-specify-ssh-port}"
12 12
13 13 traefik:
14 14 address: ":7000"
@@ -11,13 +11,6 b' x-logging: &custom-logging'
11 11 loki-timeout: "1s"
12 12 loki-max-backoff: "800ms"
13 13
14 volumes:
15
16 # volume for RhodeCode repo-store, it's where the repositories will be stored
17 rhodecode_repos:
18 labels:
19 "keep": 1
20
21 14
22 15 services:
23 16
@@ -35,8 +28,11 b' services:'
35 28 "--name=gunicorn-rhodecode-1",
36 29 "--error-logfile=-",
37 30 "--paster=/etc/rhodecode/conf/rhodecode.optimized.ini",
38 "--config=/etc/rhodecode/conf/gunicorn_conf.py"
31 "--config=/etc/rhodecode/conf/gunicorn_conf_rc.py"
39 32 ]
33 deploy:
34 # override this in .custom/docker-compose-apps.override.yaml to scale up
35 replicas: 1
40 36
41 37 # ports:
42 38 # - "127.0.0.1::10020"
@@ -85,7 +81,7 b' services:'
85 81 volumes:
86 82 - confvolume:/etc/rhodecode/conf
87 83 - logvolume:/var/log/rhodecode
88 - rhodecode_repos:/var/opt/rhodecode_repo_store
84 - rc_reposvolume:/var/opt/rhodecode_repo_store
89 85 - rc_datavolume:/var/opt/rhodecode_data
90 86
91 87 tmpfs:
@@ -95,7 +91,10 b' services:'
95 91 *custom-logging
96 92
97 93 labels:
98 - "traefik.enable=false"
94 - "traefik.enable=true"
95 - "traefik.http.routers.rhodecode.entrypoints=http"
96 - "traefik.http.routers.rhodecode.rule=Host(`${RHODECODE_HOSTNAME:?must-specify-rhodecode-hostname}`)"
97 - "traefik.http.services.rhodecode.loadbalancer.server.port=10020"
99 98
100 99 vcsserver:
101 100 networks:
@@ -113,6 +112,9 b' services:'
113 112 "--paster=/etc/rhodecode/conf/vcsserver.optimized.ini",
114 113 "--config=/etc/rhodecode/conf/gunicorn_conf_vcs.py"
115 114 ]
115 deploy:
116 # override this in .custom/docker-compose-apps.override.yaml to scale up
117 replicas: 1
116 118
117 119 # ports:
118 120 # - "127.0.0.1::10010"
@@ -137,7 +139,7 b' services:'
137 139 volumes:
138 140 - confvolume:/etc/rhodecode/conf
139 141 - logvolume:/var/log/rhodecode
140 - rhodecode_repos:/var/opt/rhodecode_repo_store
142 - rc_reposvolume:/var/opt/rhodecode_repo_store
141 143 - rc_datavolume:/var/opt/rhodecode_data
142 144
143 145 logging:
@@ -178,7 +180,7 b' services:'
178 180 volumes:
179 181 - confvolume:/etc/rhodecode/conf
180 182 - logvolume:/var/log/rhodecode
181 - rhodecode_repos:/var/opt/rhodecode_repo_store
183 - rc_reposvolume:/var/opt/rhodecode_repo_store
182 184 - rc_datavolume:/var/opt/rhodecode_data
183 185
184 186 logging:
@@ -222,7 +224,7 b' services:'
222 224 volumes:
223 225 - confvolume:/etc/rhodecode/conf
224 226 - logvolume:/var/log/rhodecode
225 - rhodecode_repos:/var/opt/rhodecode_repo_store
227 - rc_reposvolume:/var/opt/rhodecode_repo_store
226 228 - rc_datavolume:/var/opt/rhodecode_data
227 229
228 230 logging:
@@ -269,7 +271,7 b' services:'
269 271 volumes:
270 272 - confvolume:/etc/rhodecode/conf
271 273 - logvolume:/var/log/rhodecode
272 - rhodecode_repos:/var/opt/rhodecode_repo_store
274 - rc_reposvolume:/var/opt/rhodecode_repo_store
273 275
274 276 logging:
275 277 *custom-logging
@@ -297,7 +299,7 b' services:'
297 299 volumes:
298 300 - confvolume:/etc/rhodecode/conf
299 301 - logvolume:/var/log/rhodecode
300 - rhodecode_repos:/var/opt/rhodecode_repo_store
302 - rc_reposvolume:/var/opt/rhodecode_repo_store
301 303 - rc_datavolume:/var/opt/rhodecode_data
302 304
303 305 logging:
@@ -35,6 +35,11 b' volumes:'
35 35 rc_datavolume:
36 36 external: true
37 37
38 # volume for RhodeCode repo-store, it's where the repositories will be stored
39 # must be run via: docker volume create --name=rc_reposvolume
40 rc_reposvolume:
41 external: true
42
38 43 networks:
39 44
40 45 # SHARED network for all containers
@@ -108,10 +108,6 b' services:'
108 108 volumes:
109 109 - ./config/loki:/etc/loki
110 110
111 labels:
112 - "traefik.enable=false"
113 - "traefik.http.services.loki.loadbalancer.server.port=3100"
114 - "traefik.http.services.loki.loadbalancer.server.port=9095"
115 111
116 112 promtail:
117 113 image: grafana/promtail:latest
@@ -45,34 +45,3 b' services:'
45 45
46 46 logging:
47 47 *custom-logging
48
49 portainer:
50 # Run with COMPOSE_PROFILES=portainer
51 # to access portainer set HEADER `X-Docker-Host=portainer`
52 image: portainer/portainer-ce:latest
53 restart: always
54 volumes:
55 - portainer_data:/data
56 - /var/run/docker.sock:/var/run/docker.sock
57 deploy:
58 mode: replicated
59 replicas: 1
60 placement:
61 constraints:
62 # limit swarm deploy to MANAGER only
63 - node.role == manager
64
65 networks:
66 - rhodecode_network
67 labels:
68 - "traefik.enable=true"
69 - "traefik.http.services.portainer.loadbalancer.server.port=9000"
70 - "traefik.http.routers.portainer.entrypoints=https"
71 - "traefik.http.routers.portainer.rule=Headers(`X-Docker-Host`, `portainer`)"
72
73 profiles:
74 ["portainer"]
75
76 volumes:
77 portainer_data:
78 external: true No newline at end of file
@@ -43,10 +43,10 b' services:'
43 43 # ports:
44 44 # - "127.0.0.1:9800:9800"
45 45
46 command: ["channelstream", "-i", "/etc/rhodecode/conf/channelstream.ini"]
46 command: ["channelstream"]
47 47
48 environment:
49 CHANNELSTREAM_ALLOW_POSTING_FROM: 0.0.0.0
48 env_file:
49 - .custom/.runtime.env
50 50
51 51 healthcheck:
52 52 test: [ "CMD", "curl", "-s", "-o", "/dev/null", "-w", "'%{http_code}'", "http://channelstream:8000/admin/sign_in" ]
@@ -81,7 +81,7 b' services:'
81 81
82 82 healthcheck:
83 83 # change port 80 to 443 when only using SSL
84 test: [ "CMD", "curl", "-A", "RhodeCode-Healthcheck", "-s", "-o", "/dev/null", "-w", "'%{http_code}'", "http://127.0.0.1:80/_admin/ops/ping" ]
84 test: [ "CMD", "curl", "-A", "RhodeCode-Healthcheck", "-s", "-o", "/dev/null", "-w", "'%{http_code}'", "http://127.0.0.1:80/_health" ]
85 85 timeout: 30s
86 86 interval: 60s
87 87 retries: 10
@@ -102,8 +102,8 b' services:'
102 102 labels:
103 103 - "traefik.enable=true"
104 104 - "traefik.http.routers.nginx.entrypoints=http"
105 - "traefik.http.routers.nginx.rule=Host(`${RHODECODE_HOSTNAME:?must-specify-rhodecode-hostname}`) && ( PathPrefix(`/_health`) || PathPrefix(`/_channelstream`) || PathPrefix(`/_static/rhodecode`) )"
105 106 - "traefik.http.services.nginx.loadbalancer.server.port=80"
106 - "traefik.http.routers.nginx.rule=Host(`${RHODECODE_HOSTNAME:?must-specify-rhodecode-hostname}`)"
107 107
108 108 elasticsearch:
109 109 networks:
This diff has been collapsed as it changes many lines, (1544 lines changed) Show them Hide them
@@ -36,9 +36,6 b' rccontrol_usage() {'
36 36 printf "Commands:\n"
37 37 echo " self-update update rccontrol and it's docker definitions"
38 38 echo " bootstrap Bootstrap this machine, check docker version and install rhodecode-network"
39 echo " stack run one of available cluster stacks, use -h for more details"
40 echo " stack-status show stack status"
41 echo " stack-upgrade upgrade ALL stack status"
42 39 echo
43 40 printf "Build Commands:\n"
44 41 echo " get-build-artifacts Fetch Artifacts to run installer based build"
@@ -46,10 +43,13 b' rccontrol_usage() {'
46 43 echo " get-build-source Fetch RhodeCode sources, store in .source dir to run a source-based builds"
47 44 echo " build-source Build RhodeCode image from source, requires upgrade-source initially"
48 45 echo
46 printf "Stack Commands:\n"
47 echo " stack run one of available cluster stacks, use -h for more details"
48 echo " stack-status Show stack status"
49 echo " stack-upgrade upgrade ALL stack status"
50 echo
49 51 printf "CLI Commands:\n"
50 echo " cli-redis CLI"
51 echo " cli-db CLI"
52 echo " cli-db-upgrade CLI"
52 echo " cli run various CLI tools"
53 53 echo
54 54 printf "Backup Commands:\n"
55 55 echo " backup-db CLI"
@@ -172,7 +172,7 b' rccontrol_bootstrap_usage() {'
172 172
173 173 fi
174 174
175 printf "Alias: install\n"
175 printf "Alias: init\n"
176 176 echo
177 177
178 178 printf "Usage:\n"
@@ -318,7 +318,7 b' rccontrol_get_build_source_usage() {'
318 318 fi
319 319
320 320 printf "Usage:\n"
321 printf " rccontrol get-build-source REVISION [OPTIONS]\n"
321 printf " rccontrol get-build-source [OPTIONS]\n"
322 322 printf " rccontrol get-build-source --help | -h\n"
323 323 echo
324 324
@@ -333,6 +333,12 b' rccontrol_get_build_source_usage() {'
333 333
334 334 # :command.usage_flags
335 335 # :flag.usage
336 echo " --revision REVISION"
337 printf " revision to download\n"
338 printf " Default: default\n"
339 echo
340
341 # :flag.usage
336 342 echo " --auth-token AUTH_TOKEN"
337 343 printf " Specify AUTH TOKEN to obtain sources\n"
338 344 echo
@@ -343,14 +349,6 b' rccontrol_get_build_source_usage() {'
343 349 printf " Default: https://code.rhodecode.com\n"
344 350 echo
345 351
346 # :command.usage_args
347 printf "Arguments:\n"
348
349 # :argument.usage
350 echo " REVISION"
351 printf " revision to download\n"
352 echo
353
354 352 # :command.usage_examples
355 353 printf "Examples:\n"
356 354 printf " rccontrol3 get-sources $RC_CLI_VERSION_NAME\n"
@@ -414,8 +412,86 b' rccontrol_stack_usage() {'
414 412 fi
415 413
416 414 printf "Usage:\n"
417 printf " rccontrol stack NAME [SERVICES PARAMS...]\n"
418 printf " rccontrol stack --help | -h\n"
415 printf " rccontrol stack COMMAND\n"
416 printf " rccontrol stack [COMMAND] --help | -h\n"
417 echo
418 # :command.usage_commands
419 printf "Commands:\n"
420 echo " router run the router stack"
421 echo " metrics run the router stack"
422 echo " services run the router stack"
423 echo " rhodecode run the router stack"
424 echo " all run all stacks"
425 echo
426
427 # :command.long_usage
428 if [[ -n $long_usage ]]; then
429 printf "Options:\n"
430
431 # :command.usage_fixed_flags
432 echo " --help, -h"
433 printf " Show this help\n"
434 echo
435
436 # :command.usage_examples
437 printf "Examples:\n"
438 printf " - ./rccontrol3 stack router up # run router stack with output to\n console\n - ./rccontrol3 stack router up --detach # run router stack detached\n - ./rccontrol3 stack router down # stop whole router stack\n - ./rccontrol3 stack router ps # check status of router stack\n - ./rccontrol3 stack router -f docker-overrides.yaml up -d # run router stack\n with your overrides\n"
439 echo
440
441 fi
442 }
443
444 # :command.usage
445 rccontrol_stack_router_usage() {
446 if [[ -n $long_usage ]]; then
447 printf "rccontrol stack router - run the router stack\n"
448 echo
449
450 else
451 printf "rccontrol stack router - run the router stack\n"
452 echo
453
454 fi
455
456 printf "Usage:\n"
457 printf " rccontrol stack router [SERVICES PARAMS...]\n"
458 printf " rccontrol stack router --help | -h\n"
459 echo
460
461 # :command.long_usage
462 if [[ -n $long_usage ]]; then
463 printf "Options:\n"
464
465 # :command.usage_fixed_flags
466 echo " --help, -h"
467 printf " Show this help\n"
468 echo
469
470 # :command.usage_args
471 printf "Arguments:\n"
472
473 echo " SERVICES PARAMS..."
474 printf " Additional arguments or flags for services command\n"
475 echo
476
477 fi
478 }
479
480 # :command.usage
481 rccontrol_stack_metrics_usage() {
482 if [[ -n $long_usage ]]; then
483 printf "rccontrol stack metrics - run the router stack\n"
484 echo
485
486 else
487 printf "rccontrol stack metrics - run the router stack\n"
488 echo
489
490 fi
491
492 printf "Usage:\n"
493 printf " rccontrol stack metrics [SERVICES PARAMS...]\n"
494 printf " rccontrol stack metrics --help | -h\n"
419 495 echo
420 496
421 497 # :command.long_usage
@@ -430,19 +506,116 b' rccontrol_stack_usage() {'
430 506 # :command.usage_args
431 507 printf "Arguments:\n"
432 508
433 # :argument.usage
434 echo " NAME"
435 printf " Stack name\n"
436 printf " Allowed: router, metrics, services, rhodecode\n"
509 echo " SERVICES PARAMS..."
510 printf " Additional arguments or flags for services command\n"
511 echo
512
513 fi
514 }
515
516 # :command.usage
517 rccontrol_stack_services_usage() {
518 if [[ -n $long_usage ]]; then
519 printf "rccontrol stack services - run the router stack\n"
520 echo
521
522 else
523 printf "rccontrol stack services - run the router stack\n"
524 echo
525
526 fi
527
528 printf "Usage:\n"
529 printf " rccontrol stack services [SERVICES PARAMS...]\n"
530 printf " rccontrol stack services --help | -h\n"
531 echo
532
533 # :command.long_usage
534 if [[ -n $long_usage ]]; then
535 printf "Options:\n"
536
537 # :command.usage_fixed_flags
538 echo " --help, -h"
539 printf " Show this help\n"
437 540 echo
438 541
542 # :command.usage_args
543 printf "Arguments:\n"
544
439 545 echo " SERVICES PARAMS..."
440 546 printf " Additional arguments or flags for services command\n"
441 547 echo
442 548
443 # :command.usage_examples
444 printf "Examples:\n"
445 printf " - ./rccontrol3 stack router up # run router stack with output to\n console\n - ./rccontrol3 stack router up --detach # run router stack detached\n - ./rccontrol3 stack router down # stop whole router stack\n - ./rccontrol3 stack router ps # check status of router stack\n - ./rccontrol3 stack router -f docker-overrides.yaml up -d # run router stack\n with your overrides\n"
549 fi
550 }
551
552 # :command.usage
553 rccontrol_stack_rhodecode_usage() {
554 if [[ -n $long_usage ]]; then
555 printf "rccontrol stack rhodecode - run the router stack\n"
556 echo
557
558 else
559 printf "rccontrol stack rhodecode - run the router stack\n"
560 echo
561
562 fi
563
564 printf "Usage:\n"
565 printf " rccontrol stack rhodecode [SERVICES PARAMS...]\n"
566 printf " rccontrol stack rhodecode --help | -h\n"
567 echo
568
569 # :command.long_usage
570 if [[ -n $long_usage ]]; then
571 printf "Options:\n"
572
573 # :command.usage_fixed_flags
574 echo " --help, -h"
575 printf " Show this help\n"
576 echo
577
578 # :command.usage_args
579 printf "Arguments:\n"
580
581 echo " SERVICES PARAMS..."
582 printf " Additional arguments or flags for services command\n"
583 echo
584
585 fi
586 }
587
588 # :command.usage
589 rccontrol_stack_all_usage() {
590 if [[ -n $long_usage ]]; then
591 printf "rccontrol stack all - run all stacks\n"
592 echo
593
594 else
595 printf "rccontrol stack all - run all stacks\n"
596 echo
597
598 fi
599
600 printf "Usage:\n"
601 printf " rccontrol stack all [SERVICES PARAMS...]\n"
602 printf " rccontrol stack all --help | -h\n"
603 echo
604
605 # :command.long_usage
606 if [[ -n $long_usage ]]; then
607 printf "Options:\n"
608
609 # :command.usage_fixed_flags
610 echo " --help, -h"
611 printf " Show this help\n"
612 echo
613
614 # :command.usage_args
615 printf "Arguments:\n"
616
617 echo " SERVICES PARAMS..."
618 printf " Additional arguments or flags for services command\n"
446 619 echo
447 620
448 621 fi
@@ -451,11 +624,11 b' rccontrol_stack_usage() {'
451 624 # :command.usage
452 625 rccontrol_stack_status_usage() {
453 626 if [[ -n $long_usage ]]; then
454 printf "rccontrol stack-status - show stack status\n"
627 printf "rccontrol stack-status - Show stack status\n"
455 628 echo
456 629
457 630 else
458 printf "rccontrol stack-status - show stack status\n"
631 printf "rccontrol stack-status - Show stack status\n"
459 632 echo
460 633
461 634 fi
@@ -510,20 +683,56 b' rccontrol_stack_upgrade_usage() {'
510 683 }
511 684
512 685 # :command.usage
686 rccontrol_cli_usage() {
687 if [[ -n $long_usage ]]; then
688 printf "rccontrol cli - run various CLI tools\n"
689 echo
690
691 else
692 printf "rccontrol cli - run various CLI tools\n"
693 echo
694
695 fi
696
697 printf "Usage:\n"
698 printf " rccontrol cli COMMAND\n"
699 printf " rccontrol cli [COMMAND] --help | -h\n"
700 echo
701 # :command.usage_commands
702 printf "Commands:\n"
703 echo " redis CLI for Redis"
704 echo " db CLI with Database connection"
705 echo " db-upgrade CLI to run db upgrade"
706 echo " storage CLI for repository storage"
707 echo
708
709 # :command.long_usage
710 if [[ -n $long_usage ]]; then
711 printf "Options:\n"
712
713 # :command.usage_fixed_flags
714 echo " --help, -h"
715 printf " Show this help\n"
716 echo
717
718 fi
719 }
720
721 # :command.usage
513 722 rccontrol_cli_redis_usage() {
514 723 if [[ -n $long_usage ]]; then
515 printf "rccontrol cli-redis - CLI\n"
724 printf "rccontrol cli redis - CLI for Redis\n"
516 725 echo
517 726
518 727 else
519 printf "rccontrol cli-redis - CLI\n"
728 printf "rccontrol cli redis - CLI for Redis\n"
520 729 echo
521 730
522 731 fi
523 732
524 733 printf "Usage:\n"
525 printf " rccontrol cli-redis\n"
526 printf " rccontrol cli-redis --help | -h\n"
734 printf " rccontrol cli redis\n"
735 printf " rccontrol cli redis --help | -h\n"
527 736 echo
528 737
529 738 # :command.long_usage
@@ -541,18 +750,18 b' rccontrol_cli_redis_usage() {'
541 750 # :command.usage
542 751 rccontrol_cli_db_usage() {
543 752 if [[ -n $long_usage ]]; then
544 printf "rccontrol cli-db - CLI\n"
753 printf "rccontrol cli db - CLI with Database connection\n"
545 754 echo
546 755
547 756 else
548 printf "rccontrol cli-db - CLI\n"
757 printf "rccontrol cli db - CLI with Database connection\n"
549 758 echo
550 759
551 760 fi
552 761
553 762 printf "Usage:\n"
554 printf " rccontrol cli-db\n"
555 printf " rccontrol cli-db --help | -h\n"
763 printf " rccontrol cli db\n"
764 printf " rccontrol cli db --help | -h\n"
556 765 echo
557 766
558 767 # :command.long_usage
@@ -570,18 +779,47 b' rccontrol_cli_db_usage() {'
570 779 # :command.usage
571 780 rccontrol_cli_db_upgrade_usage() {
572 781 if [[ -n $long_usage ]]; then
573 printf "rccontrol cli-db-upgrade - CLI\n"
782 printf "rccontrol cli db-upgrade - CLI to run db upgrade\n"
783 echo
784
785 else
786 printf "rccontrol cli db-upgrade - CLI to run db upgrade\n"
787 echo
788
789 fi
790
791 printf "Usage:\n"
792 printf " rccontrol cli db-upgrade\n"
793 printf " rccontrol cli db-upgrade --help | -h\n"
794 echo
795
796 # :command.long_usage
797 if [[ -n $long_usage ]]; then
798 printf "Options:\n"
799
800 # :command.usage_fixed_flags
801 echo " --help, -h"
802 printf " Show this help\n"
803 echo
804
805 fi
806 }
807
808 # :command.usage
809 rccontrol_cli_storage_usage() {
810 if [[ -n $long_usage ]]; then
811 printf "rccontrol cli storage - CLI for repository storage\n"
574 812 echo
575 813
576 814 else
577 printf "rccontrol cli-db-upgrade - CLI\n"
815 printf "rccontrol cli storage - CLI for repository storage\n"
578 816 echo
579 817
580 818 fi
581 819
582 820 printf "Usage:\n"
583 printf " rccontrol cli-db-upgrade\n"
584 printf " rccontrol cli-db-upgrade --help | -h\n"
821 printf " rccontrol cli storage\n"
822 printf " rccontrol cli storage --help | -h\n"
585 823 echo
586 824
587 825 # :command.long_usage
@@ -733,6 +971,23 b' inspect_args() {'
733 971 }
734 972
735 973 # :command.user_lib
974 # src/lib/check_bootstrap.sh
975
976 check_bootstrap() {
977 # Avoid destroying bootstrapping by simple start/stop
978 for stage in $BOOTSTRAP_STAGES; do
979
980 stage_name=$(echo $stage | cut -d ":" -f 1)
981 stage_func=$(echo $stage | cut -d ":" -f 2)
982 if ! config_has_key $stage_name ; then
983 echo "$(yellow WARNING:) bootstrap key $stage_name not found in config file $CONFIG_FILE!"
984 echo "$(yellow NOTICE:) Please run ./rccontrol bootstrap first"
985 exit
986 fi
987 done
988
989 }
990
736 991 # src/lib/colors.sh
737 992 print_in_color() {
738 993 local color="$1"
@@ -861,22 +1116,6 b' config_has_key() {'
861 1116 [[ $(config_get "$1") ]]
862 1117 }
863 1118
864 # src/lib/sample_function.sh
865
866 docker_ping_host() {
867 PING_HOST="$1"
868 docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
869 }
870
871 check_bootstrap() {
872 # Avoid destroying bootstrapping by simple start/stop
873 if [[ ! -e $BOOTSTRAP_FILE ]]; then
874 echo "$(yellow WARNING:) initial bootstrap file $BOOTSTRAP_FILE not found !"
875 echo "$(yellow NOTICE:) Please run ./rccontrol bootstrap first"
876 exit
877 fi
878 }
879
880 1119 # src/lib/send_completions.sh
881 1120 send_completions() {
882 1121 echo $'# rccontrol3 completion -*- shell-script -*-'
@@ -985,7 +1224,6 b' rccontrol_bootstrap_command() {'
985 1224 force=${args[--force]}
986 1225
987 1226 check_bash_version() {
988
989 1227 if [ ! "${BASH_VERSINFO:-0}" -ge 4 ]; then
990 1228 echo "$(red Bash version 4 or greater is required, please update your bash version!)"
991 1229 exit
@@ -996,7 +1234,7 b' rccontrol_bootstrap_command() {'
996 1234 (which docker || which docker.io) &>/dev/null
997 1235 }
998 1236
999 check_and_install_docker() {
1237 bootstrap_docker_install() {
1000 1238 failMsg="Failed to find docker on your PATH"
1001 1239
1002 1240 if ! check_docker; then
@@ -1012,12 +1250,17 b' rccontrol_bootstrap_command() {'
1012 1250 fi
1013 1251 }
1014 1252
1015 docker_bootstrap() {
1016 check_and_install_docker
1253 bootstrap_docker_commons() {
1254
1017 1255 echo 'Docker: Running bootstrap.'
1018 1256
1019 echo "Docker: creating network 'rc_datavolume'"
1020 docker volume create --name=rc_datavolume
1257 echo "Docker: creating volume 'rc_datavolume'"
1258 docker volume create --label keep=1 --name=rc_datavolume
1259 echo "Docker: done"
1260 echo ""
1261
1262 echo "Docker: creating volume 'rc_reposvolume'"
1263 docker volume create --label keep=1 --name=rc_reposvolume
1021 1264 echo "Docker: done"
1022 1265 echo ""
1023 1266
@@ -1035,16 +1278,89 b' rccontrol_bootstrap_command() {'
1035 1278 fi
1036 1279 }
1037 1280
1038 definitions_bootstrap() {
1039
1040 SOURCE_DIR=$PWD
1041 RHODECODE_DOCKER_HASH='master'
1042
1043 AUTH_TOKEN=${args[--auth-token]}
1044 SERVER_URL=${args[--server-url]}
1281 bootstrap_config() {
1282 shared_key=$(echo $RANDOM | md5sum | head -c 32)
1283
1284 if [[ ! -f "$CONFIG_FILE" ]]; then
1285 echo "init config at: $CONFIG_FILE"
1286 config_init
1287 else
1288 echo "re-using config at: $CONFIG_FILE"
1289 fi
1290
1291 if ! config_has_key "rc_encrypted_secret" ; then
1292 config_set "rc_encrypted_secret" $shared_key
1293 fi
1294
1295 if ! config_has_key "rc_db_url" ; then
1296 key=$(echo $RANDOM | md5sum | head -c 32)
1297 config_set "rc_db_url" "postgresql://$DB_USER:$key@database/$DB_NAME"
1298 fi
1299
1300 if ! config_has_key "rc_license_token" ; then
1301 config_set "rc_license_token" abra-cada-bra1-rce4
1302 fi
1303
1304 if ! config_has_key "rc_base_url" ; then
1305 config_set "rc_base_url" http://docker-dev
1306 fi
1307
1308 if ! config_has_key "rc_log_formatter" ; then
1309 # json is another option
1310 config_set "rc_log_formatter" generic
1311 fi
1312
1313 if ! config_has_key "rc_use_celery" ; then
1314 config_set "rc_use_celery" true
1315 fi
1316
1317 if ! config_has_key "channelstream_secret" ; then
1318 config_set "channelstream_secret" $shared_key
1319 fi
1320
1321 if ! config_has_key "channelstream_admin_secret" ; then
1322 config_set "channelstream_admin_secret" $shared_key
1323 fi
1324
1325 if ! config_has_key "channelstream_allow_posting_from" ; then
1326 config_set "channelstream_allow_posting_from" 0.0.0.0
1327 fi
1328
1329 if ! config_has_key "rc_channelstream_ws_url" ; then
1330 config_set "rc_channelstream_ws_url" ws:/docker-dev/_channelstream
1331 fi
1332
1333 mkdir -p $PWD/.custom
1334 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
1335 if [[ ! -f "$BOOTSTRAP_RUNTIME_ENV" ]]; then
1336 echo "init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
1337 touch BOOTSTRAP_RUNTIME_ENV
1338
1339 #ENV_EXPAND=""
1340 for k in $(config_keys); do
1341 k_upper=${k^^}
1342 echo "$k_upper='$(config_get "$k")'" >> $BOOTSTRAP_RUNTIME_ENV
1343 done
1344
1345 fi
1346 }
1347
1348 bootstrap_definitions() {
1349
1350 SOURCE_DIR=$PWD
1351 RHODECODE_DOCKER_HASH='master'
1352
1353 AUTH_TOKEN=${args[--auth-token]}
1354 SERVER_URL=${args[--server-url]}
1045 1355
1046 1356 DEFINITIONS_EXIST=""
1047 CHECK_FILES="rccontrol .env docker-compose-services.yaml docker-compose-apps.yaml"
1357 CHECK_FILES="\
1358 .env \
1359 docker-compose-services.yaml \
1360 docker-compose-apps.yaml \
1361 docker-compose-metrics.yaml \
1362 docker-compose-router.yaml \
1363 "
1048 1364 for check_file in $CHECK_FILES; do
1049 1365 if [[ -f "$check_file" ]]; then
1050 1366 DEFINITIONS_EXIST="1"
@@ -1068,8 +1384,6 b' rccontrol_bootstrap_command() {'
1068 1384 done
1069 1385 fi
1070 1386
1071 exit
1072
1073 1387 # download sources
1074 1388 echo "Files: download rhodecode docker definitions from $SERVER_URL"
1075 1389 echo ""
@@ -1094,83 +1408,56 b' rccontrol_bootstrap_command() {'
1094 1408 echo "$(green_bold DONE: docker definitions extracted to $SOURCE_DIR)"
1095 1409 }
1096 1410
1097 config_bootstrap() {
1411 bootstrap_overrides() {
1412 templates=$(find $PWD/templates/*.yaml -printf "%f\n")
1098 1413
1099 if [[ ! -f "$CONFIG_FILE" ]]; then
1100 echo "init config at: $CONFIG_FILE"
1101 config_init
1414 target_dir=$PWD/.custom/
1415 for o_file in $templates; do
1416 target_file=$target_dir/$o_file
1417 if [[ ! -f "$target_file" ]]; then
1418 echo "copy override file $o_file"
1419 cp -v $PWD/templates/$o_file $target_file
1102 1420 else
1103 echo "re-using config at: $CONFIG_FILE"
1104 fi
1105
1106 if ! config_has_key "rc_encrypted_secret" ; then
1107 key=$(echo $RANDOM | md5sum | head -c 32)
1108 config_set "rc_encrypted_secret" $key
1109 fi
1110
1111 if ! config_has_key "rc_db_url" ; then
1112 key=$(echo $RANDOM | md5sum | head -c 32)
1113 config_set "rc_db_url" "postgresql://$DB_USER:$key@database/$DB_NAME"
1114 fi
1115
1116 if ! config_has_key "rc_license_token" ; then
1117 config_set "rc_license_token" abra-cada-bra1-rce4
1421 echo "file $target_file existing, skipping..."
1118 1422 fi
1119
1120 if ! config_has_key "rc_base_url" ; then
1121 config_set "rc_base_url" http://docker-dev
1122 fi
1123
1124 if ! config_has_key "rc_log_formatter" ; then
1125 # json is another option
1126 config_set "rc_log_formatter" generic
1127 fi
1128
1129 if ! config_has_key "rc_use_celery" ; then
1130 config_set "rc_use_celery" true
1131 fi
1132
1133 BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
1134 if [[ ! -f "$BOOTSTRAP_RUNTIME_ENV" ]]; then
1135 echo "init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
1136 touch BOOTSTRAP_RUNTIME_ENV
1137
1138 #ENV_EXPAND=""
1139 for k in $(config_keys); do
1140 k_upper=${k^^}
1141 echo "$k_upper='$(config_get "$k")'" >> $BOOTSTRAP_RUNTIME_ENV
1142 1423 done
1143
1144 fi
1424 echo "$(green_bold DONE: overrides extracted to $target_dir)"
1145 1425 }
1146 1426
1147 1427 cur_date=$(date '+%Y-%m-%d %H:%M:%S')
1148 1428
1149 1429 check_bash_version
1150 1430
1151 if [[ ! -e $BOOTSTRAP_FILE ]]; then
1152 echo "initial bootstrap file $BOOTSTRAP_FILE not found !"
1431 # Init the config !
1432 if [[ ! -f "$CONFIG_FILE" ]]; then
1433 echo "config: init new config at: $CONFIG_FILE"
1434 config_init
1435 else
1436 echo "config: re-using present config at: $CONFIG_FILE"
1437 fi
1153 1438
1154 docker_bootstrap
1155 definitions_bootstrap
1156 config_bootstrap
1439 for stage in $BOOTSTRAP_STAGES; do
1157 1440
1158 echo "$cur_date" > "$BOOTSTRAP_FILE"
1441 stage_name=$(echo $stage | cut -d ":" -f 1)
1442 stage_func=$(echo $stage | cut -d ":" -f 2)
1159 1443
1444 if ! config_has_key $stage_name ; then
1445 echo "$(green \* bootstrap: \'$stage_name\' stage not found\; running now... )"
1446 $stage_func
1447 config_set "$stage_name" $cur_date
1160 1448 else
1161 1449 if [ $force ]; then
1450 echo "$(green \* bootstrap: \'$stage_name\' is present!\; FORCE running now... )"
1451 $stage_func $force
1452 config_set "$stage_name" $cur_date
1453 else
1454 echo "$(yellow \* bootstrap: \'$stage_name\' already present, use --force to run it again)"
1455 fi
1456 fi
1162 1457
1163 docker_bootstrap $force
1164 definitions_bootstrap $force ## TODO: remove old
1165 config_bootstrap $force
1166
1167 echo "$cur_date" > "$BOOTSTRAP_FILE"
1458 done
1168 1459
1169 1460 exit
1170 fi
1171
1172 echo "bootstrap file $BOOTSTRAP_FILE was found add --force to force bootstrap"
1173 fi
1174 1461
1175 1462 get_started
1176 1463 }
@@ -1263,7 +1550,7 b' rccontrol_get_build_source_command() {'
1263 1550
1264 1551 AUTH_TOKEN=${args[--auth-token]}
1265 1552 SERVER_URL=${args[--server-url]}
1266 revision=${args[revision]}
1553 revision=${args[--revision]}
1267 1554
1268 1555 SOURCE_DIR=$PWD/.source
1269 1556
@@ -1279,11 +1566,17 b' rccontrol_get_build_source_command() {'
1279 1566 #TODO: fix just CE build...
1280 1567 curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-ee/archive/$RHODECODE_EE_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
1281 1568
1282 rm -rf $SOURCE_DIR/rhodecode-vcsserver && mv $SOURCE_DIR/*rhodecode-vcsserver-plain $SOURCE_DIR/rhodecode-vcsserver
1283 rm -rf $SOURCE_DIR/rhodecode-enterprise-ce && mv $SOURCE_DIR/*rhodecode-enterprise-ce-plain $SOURCE_DIR/rhodecode-enterprise-ce
1284 rm -rf $SOURCE_DIR/rhodecode-enterprise-ee && cp -r $SOURCE_DIR/*rhodecode-enterprise-ee-plain $SOURCE_DIR/rhodecode-enterprise-ee
1569 rm -rf $SOURCE_DIR/rhodecode-vcsserver && \
1570 mv $SOURCE_DIR/*rhodecode-vcsserver-plain $SOURCE_DIR/rhodecode-vcsserver
1571
1572 rm -rf $SOURCE_DIR/rhodecode-enterprise-ce && \
1573 mv $SOURCE_DIR/*rhodecode-enterprise-ce-plain $SOURCE_DIR/rhodecode-enterprise-ce
1574
1575 rm -rf $SOURCE_DIR/rhodecode-enterprise-ee && \
1576 mv $SOURCE_DIR/*rhodecode-enterprise-ee-plain $SOURCE_DIR/rhodecode-enterprise-ee
1285 1577
1286 1578 echo "downloading sources done to $SOURCE_DIR"
1579 ls -l $SOURCE_DIR
1287 1580
1288 1581 }
1289 1582
@@ -1301,12 +1594,11 b' rccontrol_build_source_command() {'
1301 1594 }
1302 1595
1303 1596 # :command.function
1304 rccontrol_stack_command() {
1305 # src/stack_command.sh
1597 rccontrol_stack_router_command() {
1598 # src/stack_router_command.sh
1306 1599 check_bootstrap
1307 1600
1308 1601 DEBUG=${args[--debug]}
1309 service_name=${args[name]}
1310 1602
1311 1603 if [[ ! -f $RC_STACK_ROUTER_EXT ]]; then
1312 1604 RC_STACK_ROUTER_EXT=""
@@ -1322,6 +1614,55 b' rccontrol_stack_command() {'
1322 1614 -f docker-compose-base.yaml \
1323 1615 -f docker-compose-router.yaml $RC_STACK_ROUTER_EXT"
1324 1616
1617 if [[ $DEBUG ]]; then
1618 echo "---"
1619 echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
1620 echo "running command: ${CMD_ROUTER}"
1621 echo "ARGS: ${other_args[*]}"
1622 echo "---"
1623 fi
1624 eval "${CMD_ROUTER} ${other_args[*]}"
1625
1626 }
1627
1628 # :command.function
1629 rccontrol_stack_metrics_command() {
1630 # src/stack_metrics_command.sh
1631 check_bootstrap
1632
1633 DEBUG=${args[--debug]}
1634
1635 if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
1636 RC_STACK_METRICS_EXT_LCL=""
1637 else
1638 RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
1639 fi
1640
1641 CMD_METRICS="\
1642 docker compose \
1643 --env-file $ENV_FILE \
1644 $ENV_EXPAND \
1645 -p rc_cluster_metrics \
1646 -f docker-compose-base.yaml \
1647 -f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
1648
1649 if [[ $DEBUG ]]; then
1650 echo "---"
1651 echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
1652 echo "running command: ${CMD_METRICS}"
1653 echo "ARGS: ${other_args[*]}"
1654 echo "---"
1655 fi
1656 eval "${CMD_METRICS} ${other_args[*]}"
1657 }
1658
1659 # :command.function
1660 rccontrol_stack_services_command() {
1661 # src/stack_services_command.sh
1662 check_bootstrap
1663
1664 DEBUG=${args[--debug]}
1665
1325 1666 if [[ ! -f $RC_STACK_SERVICES_EXT ]]; then
1326 1667 RC_STACK_SERVICES_EXT_LCL=""
1327 1668 else
@@ -1339,19 +1680,23 b' rccontrol_stack_command() {'
1339 1680 -f docker-compose-base.yaml \
1340 1681 -f docker-compose-services.yaml $RC_STACK_SERVICES_EXT_LCL"
1341 1682
1342 if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
1343 RC_STACK_METRICS_EXT_LCL=""
1344 else
1345 RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
1683 if [[ $DEBUG ]]; then
1684 echo "---"
1685 echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
1686 echo "running command: ${CMD_SERVICES}"
1687 echo "ARGS: ${other_args[*]}"
1688 echo "---"
1346 1689 fi
1347 1690
1348 CMD_METRICS="\
1349 docker compose \
1350 --env-file $ENV_FILE \
1351 $ENV_EXPAND \
1352 -p rc_cluster_metrics \
1353 -f docker-compose-base.yaml \
1354 -f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
1691 eval "${CMD_SERVICES} ${other_args[*]}"
1692 }
1693
1694 # :command.function
1695 rccontrol_stack_rhodecode_command() {
1696 # src/stack_rhodecode_command.sh
1697 check_bootstrap
1698
1699 DEBUG=${args[--debug]}
1355 1700
1356 1701 if [[ ! -f $RC_STACK_RHODECODE_EXT ]]; then
1357 1702 RC_STACK_RHODECODE_EXT_LCL=""
@@ -1376,43 +1721,6 b' rccontrol_stack_command() {'
1376 1721 -f docker-compose-apps.yaml \
1377 1722 -f docker-compose-apps.source.yaml $RC_STACK_RHODECODE_EXT_LCL"
1378 1723
1379 case $service_name in
1380
1381 services )
1382 if [[ $DEBUG ]]; then
1383 echo "---"
1384 echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
1385 echo "running command: ${CMD_SERVICES}"
1386 echo "ARGS: ${other_args[*]}"
1387 echo "---"
1388 fi
1389
1390 eval "${CMD_SERVICES} ${other_args[*]}"
1391 exit
1392 ;;
1393 router )
1394 if [[ $DEBUG ]]; then
1395 echo "---"
1396 echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
1397 echo "running command: ${CMD_ROUTER}"
1398 echo "ARGS: ${other_args[*]}"
1399 echo "---"
1400 fi
1401 eval "${CMD_ROUTER} ${other_args[*]}"
1402 exit
1403 ;;
1404 metrics )
1405 if [[ $DEBUG ]]; then
1406 echo "---"
1407 echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
1408 echo "running command: ${CMD_METRICS}"
1409 echo "ARGS: ${other_args[*]}"
1410 echo "---"
1411 fi
1412 eval "${CMD_METRICS} ${other_args[*]}"
1413 exit
1414 ;;
1415 rhodecode )
1416 1724 if [[ $DEBUG ]]; then
1417 1725 echo "---"
1418 1726 echo "stacks docker: $RC_STACK_RHODECODE_EXT_LCL"
@@ -1421,9 +1729,21 b' rccontrol_stack_command() {'
1421 1729 echo "---"
1422 1730 fi
1423 1731 eval "${CMD_RHODECODE} ${other_args[*]}"
1424 exit
1425 ;;
1426 esac
1732
1733 }
1734
1735 # :command.function
1736 rccontrol_stack_all_command() {
1737 # src/stack_all_command.sh
1738 check_bootstrap
1739
1740 DEBUG=${args[--debug]}
1741
1742 stack_lst=$VALID_SERVICES
1743
1744 for stack in $stack_lst; do
1745 ./rccontrol stack $stack ${other_args[*]}
1746 done
1427 1747
1428 1748 }
1429 1749
@@ -1552,33 +1872,79 b' rccontrol_cli_db_upgrade_command() {'
1552 1872 }
1553 1873
1554 1874 # :command.function
1555 rccontrol__completions_command() {
1556 # src/_completions_command.sh
1557 send_completions
1558 }
1559
1560 # :command.function
1561 rccontrol_backup_db_command() {
1562 # src/backup_db_command.sh
1875 rccontrol_cli_storage_command() {
1876 # src/cli_storage_command.sh
1563 1877 check_bootstrap
1564 1878
1565 1879 DEBUG=${args[--debug]}
1566 DESTINATION=${args[destination]}
1567 1880
1568 target_container=rc_cluster_services-database-1
1881 source $ENV_FILE
1882 target_container=$RC_IMAGE_EE
1569 1883
1570 docker_id=$(docker ps --filter name=$target_container -q)
1571 backup_name=rc_db_dump-$(date +%Y-%m-%d).tar.gz
1884 image_id=$(docker image ls $RC_IMAGE_EE -q)
1572 1885
1573 echo "creating backup $backup_name"
1886 echo "Attaching storage from $target_container"
1574 1887
1575 1888 if [[ $DEBUG ]]; then
1576 echo "container id: $docker_id, based on $target_container filter"
1577 docker ps
1889 echo "image id: $image_id, based on $target_container filter"
1890 docker image ls
1578 1891 echo "---"
1579 1892 fi
1580 1893
1581 #image_id=$(docker inspect "$docker_id" --format {{.Image}} | cut -c 8-)
1894 if [[ $DEBUG ]]; then
1895 echo "rc_datavolume inspection..."
1896 docker volume inspect rc_datavolume
1897
1898 echo "rhodecode_repos inspection..."
1899 docker volume inspect rhodecode_repos
1900 fi
1901
1902 #
1903 #if [[ $DEBUG ]]; then
1904 # echo "image id: $image_id, based on $target_container filter"
1905 # docker image ls
1906 # echo "---"
1907 #fi
1908
1909 docker run --rm \
1910 -it \
1911 --volume $PWD/.custom/storage:/vol/backupvolume \
1912 --volume rc_datavolume:/vol/datavolume \
1913 --volume rc_reposvolume:/vol/repovolume \
1914 --workdir="/vol" \
1915 debian:jessie \
1916 /bin/bash
1917
1918 }
1919
1920 # :command.function
1921 rccontrol__completions_command() {
1922 # src/_completions_command.sh
1923 send_completions
1924 }
1925
1926 # :command.function
1927 rccontrol_backup_db_command() {
1928 # src/backup_db_command.sh
1929 check_bootstrap
1930
1931 DEBUG=${args[--debug]}
1932 DESTINATION=${args[destination]}
1933
1934 target_container=rc_cluster_services-database-1
1935
1936 docker_id=$(docker ps --filter name=$target_container -q)
1937 backup_name=rc_db_dump-$(date +%Y-%m-%d).sql.gz
1938
1939 echo "creating backup $backup_name"
1940
1941 if [[ $DEBUG ]]; then
1942 echo "container id: $docker_id, based on $target_container filter"
1943 docker ps
1944 echo "---"
1945 fi
1946
1947 #image_id=$(docker inspect "$docker_id" --format {{.Image}} | cut -c 8-)
1582 1948 #
1583 1949 #if [[ $DEBUG ]]; then
1584 1950 # echo "image id: $image_id, based on $target_container filter"
@@ -1597,9 +1963,12 b' rccontrol_backup_db_command() {'
1597 1963 # echo "$(red $MSG)"
1598 1964 # exit
1599 1965 #fi
1966 # docker exec -i your-db-container psql -U your-db-user -d your-db-name gunzip < your_dump.sql.gz |
1600 1967
1601 1968 if [[ $DEBUG ]]; then
1602 echo "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
1969 echo "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'mkdir -p /var/rc-data-dump && pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
1970 echo "dump placed in /var/rc-data-dump/$backup_name"
1971 echo "run docker cp $docker_id:/var/rc-data-dump/$backup_name $PWD to copy the file into your host machine"
1603 1972 fi
1604 1973
1605 1974 eval "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
@@ -1664,7 +2033,7 b' parse_requirements() {'
1664 2033 shift $#
1665 2034 ;;
1666 2035
1667 bootstrap | install )
2036 bootstrap | init )
1668 2037 action="bootstrap"
1669 2038 shift
1670 2039 rccontrol_bootstrap_parse_requirements "$@"
@@ -1720,24 +2089,10 b' parse_requirements() {'
1720 2089 shift $#
1721 2090 ;;
1722 2091
1723 cli-redis )
1724 action="cli-redis"
2092 cli )
2093 action="cli"
1725 2094 shift
1726 rccontrol_cli_redis_parse_requirements "$@"
1727 shift $#
1728 ;;
1729
1730 cli-db )
1731 action="cli-db"
1732 shift
1733 rccontrol_cli_db_parse_requirements "$@"
1734 shift $#
1735 ;;
1736
1737 cli-db-upgrade )
1738 action="cli-db-upgrade"
1739 shift
1740 rccontrol_cli_db_upgrade_parse_requirements "$@"
2095 rccontrol_cli_parse_requirements "$@"
1741 2096 shift $#
1742 2097 ;;
1743 2098
@@ -2050,209 +2405,534 b' rccontrol_get_build_artifacts_parse_requirements() {'
2050 2405 ;;
2051 2406
2052 2407 -?* )
2053 printf "invalid option: %s\n" "$key" >&2
2054 exit 1
2408 printf "invalid option: %s\n" "$key" >&2
2409 exit 1
2410 ;;
2411
2412 * )
2413 # :command.parse_requirements_case
2414 # :command.parse_requirements_case_simple
2415 printf "invalid argument: %s\n" "$key" >&2
2416 exit 1
2417
2418 ;;
2419
2420 esac
2421 done
2422
2423 # :command.default_assignments
2424 [[ -n ${args[--auth]:-} ]] || args[--auth]=""
2425 [[ -n ${args[--installer-url]:-} ]] || args[--installer-url]="https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee"
2426 [[ -n ${args[--manifest-url]:-} ]] || args[--manifest-url]="https://dls.rhodecode.com/linux/MANIFEST"
2427 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2428
2429 }
2430
2431 # :command.parse_requirements
2432 rccontrol_build_parse_requirements() {
2433 # :command.fixed_flags_filter
2434 case "${1:-}" in
2435 --help | -h )
2436 long_usage=yes
2437 rccontrol_build_usage
2438 exit
2439 ;;
2440
2441 esac
2442
2443 # :command.command_filter
2444 action="build"
2445
2446 # :command.parse_requirements_while
2447 while [[ $# -gt 0 ]]; do
2448 key="$1"
2449 case "$key" in
2450 # :flag.case
2451 --version-name )
2452
2453 # :flag.case_arg
2454 if [[ -n ${2+x} ]]; then
2455
2456 args[--version-name]="$2"
2457 shift
2458 shift
2459 else
2460 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2461 exit 1
2462 fi
2463 ;;
2464
2465 -?* )
2466 printf "invalid option: %s\n" "$key" >&2
2467 exit 1
2468 ;;
2469
2470 * )
2471 # :command.parse_requirements_case
2472 # :command.parse_requirements_case_simple
2473 printf "invalid argument: %s\n" "$key" >&2
2474 exit 1
2475
2476 ;;
2477
2478 esac
2479 done
2480
2481 # :command.default_assignments
2482 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2483
2484 }
2485
2486 # :command.parse_requirements
2487 rccontrol_get_build_source_parse_requirements() {
2488 # :command.fixed_flags_filter
2489 case "${1:-}" in
2490 --help | -h )
2491 long_usage=yes
2492 rccontrol_get_build_source_usage
2493 exit
2494 ;;
2495
2496 esac
2497
2498 # :command.dependencies_filter
2499 if ! [[ -x "$(command -v curl)" ]]; then
2500 printf "missing dependency: curl\n" >&2
2501 exit 1
2502 fi
2503 if ! [[ -x "$(command -v tar)" ]]; then
2504 printf "missing dependency: tar\n" >&2
2505 exit 1
2506 fi
2507
2508 # :command.command_filter
2509 action="get-build-source"
2510
2511 # :command.parse_requirements_while
2512 while [[ $# -gt 0 ]]; do
2513 key="$1"
2514 case "$key" in
2515 # :flag.case
2516 --revision )
2517
2518 # :flag.case_arg
2519 if [[ -n ${2+x} ]]; then
2520
2521 args[--revision]="$2"
2522 shift
2523 shift
2524 else
2525 printf "%s\n" "--revision requires an argument: --revision REVISION" >&2
2526 exit 1
2527 fi
2528 ;;
2529
2530 # :flag.case
2531 --auth-token )
2532
2533 # :flag.case_arg
2534 if [[ -n ${2+x} ]]; then
2535
2536 args[--auth-token]="$2"
2537 shift
2538 shift
2539 else
2540 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2541 exit 1
2542 fi
2543 ;;
2544
2545 # :flag.case
2546 --server-url )
2547
2548 # :flag.case_arg
2549 if [[ -n ${2+x} ]]; then
2550
2551 args[--server-url]="$2"
2552 shift
2553 shift
2554 else
2555 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2556 exit 1
2557 fi
2558 ;;
2559
2560 -?* )
2561 printf "invalid option: %s\n" "$key" >&2
2562 exit 1
2563 ;;
2564
2565 * )
2566 # :command.parse_requirements_case
2567 # :command.parse_requirements_case_simple
2568 printf "invalid argument: %s\n" "$key" >&2
2569 exit 1
2570
2571 ;;
2572
2573 esac
2574 done
2575
2576 # :command.default_assignments
2577 [[ -n ${args[--revision]:-} ]] || args[--revision]="default"
2578 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2579
2580 }
2581
2582 # :command.parse_requirements
2583 rccontrol_build_source_parse_requirements() {
2584 # :command.fixed_flags_filter
2585 case "${1:-}" in
2586 --help | -h )
2587 long_usage=yes
2588 rccontrol_build_source_usage
2589 exit
2590 ;;
2591
2592 esac
2593
2594 # :command.command_filter
2595 action="build-source"
2596
2597 # :command.parse_requirements_while
2598 while [[ $# -gt 0 ]]; do
2599 key="$1"
2600 case "$key" in
2601 # :flag.case
2602 --version-name )
2603
2604 # :flag.case_arg
2605 if [[ -n ${2+x} ]]; then
2606
2607 args[--version-name]="$2"
2608 shift
2609 shift
2610 else
2611 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2612 exit 1
2613 fi
2614 ;;
2615
2616 -?* )
2617 printf "invalid option: %s\n" "$key" >&2
2618 exit 1
2619 ;;
2620
2621 * )
2622 # :command.parse_requirements_case
2623 # :command.parse_requirements_case_simple
2624 printf "invalid argument: %s\n" "$key" >&2
2625 exit 1
2626
2627 ;;
2628
2629 esac
2630 done
2631
2632 # :command.default_assignments
2633 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2634
2635 }
2636
2637 # :command.parse_requirements
2638 rccontrol_stack_parse_requirements() {
2639 # :command.fixed_flags_filter
2640 case "${1:-}" in
2641 --help | -h )
2642 long_usage=yes
2643 rccontrol_stack_usage
2644 exit
2645 ;;
2646
2647 esac
2648
2649 # :command.command_filter
2650 action=${1:-}
2651
2652 case $action in
2653 -* )
2654 ;;
2655
2656 router )
2657 action="router"
2658 shift
2659 rccontrol_stack_router_parse_requirements "$@"
2660 shift $#
2661 ;;
2662
2663 metrics )
2664 action="metrics"
2665 shift
2666 rccontrol_stack_metrics_parse_requirements "$@"
2667 shift $#
2668 ;;
2669
2670 services )
2671 action="services"
2672 shift
2673 rccontrol_stack_services_parse_requirements "$@"
2674 shift $#
2675 ;;
2676
2677 rhodecode )
2678 action="rhodecode"
2679 shift
2680 rccontrol_stack_rhodecode_parse_requirements "$@"
2681 shift $#
2682 ;;
2683
2684 all )
2685 action="all"
2686 shift
2687 rccontrol_stack_all_parse_requirements "$@"
2688 shift $#
2689 ;;
2690
2691 # :command.command_fallback
2692 "" )
2693 rccontrol_stack_usage >&2
2694 exit 1
2695 ;;
2696
2697 * )
2698 printf "invalid command: %s\n" "$action" >&2
2699 exit 1
2700 ;;
2701
2702 esac
2703
2704 # :command.parse_requirements_while
2705 while [[ $# -gt 0 ]]; do
2706 key="$1"
2707 case "$key" in
2708
2709 -?* )
2710 printf "invalid option: %s\n" "$key" >&2
2711 exit 1
2712 ;;
2713
2714 * )
2715 # :command.parse_requirements_case
2716 # :command.parse_requirements_case_simple
2717 printf "invalid argument: %s\n" "$key" >&2
2718 exit 1
2719
2720 ;;
2721
2722 esac
2723 done
2724
2725 }
2726
2727 # :command.parse_requirements
2728 rccontrol_stack_router_parse_requirements() {
2729 # :command.fixed_flags_filter
2730 case "${1:-}" in
2731 --help | -h )
2732 long_usage=yes
2733 rccontrol_stack_router_usage
2734 exit
2735 ;;
2736
2737 esac
2738
2739 # :command.command_filter
2740 action="stack router"
2741
2742 # :command.parse_requirements_while
2743 while [[ $# -gt 0 ]]; do
2744 key="$1"
2745 case "$key" in
2746
2747 -?* )
2748 other_args+=("$1")
2749 shift
2750 ;;
2751
2752 * )
2753 # :command.parse_requirements_case
2754 # :command.parse_requirements_case_catch_all
2755 other_args+=("$1")
2756 shift
2757
2758 ;;
2759
2760 esac
2761 done
2762
2763 }
2764
2765 # :command.parse_requirements
2766 rccontrol_stack_metrics_parse_requirements() {
2767 # :command.fixed_flags_filter
2768 case "${1:-}" in
2769 --help | -h )
2770 long_usage=yes
2771 rccontrol_stack_metrics_usage
2772 exit
2773 ;;
2774
2775 esac
2776
2777 # :command.command_filter
2778 action="stack metrics"
2779
2780 # :command.parse_requirements_while
2781 while [[ $# -gt 0 ]]; do
2782 key="$1"
2783 case "$key" in
2784
2785 -?* )
2786 other_args+=("$1")
2787 shift
2788 ;;
2789
2790 * )
2791 # :command.parse_requirements_case
2792 # :command.parse_requirements_case_catch_all
2793 other_args+=("$1")
2794 shift
2795
2796 ;;
2797
2798 esac
2799 done
2800
2801 }
2802
2803 # :command.parse_requirements
2804 rccontrol_stack_services_parse_requirements() {
2805 # :command.fixed_flags_filter
2806 case "${1:-}" in
2807 --help | -h )
2808 long_usage=yes
2809 rccontrol_stack_services_usage
2810 exit
2811 ;;
2812
2813 esac
2814
2815 # :command.command_filter
2816 action="stack services"
2817
2818 # :command.parse_requirements_while
2819 while [[ $# -gt 0 ]]; do
2820 key="$1"
2821 case "$key" in
2822
2823 -?* )
2824 other_args+=("$1")
2825 shift
2055 2826 ;;
2056 2827
2057 2828 * )
2058 2829 # :command.parse_requirements_case
2059 # :command.parse_requirements_case_simple
2060 printf "invalid argument: %s\n" "$key" >&2
2061 exit 1
2830 # :command.parse_requirements_case_catch_all
2831 other_args+=("$1")
2832 shift
2062 2833
2063 2834 ;;
2064 2835
2065 2836 esac
2066 2837 done
2067 2838
2068 # :command.default_assignments
2069 [[ -n ${args[--auth]:-} ]] || args[--auth]=""
2070 [[ -n ${args[--installer-url]:-} ]] || args[--installer-url]="https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee"
2071 [[ -n ${args[--manifest-url]:-} ]] || args[--manifest-url]="https://dls.rhodecode.com/linux/MANIFEST"
2072 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2073
2074 2839 }
2075 2840
2076 2841 # :command.parse_requirements
2077 rccontrol_build_parse_requirements() {
2842 rccontrol_stack_rhodecode_parse_requirements() {
2078 2843 # :command.fixed_flags_filter
2079 2844 case "${1:-}" in
2080 2845 --help | -h )
2081 2846 long_usage=yes
2082 rccontrol_build_usage
2847 rccontrol_stack_rhodecode_usage
2083 2848 exit
2084 2849 ;;
2085 2850
2086 2851 esac
2087 2852
2088 2853 # :command.command_filter
2089 action="build"
2854 action="stack rhodecode"
2090 2855
2091 2856 # :command.parse_requirements_while
2092 2857 while [[ $# -gt 0 ]]; do
2093 2858 key="$1"
2094 2859 case "$key" in
2095 # :flag.case
2096 --version-name )
2097
2098 # :flag.case_arg
2099 if [[ -n ${2+x} ]]; then
2100
2101 args[--version-name]="$2"
2102 shift
2103 shift
2104 else
2105 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2106 exit 1
2107 fi
2108 ;;
2109 2860
2110 2861 -?* )
2111 printf "invalid option: %s\n" "$key" >&2
2112 exit 1
2862 other_args+=("$1")
2863 shift
2113 2864 ;;
2114 2865
2115 2866 * )
2116 2867 # :command.parse_requirements_case
2117 # :command.parse_requirements_case_simple
2118 printf "invalid argument: %s\n" "$key" >&2
2119 exit 1
2868 # :command.parse_requirements_case_catch_all
2869 other_args+=("$1")
2870 shift
2120 2871
2121 2872 ;;
2122 2873
2123 2874 esac
2124 2875 done
2125 2876
2126 # :command.default_assignments
2127 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2128
2129 2877 }
2130 2878
2131 2879 # :command.parse_requirements
2132 rccontrol_get_build_source_parse_requirements() {
2880 rccontrol_stack_all_parse_requirements() {
2133 2881 # :command.fixed_flags_filter
2134 2882 case "${1:-}" in
2135 2883 --help | -h )
2136 2884 long_usage=yes
2137 rccontrol_get_build_source_usage
2885 rccontrol_stack_all_usage
2138 2886 exit
2139 2887 ;;
2140 2888
2141 2889 esac
2142 2890
2143 # :command.dependencies_filter
2144 if ! [[ -x "$(command -v curl)" ]]; then
2145 printf "missing dependency: curl\n" >&2
2146 exit 1
2147 fi
2148 if ! [[ -x "$(command -v tar)" ]]; then
2149 printf "missing dependency: tar\n" >&2
2150 exit 1
2151 fi
2152
2153 2891 # :command.command_filter
2154 action="get-build-source"
2892 action="stack all"
2155 2893
2156 2894 # :command.parse_requirements_while
2157 2895 while [[ $# -gt 0 ]]; do
2158 2896 key="$1"
2159 2897 case "$key" in
2160 # :flag.case
2161 --auth-token )
2162
2163 # :flag.case_arg
2164 if [[ -n ${2+x} ]]; then
2165
2166 args[--auth-token]="$2"
2167 shift
2168 shift
2169 else
2170 printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
2171 exit 1
2172 fi
2173 ;;
2174
2175 # :flag.case
2176 --server-url )
2177
2178 # :flag.case_arg
2179 if [[ -n ${2+x} ]]; then
2180
2181 args[--server-url]="$2"
2182 shift
2183 shift
2184 else
2185 printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
2186 exit 1
2187 fi
2188 ;;
2189 2898
2190 2899 -?* )
2191 printf "invalid option: %s\n" "$key" >&2
2192 exit 1
2900 other_args+=("$1")
2901 shift
2193 2902 ;;
2194 2903
2195 2904 * )
2196 2905 # :command.parse_requirements_case
2197 # :command.parse_requirements_case_simple
2198 if [[ -z ${args[revision]+x} ]]; then
2199
2200 args[revision]=$1
2906 # :command.parse_requirements_case_catch_all
2907 other_args+=("$1")
2201 2908 shift
2202 else
2203 printf "invalid argument: %s\n" "$key" >&2
2204 exit 1
2205 fi
2206 2909
2207 2910 ;;
2208 2911
2209 2912 esac
2210 2913 done
2211 2914
2212 # :command.required_args_filter
2213 if [[ -z ${args[revision]+x} ]]; then
2214 printf "missing required argument: REVISION\nusage: rccontrol get-build-source REVISION [OPTIONS]\n" >&2
2215 exit 1
2216 fi
2217
2218 # :command.default_assignments
2219 [[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
2220
2221 2915 }
2222 2916
2223 2917 # :command.parse_requirements
2224 rccontrol_build_source_parse_requirements() {
2918 rccontrol_stack_status_parse_requirements() {
2225 2919 # :command.fixed_flags_filter
2226 2920 case "${1:-}" in
2227 2921 --help | -h )
2228 2922 long_usage=yes
2229 rccontrol_build_source_usage
2923 rccontrol_stack_status_usage
2230 2924 exit
2231 2925 ;;
2232 2926
2233 2927 esac
2234 2928
2235 2929 # :command.command_filter
2236 action="build-source"
2930 action="stack-status"
2237 2931
2238 2932 # :command.parse_requirements_while
2239 2933 while [[ $# -gt 0 ]]; do
2240 2934 key="$1"
2241 2935 case "$key" in
2242 # :flag.case
2243 --version-name )
2244
2245 # :flag.case_arg
2246 if [[ -n ${2+x} ]]; then
2247
2248 args[--version-name]="$2"
2249 shift
2250 shift
2251 else
2252 printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
2253 exit 1
2254 fi
2255 ;;
2256 2936
2257 2937 -?* )
2258 2938 printf "invalid option: %s\n" "$key" >&2
@@ -2270,25 +2950,22 b' rccontrol_build_source_parse_requirements() {'
2270 2950 esac
2271 2951 done
2272 2952
2273 # :command.default_assignments
2274 [[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
2275
2276 2953 }
2277 2954
2278 2955 # :command.parse_requirements
2279 rccontrol_stack_parse_requirements() {
2956 rccontrol_stack_upgrade_parse_requirements() {
2280 2957 # :command.fixed_flags_filter
2281 2958 case "${1:-}" in
2282 2959 --help | -h )
2283 2960 long_usage=yes
2284 rccontrol_stack_usage
2961 rccontrol_stack_upgrade_usage
2285 2962 exit
2286 2963 ;;
2287 2964
2288 2965 esac
2289 2966
2290 2967 # :command.command_filter
2291 action="stack"
2968 action="stack-upgrade"
2292 2969
2293 2970 # :command.parse_requirements_while
2294 2971 while [[ $# -gt 0 ]]; do
@@ -2296,55 +2973,82 b' rccontrol_stack_parse_requirements() {'
2296 2973 case "$key" in
2297 2974
2298 2975 -?* )
2299 other_args+=("$1")
2300 shift
2976 printf "invalid option: %s\n" "$key" >&2
2977 exit 1
2301 2978 ;;
2302 2979
2303 2980 * )
2304 2981 # :command.parse_requirements_case
2305 # :command.parse_requirements_case_catch_all
2306 if [[ -z ${args[name]+x} ]]; then
2307
2308 args[name]=$1
2309 shift
2310 else
2311 other_args+=("$1")
2312 shift
2313 fi
2982 # :command.parse_requirements_case_simple
2983 printf "invalid argument: %s\n" "$key" >&2
2984 exit 1
2314 2985
2315 2986 ;;
2316 2987
2317 2988 esac
2318 2989 done
2319 2990
2320 # :command.required_args_filter
2321 if [[ -z ${args[name]+x} ]]; then
2322 printf "missing required argument: NAME\nusage: rccontrol stack NAME [SERVICES PARAMS...]\n" >&2
2323 exit 1
2324 fi
2325
2326 # :command.whitelist_filter
2327 if [[ ! ${args[name]} =~ ^(router|metrics|services|rhodecode)$ ]]; then
2328 printf "%s\n" "name must be one of: router, metrics, services, rhodecode" >&2
2329 exit 1
2330 fi
2331
2332 2991 }
2333 2992
2334 2993 # :command.parse_requirements
2335 rccontrol_stack_status_parse_requirements() {
2994 rccontrol_cli_parse_requirements() {
2336 2995 # :command.fixed_flags_filter
2337 2996 case "${1:-}" in
2338 2997 --help | -h )
2339 2998 long_usage=yes
2340 rccontrol_stack_status_usage
2999 rccontrol_cli_usage
2341 3000 exit
2342 3001 ;;
2343 3002
2344 3003 esac
2345 3004
2346 3005 # :command.command_filter
2347 action="stack-status"
3006 action=${1:-}
3007
3008 case $action in
3009 -* )
3010 ;;
3011
3012 redis )
3013 action="redis"
3014 shift
3015 rccontrol_cli_redis_parse_requirements "$@"
3016 shift $#
3017 ;;
3018
3019 db )
3020 action="db"
3021 shift
3022 rccontrol_cli_db_parse_requirements "$@"
3023 shift $#
3024 ;;
3025
3026 db-upgrade )
3027 action="db-upgrade"
3028 shift
3029 rccontrol_cli_db_upgrade_parse_requirements "$@"
3030 shift $#
3031 ;;
3032
3033 storage )
3034 action="storage"
3035 shift
3036 rccontrol_cli_storage_parse_requirements "$@"
3037 shift $#
3038 ;;
3039
3040 # :command.command_fallback
3041 "" )
3042 rccontrol_cli_usage >&2
3043 exit 1
3044 ;;
3045
3046 * )
3047 printf "invalid command: %s\n" "$action" >&2
3048 exit 1
3049 ;;
3050
3051 esac
2348 3052
2349 3053 # :command.parse_requirements_while
2350 3054 while [[ $# -gt 0 ]]; do
@@ -2370,19 +3074,19 b' rccontrol_stack_status_parse_requirements() {'
2370 3074 }
2371 3075
2372 3076 # :command.parse_requirements
2373 rccontrol_stack_upgrade_parse_requirements() {
3077 rccontrol_cli_redis_parse_requirements() {
2374 3078 # :command.fixed_flags_filter
2375 3079 case "${1:-}" in
2376 3080 --help | -h )
2377 3081 long_usage=yes
2378 rccontrol_stack_upgrade_usage
3082 rccontrol_cli_redis_usage
2379 3083 exit
2380 3084 ;;
2381 3085
2382 3086 esac
2383 3087
2384 3088 # :command.command_filter
2385 action="stack-upgrade"
3089 action="cli redis"
2386 3090
2387 3091 # :command.parse_requirements_while
2388 3092 while [[ $# -gt 0 ]]; do
@@ -2408,19 +3112,19 b' rccontrol_stack_upgrade_parse_requirements() {'
2408 3112 }
2409 3113
2410 3114 # :command.parse_requirements
2411 rccontrol_cli_redis_parse_requirements() {
3115 rccontrol_cli_db_parse_requirements() {
2412 3116 # :command.fixed_flags_filter
2413 3117 case "${1:-}" in
2414 3118 --help | -h )
2415 3119 long_usage=yes
2416 rccontrol_cli_redis_usage
3120 rccontrol_cli_db_usage
2417 3121 exit
2418 3122 ;;
2419 3123
2420 3124 esac
2421 3125
2422 3126 # :command.command_filter
2423 action="cli-redis"
3127 action="cli db"
2424 3128
2425 3129 # :command.parse_requirements_while
2426 3130 while [[ $# -gt 0 ]]; do
@@ -2446,19 +3150,19 b' rccontrol_cli_redis_parse_requirements() {'
2446 3150 }
2447 3151
2448 3152 # :command.parse_requirements
2449 rccontrol_cli_db_parse_requirements() {
3153 rccontrol_cli_db_upgrade_parse_requirements() {
2450 3154 # :command.fixed_flags_filter
2451 3155 case "${1:-}" in
2452 3156 --help | -h )
2453 3157 long_usage=yes
2454 rccontrol_cli_db_usage
3158 rccontrol_cli_db_upgrade_usage
2455 3159 exit
2456 3160 ;;
2457 3161
2458 3162 esac
2459 3163
2460 3164 # :command.command_filter
2461 action="cli-db"
3165 action="cli db-upgrade"
2462 3166
2463 3167 # :command.parse_requirements_while
2464 3168 while [[ $# -gt 0 ]]; do
@@ -2484,19 +3188,19 b' rccontrol_cli_db_parse_requirements() {'
2484 3188 }
2485 3189
2486 3190 # :command.parse_requirements
2487 rccontrol_cli_db_upgrade_parse_requirements() {
3191 rccontrol_cli_storage_parse_requirements() {
2488 3192 # :command.fixed_flags_filter
2489 3193 case "${1:-}" in
2490 3194 --help | -h )
2491 3195 long_usage=yes
2492 rccontrol_cli_db_upgrade_usage
3196 rccontrol_cli_storage_usage
2493 3197 exit
2494 3198 ;;
2495 3199
2496 3200 esac
2497 3201
2498 3202 # :command.command_filter
2499 action="cli-db-upgrade"
3203 action="cli storage"
2500 3204
2501 3205 # :command.parse_requirements_while
2502 3206 while [[ $# -gt 0 ]]; do
@@ -2669,12 +3373,21 b' initialize() {'
2669 3373 ENV_FILE=$PWD/.env
2670 3374
2671 3375 # bootstrap file is a config file at the same time
2672 BOOTSTRAP_FILE='.rccontrol-bootstrap'
2673 3376 CONFIG_FILE='.rccontrol.ini'
2674 3377
3378 # STACK_LIST
2675 3379 VALID_SERVICES="router metrics services rhodecode"
2676 3380 DOCKER_DEFS_WORK_DIR="docker_defs"
2677 3381
3382 # stage key, saved in .rccontrol.ini : stage func to execute
3383 BOOTSTRAP_STAGES="\
3384 bootstrap_docker_install:bootstrap_docker_install \
3385 bootstrap_docker_commons:bootstrap_docker_commons \
3386 bootstrap_config:bootstrap_config \
3387 bootstrap_definitions:bootstrap_definitions \
3388 bootstrap_overrides:bootstrap_overrides \
3389 "
3390
2678 3391 #echo "1 ----"
2679 3392 #echo $RC_STACK_SERVICES_EXT
2680 3393 #echo $RC_STACK_METRICS_EXT
@@ -2706,6 +3419,11 b' initialize() {'
2706 3419
2707 3420 #env | grep RC_
2708 3421
3422 docker_ping_host() {
3423 PING_HOST="$1"
3424 docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
3425 }
3426
2709 3427 # backup files from a docker volume into /tmp/backup.tar.gz
2710 3428 docker-volume-backup-compressed() {
2711 3429 docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}"
@@ -2816,6 +3534,46 b' run() {'
2816 3534 rccontrol_stack_command
2817 3535 fi
2818 3536
3537 elif [[ $action == "stack router" ]]; then
3538 if [[ ${args[--help]:-} ]]; then
3539 long_usage=yes
3540 rccontrol_stack_router_usage
3541 else
3542 rccontrol_stack_router_command
3543 fi
3544
3545 elif [[ $action == "stack metrics" ]]; then
3546 if [[ ${args[--help]:-} ]]; then
3547 long_usage=yes
3548 rccontrol_stack_metrics_usage
3549 else
3550 rccontrol_stack_metrics_command
3551 fi
3552
3553 elif [[ $action == "stack services" ]]; then
3554 if [[ ${args[--help]:-} ]]; then
3555 long_usage=yes
3556 rccontrol_stack_services_usage
3557 else
3558 rccontrol_stack_services_command
3559 fi
3560
3561 elif [[ $action == "stack rhodecode" ]]; then
3562 if [[ ${args[--help]:-} ]]; then
3563 long_usage=yes
3564 rccontrol_stack_rhodecode_usage
3565 else
3566 rccontrol_stack_rhodecode_command
3567 fi
3568
3569 elif [[ $action == "stack all" ]]; then
3570 if [[ ${args[--help]:-} ]]; then
3571 long_usage=yes
3572 rccontrol_stack_all_usage
3573 else
3574 rccontrol_stack_all_command
3575 fi
3576
2819 3577 elif [[ $action == "stack-status" ]]; then
2820 3578 if [[ ${args[--help]:-} ]]; then
2821 3579 long_usage=yes
@@ -2832,7 +3590,15 b' run() {'
2832 3590 rccontrol_stack_upgrade_command
2833 3591 fi
2834 3592
2835 elif [[ $action == "cli-redis" ]]; then
3593 elif [[ $action == "cli" ]]; then
3594 if [[ ${args[--help]:-} ]]; then
3595 long_usage=yes
3596 rccontrol_cli_usage
3597 else
3598 rccontrol_cli_command
3599 fi
3600
3601 elif [[ $action == "cli redis" ]]; then
2836 3602 if [[ ${args[--help]:-} ]]; then
2837 3603 long_usage=yes
2838 3604 rccontrol_cli_redis_usage
@@ -2840,7 +3606,7 b' run() {'
2840 3606 rccontrol_cli_redis_command
2841 3607 fi
2842 3608
2843 elif [[ $action == "cli-db" ]]; then
3609 elif [[ $action == "cli db" ]]; then
2844 3610 if [[ ${args[--help]:-} ]]; then
2845 3611 long_usage=yes
2846 3612 rccontrol_cli_db_usage
@@ -2848,7 +3614,7 b' run() {'
2848 3614 rccontrol_cli_db_command
2849 3615 fi
2850 3616
2851 elif [[ $action == "cli-db-upgrade" ]]; then
3617 elif [[ $action == "cli db-upgrade" ]]; then
2852 3618 if [[ ${args[--help]:-} ]]; then
2853 3619 long_usage=yes
2854 3620 rccontrol_cli_db_upgrade_usage
@@ -2856,6 +3622,14 b' run() {'
2856 3622 rccontrol_cli_db_upgrade_command
2857 3623 fi
2858 3624
3625 elif [[ $action == "cli storage" ]]; then
3626 if [[ ${args[--help]:-} ]]; then
3627 long_usage=yes
3628 rccontrol_cli_storage_usage
3629 else
3630 rccontrol_cli_storage_command
3631 fi
3632
2859 3633 elif [[ $action == "_completions" ]]; then
2860 3634 if [[ ${args[--help]:-} ]]; then
2861 3635 long_usage=yes
@@ -11,7 +11,7 b' ARG RHODECODE_VERSION=4.28.0'
11 11 ARG RHODECODE_DB=sqlite
12 12 ARG RHODECODE_USER_NAME=admin
13 13 ARG RHODECODE_USER_PASS=secret4
14 ARG RHODECODE_USER_EMAIL=support@rhodecode.com
14 ARG RHODECODE_USER_EMAIL=admin@server.local
15 15
16 16 # nix ver/channels
17 17 ARG DEV_NIX_VERSION=2.0.4
@@ -232,7 +232,7 b' echo "** install rhodecode ${RHODECODE_TYPE} ${RHODECODE_VERSION} **" && \\'
232 232 RHODECODE_PATH=/home/$RC_USER/.rccontrol/${RC_TYPE_ID} && \
233 233 rm -rf $BUILD_BIN_DIR/bin && ln -s ${RHODECODE_PATH}/profile/bin $BUILD_BIN_DIR/ && \
234 234 cp -v ${RHODECODE_PATH}/rhodecode.ini $BUILD_CONF/rhodecode.ini && \
235 cp -v ${RHODECODE_PATH}/gunicorn_conf.py $BUILD_CONF/gunicorn_conf.py && \
235 cp -v ${RHODECODE_PATH}/gunicorn_conf.py $BUILD_CONF/gunicorn_conf_rc.py && \
236 236 cp -v ${RHODECODE_PATH}/search_mapping.ini $BUILD_CONF/search_mapping.ini && \
237 237 mkdir -p $RHODECODE_DATA_DIR/static && cp -r ${RHODECODE_PATH}/public/* $RHODECODE_DATA_DIR/static/ && \
238 238 rm ${RHODECODE_PATH}/rhodecode.db && \
@@ -280,4 +280,4 b' VOLUME /var/log/rhodecode'
280 280 ENTRYPOINT ["/opt/entrypoints.d/entrypoint.sh"]
281 281
282 282 # compose can override this
283 CMD [ "$BUILD_BIN_DIR/bin/gunicorn", "--error-logfile=-", "--paster=/etc/rhodecode/conf_build/run.ini", "--config=/etc/rhodecode/conf_build/gunicorn_conf.py" ]
283 CMD [ "$BUILD_BIN_DIR/bin/gunicorn", "--error-logfile=-", "--paster=/etc/rhodecode/conf_build/run.ini", "--config=/etc/rhodecode/conf_build/gunicorn_conf_rc.py" ]
@@ -11,7 +11,7 b' ARG RHODECODE_VERSION=4.28.0'
11 11 ARG RHODECODE_DB=sqlite
12 12 ARG RHODECODE_USER_NAME=admin
13 13 ARG RHODECODE_USER_PASS=secret4
14 ARG RHODECODE_USER_EMAIL=support@rhodecode.com
14 ARG RHODECODE_USER_EMAIL=admin@server.local
15 15
16 16 # nix ver/channels
17 17 ARG DEV_NIX_VERSION=2.0.4
@@ -202,16 +202,17 b' COPY --chown=$RC_USER:$RC_USER .cache/* /home/$RC_USER/.rccontrol/cache/'
202 202 COPY --chown=$RC_USER:$RC_USER config/_shared/rhodecode_enterprise.license /home/$RC_USER/.rccontrol/bootstrap/
203 203 COPY --chown=$RC_USER:$RC_USER service/rhodecode/bootstrap/* /home/$RC_USER/.rccontrol/bootstrap/
204 204
205 RUN \
206 echo "**** locale-archive path ****" && \
207 mv -v /home/$RC_USER/.rccontrol/cache/locale-archive /var/opt/locale-archive
208
205 209 COPY --chown=$RC_USER:$RC_USER .source/ /home/$RC_USER/
206 210 RUN \
207 211 echo "** prepare rhodecode dirs **" && \
208 212 install -d -m 0755 -o $RC_USER -g $RC_USER /home/$RC_USER/.rccontrol/vcsserver-1 && \
209 213 install -d -m 0755 -o $RC_USER -g $RC_USER /home/$RC_USER/.rccontrol/community-1 && \
210 214 install -d -m 0755 -o $RC_USER -g $RC_USER /home/$RC_USER/.rccontrol/enterprise-1 && \
211
212 RUN \
213 echo "**** locale-archive path ****" && \
214 mv -v /home/$RC_USER/.rccontrol/cache/locale-archive /var/opt/locale-archive
215 echo "Done rhodecode dirs"
215 216
216 217 # change to non-root user for RUN commands
217 218 USER $RC_USER
@@ -220,13 +221,15 b' WORKDIR /home/$RC_USER'
220 221
221 222 RUN \
222 223 echo "** download and install nix ** from $DEV_NIX_VERSION/install" && \
223 curl -L https://releases.nixos.org/nix/nix-$DEV_NIX_VERSION/install | USER=$RC_USER /bin/bash
224 curl -L https://releases.nixos.org/nix/nix-$DEV_NIX_VERSION/install | USER=$RC_USER /bin/bash && \
225 echo "Done nix install"
224 226
225 227 RUN \
226 228 echo "** update nix package database and set channel to $DEV_NIX_CHANNEL **" && \
227 229 . /home/rhodecode/.nix-profile/etc/profile.d/nix.sh && \
228 230 nix-channel --add https://channels.nixos.org/$DEV_NIX_CHANNEL nixpkgs && \
229 nix-channel --update
231 nix-channel --update && \
232 echo "done nix package updates"
230 233
231 234
232 235 RUN \
@@ -272,7 +275,7 b' echo "** install rhodecode ${RHODECODE_VERSION} **" && \\'
272 275 rm -rf $BUILD_BIN_DIR/bin && \
273 276 cp -rv --preserve=links /home/$RC_USER/.rccontrol/enterprise-1/profile/bin $BUILD_BIN_DIR/ && \
274 277 cp -v ${RHODECODE_PATH}/configs/production.ini $BUILD_CONF/rhodecode.ini && \
275 cp -v ${RHODECODE_PATH}/configs/gunicorn_config.py $BUILD_CONF/gunicorn_conf.py && \
278 cp -v ${RHODECODE_PATH}/configs/gunicorn_config.py $BUILD_CONF/gunicorn_conf_rc.py && \
276 279 mkdir -p $RHODECODE_DATA_DIR/static && cp -r /home/$RC_USER/.rccontrol/enterprise-1/profile/etc/static/* $RHODECODE_DATA_DIR/static/ && \
277 280 echo "Done installing rhodecode"
278 281
@@ -321,4 +324,4 b' VOLUME /var/log/rhodecode'
321 324 ENTRYPOINT ["/opt/entrypoints.d/entrypoint.sh"]
322 325
323 326 # compose can override this
324 CMD [ "$BUILD_BIN_DIR/bin/gunicorn", "--error-logfile=-", "--paster=/etc/rhodecode/conf_build/run.ini", "--config=/etc/rhodecode/conf_build/gunicorn_conf.py" ]
327 CMD [ "$BUILD_BIN_DIR/bin/gunicorn", "--error-logfile=-", "--paster=/etc/rhodecode/conf_build/run.ini", "--config=/etc/rhodecode/conf_build/gunicorn_conf_rc.py" ]
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now