-
Notifications
You must be signed in to change notification settings - Fork 12
/
walk-through.sh
executable file
·155 lines (115 loc) · 4.21 KB
/
walk-through.sh
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
#!/usr/bin/env bash
# Script for creating Dockta CLI walkthrough presenting the key features.
# Include the demoing code
. demo-magic.sh
clear
# Set some themeing options
DEMO_PROMPT=$BLUE"$ "
DEMO_CMD_COLOR=$GREEN
# For a live, manual walkthough (-i.e. without using the -n flag where we press
# enter for each command) we want 'instant' typing (by undefining TYPE_SPEED)
TYPE_SPEED=
# Do some clean up first
rm tests/fixtures/r-spatial/*.png 2> /dev/null
# Run the demo!
p "# Welcome to this walkthrough presenting the key features of Dockta\n"
p "# First we'll change into one of the R example projects"
pe "cd tests/fixtures/r-spatial"
p "# And take a look at the files in it"
pe "ls"
sleep 1
p "# The 'main.R' file reads in some spatial data and plots it"
pe "cat main.R"
sleep 1
p "# Let's start by using Dockta to 'compile' this project"
pe "dockta compile"
sleep 1
p "# You'll see that Dockta has created several new files, prefixed with a dot"
pe "ls -a"
sleep 2
p "# .DESCRIPTION is a R package description file which Dockta has generated for you"
p "# based on the packages used in main.R"
pe "cat .DESCRIPTION"
sleep 3
p "# .environ.jsonld is a JSON-LD file which describes the project, and it's dependendencies, as linked data"
pe "cat .environ.jsonld | head -n 30"
sleep 3
p "# The .Dockerfile is generated from this information"
pe "cat .Dockerfile"
sleep 3
p "# Okay, so let's build this thing!"
pe "dockta build"
sleep 3
p "# Let's check that it's built by listing the Docker images on this machine"
pe "docker images | head -n 5"
sleep 2
p "# Note that the image r-spatial was just created and it has two tags: 'latest' and 'system' "
p "# These two tags are used by Dockta's incremental builds"
p "# We can have a look into the layers of the Docker image that we just built"
pe "docker history r-spatial"
sleep 2
p "# If you add, remove or update a package in your project, Dockta will do an \"intelligent\", incremental rebuild."
p "# Let's see how incremental build works in practice"
pe "echo \"library(forcats)\" >> main.R"
sleep 2
pe "cat main.R"
sleep 2
p "# The R code now requires a new library to be available. Let's then recompile the project"
pe "dockta compile"
sleep 2
p "# Let's check that Dockta has added that package to the files that it generates."
pe "cat .DESCRIPTION"
sleep 3
pe "cat .Dockerfile"
sleep 3
p "# Let's then rebuild the image"
pe "dockta build"
sleep 2
p "# The Docker history will show us how the images were updated"
pe "docker history r-spatial"
sleep 3
p "# Now we can execute this project"
pe "dockta execute"
sleep 2
p "# That started a container using the new image, mounted the project directory into the container and ran main.R"
p "# The project folder now has a new file in it, plot.png, created by R from within the container"
pe "ls -lt"
sleep 2
p "# Now we've executed the project and created a reproducible figure. Give credit where credit is due!"
p "# The who command lists all the contributors of all the packages that your project depends upon"
pe "dockta who"
p "# Let's try this on another example using some Python code"
pe "cd ../py-weather"
pe "ls"
sleep 2
p "# Let's see what we mean by \"east to pick up, easy to throw away\". As it is now, the project does not have a requirements.txt file. "
p "# Dockta will create it for us"
pe "dockta compile"
sleep 2
pe "ls -a"
sleep 2
p "# The packages required for the project should now be in the file"
pe "cat .requirements.txt"
sleep 2
p "# If we want to now be in charge, we need to rename the requirements.txt file"
pe "mv .requirements.txt requirements.txt"
sleep 2
p "# Let's add anoter Python package to requirements.txt"
pe "echo -e '\npython-dateutil==2.7.5' >> requirements.txt"
sleep 2
p "# The dateutil package should now be added to the list in the requirements.txt file"
pe "cat requirements.txt"
sleep 2
p "# Let's build the image for the project. Dockta will pick up the new package from the requirements.txt file."
pe "dockta build"
sleep 2
p "# Now we should see the image on the list"
pe "docker images"
sleep 2
p "# Check out the docs (https://github.com/stencila/dockta#readme) for more things you can do with Dockta."
p "# Thanks for watching!"
sleep 2
p "# This demo was created using"
pe "dockta --version"
sleep 2
exit