Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grady-docker-helper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grady Corp.
grady-docker-helper
Commits
e05919c1
Commit
e05919c1
authored
6 years ago
by
robinwilliam.hundt
Browse files
Options
Downloads
Patches
Plain Diff
First version of script
parent
afe06d86
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+14
-2
14 additions, 2 deletions
README.md
create-instance.py
+67
-0
67 additions, 0 deletions
create-instance.py
example.docker-compose.yml
+42
-0
42 additions, 0 deletions
example.docker-compose.yml
example.env
+6
-0
6 additions, 0 deletions
example.env
with
129 additions
and
2 deletions
README.md
+
14
−
2
View file @
e05919c1
#
g
rady
-d
ocker
-h
elper
#
G
rady
D
ocker
H
elper
A small script to help with the creation of a new Grady instance.
A small script to help with the creation of a new Grady instance.
\ No newline at end of file
## Usage
Display help:
```
python3 create-instance.py -h
```
Create a new instance folder with all necessary files:
```
python3 create-instance.py sose 18 ckurs lecturer 1.0.0 ..
```
The last argument is the path at which the folder is created, default: ..
This diff is collapsed.
Click to expand it.
create-instance.py
0 → 100644
+
67
−
0
View file @
e05919c1
import
argparse
import
os
import
shutil
CWD
=
os
.
getcwd
()
DEFAULT_FOLDER_PATH
=
os
.
path
.
join
(
CWD
,
'
..
'
)
SRC_DIR
=
os
.
path
.
dirname
(
__file__
)
DOCKER_COMPOSE_PATH
=
os
.
path
.
join
(
SRC_DIR
,
'
example.docker-compose.yml
'
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'
Create the necessary files for a new grady instance
'
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'
semester
'
,
help
=
"
Is this
'
sose
'
or
'
wise
'
?
"
)
parser
.
add_argument
(
'
year
'
,
help
=
"
Year of the semester in the format
'
18
'
or
'
1819
'
for a sose
"
)
parser
.
add_argument
(
'
course
'
,
help
=
"
E.g.
'
ckurs
'
,
'
cs1
'
or
'
cs2
'"
)
parser
.
add_argument
(
'
lecturer
'
,
help
=
"
The lecturer of the course
"
)
parser
.
add_argument
(
'
version
'
,
help
=
"
Grady version that is deployed
"
)
parser
.
add_argument
(
'
path
'
,
default
=
DEFAULT_FOLDER_PATH
,
nargs
=
'
?
'
,
help
=
"
Path where the instance folder is created.
"
"
Folder name is autogenerated and should not be part of the path
"
)
args
=
parser
.
parse_args
()
create_instance
(
args
)
def
create_instance
(
args
):
instance_folder
=
create_folder
(
args
)
shutil
.
copy2
(
DOCKER_COMPOSE_PATH
,
os
.
path
.
join
(
instance_folder
,
'
docker-compose.yml
'
))
with
open
(
os
.
path
.
join
(
instance_folder
,
'
secret
'
),
'
x
'
):
pass
create_env_file
(
args
,
instance_folder
)
print
(
"
Created instance at: {}
\n
"
"
Run
'
docker-compose pull
'
and
'
docker-compose up
'
to start the instance
"
.
format
(
instance_folder
))
def
create_folder
(
args
):
folder_name
=
"
{}_{}_{}_{}
"
.
format
(
args
.
semester
,
args
.
year
,
args
.
course
,
args
.
lecturer
)
folder_name
=
os
.
path
.
join
(
args
.
path
,
folder_name
)
try
:
os
.
mkdir
(
folder_name
)
except
OSError
:
print
(
"
The folder {} already exists. Please enter different parameters
"
.
format
(
folder_name
))
exit
(
1
)
return
folder_name
def
create_env_file
(
args
,
instance_folder
):
env_template
=
"
INSTANCE={}
\n
"
\
"
URLPATH={}
\n
"
\
"
VERSION={}
\n
"
urlpath
=
"
/{}/{}{}
"
.
format
(
args
.
course
,
args
.
semester
,
args
.
year
)
env_content
=
env_template
.
format
(
os
.
path
.
basename
(
instance_folder
),
urlpath
,
args
.
version
)
with
open
(
os
.
path
.
join
(
instance_folder
,
'
.env
'
),
'
x
'
)
as
env_file
:
env_file
.
write
(
env_content
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
example.docker-compose.yml
0 → 100644
+
42
−
0
View file @
e05919c1
version
:
"
3"
services
:
postgres
:
image
:
postgres:9.6
restart
:
always
labels
:
traefik.enable
:
"
false"
networks
:
-
internal
volumes
:
-
./database:/var/lib/postgresql/data
grady
:
image
:
docker.gitlab.gwdg.de/j.michal/grady:${VERSION}
restart
:
always
entrypoint
:
-
./deploy.sh
volumes
:
-
./secret:/code/secret
environment
:
GRADY_INSTANCE
:
${INSTANCE}
SCRIPT_NAME
:
${URLPATH}
networks
:
-
internal
-
proxy
labels
:
traefik.backend
:
${INSTANCE}
traefik.enable
:
"
true"
traefik.frontend.rule
:
Host:grady.informatik.uni-goettingen.de;PathPrefix:${URLPATH}
traefik.docker.network
:
proxy
traefik.port
:
"
8000"
depends_on
:
-
postgres
networks
:
proxy
:
external
:
true
internal
:
external
:
false
This diff is collapsed.
Click to expand it.
example.env
0 → 100644
+
6
−
0
View file @
e05919c1
# This is an example .env file which is not use for the instance generation
INSTANCE=sose_18_ckurs_brosenne
URLPATH=/ckurs/sose18
VERSION=1.0.0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment