Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
EditionOpenAccess
/
eoa2-xmldb
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security
Insights
Files
d9f8401
res
scripts
config
utils
exec_in_container.py
exec_in_xmldb.py
install.py
run.py
stop.py
uninstall.py
src
.dockerignore
.gitignore
Dockerfile
LICENSE
README.md
dependencies.conf
docker-compose.yaml
docker-compose_installxml.yaml
requirements.txt
Breadcrumbs
eoa2-xmldb
/
scripts
/
install.py
Blame
Blame
Latest commit
History
History
executable file
·
161 lines (134 loc) · 3.79 KB
Breadcrumbs
eoa2-xmldb
/
scripts
/
install.py
Top
File metadata and controls
Code
Blame
executable file
·
161 lines (134 loc) · 3.79 KB
Raw
#!/usr/bin/env python3 from utils.settings import BASE_DIR, load_config, create_docker_env_file from utils.functions import exec_in_xmldb, exec_in_container, run from stop import stop from pathlib import Path import shlex import shutil import pwd import os import subprocess from time import sleep BASE_DIR = Path( __file__ ).parent.parent DEP_DIR = BASE_DIR / "dependencies" XMLDB_WAIT_TIME=40 SQLDB_WAIT_TIME=20 def create_dir(dir): print( "creating dir '{}'".format( dir ) ) Path(dir).mkdir( parents = True, exist_ok = True ) def copy_dir(src, dst): print( "'{}' -> '{}'".format( src, dst ) ) if Path(dst).exists(): shutil.rmtree( dst ) shutil.copytree( src=src, dst=dst ) def create_dirs( config ): create_dir( BASE_DIR / config['DATABASE_DATA_DIR'] ) create_dir( BASE_DIR / config['XMLDB_CONFIG_DIR'] ) create_dir( BASE_DIR / config['XMLDB_DATA_DIR'] ) """ create_dir( BASE_DIR / config['INPUT_DIR'] ) if (BASE_DIR / config['INPUT_DIR'] / "example") """ """ this extra copy is necessary in order to resolve symlinks. Docker won't resolve them. """ copy_dir( src=config['RES_DIR'], dst=config['RES_DIR_RUNTIME'] ) def install_xml_db( config ): try: subprocess.check_call( ["docker-compose", "--file", "docker-compose_installxml.yaml", "up", "-d"] ) subprocess.check_call( shlex.split( "docker cp \"xmldb_install:{XMLDB_CONFIG_DIR_IN_CONTAINER}/.\" \"{XMLDB_CONFIG_DIR}\"".format( XMLDB_CONFIG_DIR_IN_CONTAINER = config['XMLDB_CONFIG_DIR_IN_CONTAINER'], XMLDB_CONFIG_DIR = config['XMLDB_CONFIG_DIR'], ) ), ) subprocess.check_call( shlex.split( "docker cp \"xmldb_install:{XMLDB_DATA_DIR_IN_CONTAINER}/.\" \"{XMLDB_DATA_DIR}\"".format( XMLDB_DATA_DIR_IN_CONTAINER = config['XMLDB_DATA_DIR_IN_CONTAINER'], XMLDB_DATA_DIR = config['XMLDB_DATA_DIR'], ) ) ) finally: subprocess.check_call( shlex.split( "docker-compose --file docker-compose_installxml.yaml down" ), ) def init_sqldb( config ): # print( "env in config:" ) # subprocess.check_call( # ["env",], # env=config # ) try: subprocess.check_call( ["docker-compose", "up", "-d"], env=config ) print( "wait {}s for the sql database to get ready... :-P".format( SQLDB_WAIT_TIME ) ) sleep( SQLDB_WAIT_TIME ) exec_in_container( "python", "manage.py", "makemigrations", env=config, ) exec_in_container( "python", "manage.py", "migrate", env=config, ) finally: subprocess.check_call( ["docker-compose", "down"], env=config, ) if __name__ == '__main__': from argparse import ArgumentParser parser = ArgumentParser( description="initialize the repository: create directories, initialize xml database, initialize sql database" ) parser.add_argument( "--build", action = "store_true", help = "rebuild docker image from Dockerfile", ) args = parser.parse_args() # orig_config_file -> env_file: create_docker_env_file() # load env_file: config = load_config() create_dirs( config ) install_xml_db( config ) # rebuild docker image: if args.build: run( env = config, build = True, ) stop( env = config, ) init_sqldb( config )
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
You can’t perform that action at this time.