-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchapter2.html
More file actions
243 lines (219 loc) · 9.78 KB
/
chapter2.html
File metadata and controls
243 lines (219 loc) · 9.78 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The problem</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="icon" type="image/x-icon" href="mc2/images/favicon.ico">
<link rel="stylesheet" href="mc2/styles/reveal.css">
<link rel="stylesheet" href="mc2/styles/theme.css" id="theme">
<link rel="stylesheet" href="mc2/styles/code.css">
<!--STARTCOURSESPECIFICSTYLES--><link rel="stylesheet" href="styles/styles.css"><!--ENDCOURSESPECIFICSTYLES-->
</head>
<body>
<div id="pos"></div>
<div class="reveal">
<div class="slides">
<section class="slide chaptertitle">
<div class="slidecontent">
<div class="chapternumber"> chapter 2 of 3 </div>
<h1>The problem</h1>
</div>
</section>
<!--STARTSECTIONINDEX--><section class="slide sectionlist">
<div class="slidecontent">
<h3>Sections in this chapter</h3>
<ol>
<li><a href="#/2">Our use case</a></li>
<li><a href="#/3">Introducing the problem</a></li>
</ol>
</div>
</section>
<!--ENDSECTIONINDEX-->
<!--STARTCHAPTERCONTENT--><!--STARTSECTION1--><section>
<section class="slide sectiontitle">
<div class="slidecontent">
<div class='sectioncount'>Section 1/2</div>
<h3>Our use case</h3>
<p>Guess a UUID</p>
</p>
</div>
</section>
<section class="slide" data-pos="2-1-1">
<span class="pos">2-1-1</span>
<div class="slidecontent"><h3 id="a-simple-game-">A simple game*</h3>
<p><img style="max-width: 70%" src="resources/images/guess-a-uuid.png"></p>
<p><strong>* some cheating required...</strong></p>
</div></section><section class="slide" data-pos="2-1-2">
<span class="pos">2-1-2</span>
<div class="slidecontent"><h3 id="generating-the-uuid-">Generating the uuid:</h3>
<p><pre><code><span class="hljs-keyword">import</span> uuid <span class="hljs-keyword">from</span> <span class="hljs-string">'uuid/v4'</span>;
<span class="hljs-keyword">let</span> uuidToGuess;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">resetUuid</span>(<span class="hljs-params"></span>) </span>{
uuidToGuess = uuid();
}
resetUuid();</code></pre></p>
</div></section><section class="slide" data-pos="2-1-3">
<span class="pos">2-1-3</span>
<div class="slidecontent"><h3 id="serving-a-simple-page-">Serving a simple page:</h3>
<p><pre><code>app.get(<span class="hljs-string">'/'</span>, (req, res) => {
res.status(<span class="hljs-number">200</span>).send(<span class="hljs-string">'<h1>Guess a uuid!</h1><br>'</span> +
<span class="hljs-string">'Guess here: /guess/:uuid-to-guess<br>'</span> +
<span class="hljs-string">'Reset Game Here: /reset'</span>);
});</code></pre></p>
</div></section><section class="slide" data-pos="2-1-4">
<span class="pos">2-1-4</span>
<div class="slidecontent"><h3 id="the-routes-">The routes:</h3>
<p><pre><code>app.get(<span class="hljs-string">'/guess/:uuid'</span>, (req, res) => {
res.status(<span class="hljs-number">200</span>).json({<span class="hljs-string">'correct'</span>: uuidToGuess === req.params.uuid});
});
app.get(<span class="hljs-string">'/reset'</span>, (req, res) => {
resetUuid();
res.status(<span class="hljs-number">200</span>).send(<span class="hljs-string">'uuid to guess is now reset!'</span>);
});</code></pre></p>
</div></section><section class="slide" data-pos="2-1-5">
<span class="pos">2-1-5</span>
<div class="slidecontent"><h3 id="the-docker-file-">The docker file:</h3>
<p><pre><code><span class="hljs-keyword">FROM</span> node:<span class="hljs-number">8</span>
<span class="hljs-keyword">WORKDIR</span><span class="bash"> /work
</span><span class="hljs-keyword">COPY</span><span class="bash"> ./ /work/
</span><span class="hljs-comment">#RUN npm install</span>
<span class="hljs-comment">#RUN npm run build</span>
<span class="hljs-keyword">EXPOSE</span> <span class="hljs-number">8080</span>
<span class="hljs-keyword">CMD</span><span class="bash"> [<span class="hljs-string">"node"</span>, <span class="hljs-string">"server-build.js"</span>]</span></code></pre></p>
</div></section>
</section>
<!--ENDSECTION1-->
<!--STARTSECTION2--><section>
<section class="slide sectiontitle">
<div class="slidecontent">
<div class='sectioncount'>Section 2/2</div>
<h3>Introducing the problem</h3>
<p>Debugging outside of Docker</p>
</p>
</div>
</section>
<section class="slide" data-pos="2-2-1">
<span class="pos">2-2-1</span>
<div class="slidecontent"><h3 id="debug-in-ide">Debug in IDE</h3>
<ul>
<li>Run app as per normal</li>
<li>Set breakpoints</li>
<li>Dockerize app</li>
<li>Run Docker container</li>
<li><strong>Cross fingers!</strong></li>
</ul>
</div></section><section class="slide" data-pos="2-2-2">
<span class="pos">2-2-2</span>
<div class="slidecontent"><h3 id="configure-debugger-">Configure debugger:</h3>
<p><img style="max-width: 70%" src="resources/images/debugger-setup.png"></p>
</div></section><section class="slide" data-pos="2-2-3">
<span class="pos">2-2-3</span>
<div class="slidecontent"><h3 id="set-breakpoint-">Set breakpoint:</h3>
<p><img style="max-width: 70%" src="resources/images/breakpoint.png"></p>
</div></section><section class="slide" data-pos="2-2-4">
<span class="pos">2-2-4</span>
<div class="slidecontent"><h3 id="setup-source-maps-">Setup source maps:</h3>
<p><pre><code> <span class="hljs-string">"scripts"</span>: {
<span class="hljs-string">"test"</span>: <span class="hljs-string">"echo \"Error: no test specified\" && exit 1"</span>,
<span class="hljs-string">"serve"</span>: <span class="hljs-string">"babel-node server.js"</span>,
<span class="hljs-string">"build"</span>: <span class="hljs-string">"babel server.js -o server-build.js --source-maps inline"</span>
},
</code></pre></p>
</div></section><section class="slide" data-pos="2-2-5">
<span class="pos">2-2-5</span>
<div class="slidecontent"><h3 id="debugger-configured-with-source-maps">Debugger configured with source maps</h3>
<p><img style="max-width: 70%" src="resources/images/debugger-setup-sourcemap.png"></p>
</div></section><section class="slide" data-pos="2-2-6">
<span class="pos">2-2-6</span>
<div class="slidecontent"><h3 id="demo">Demo</h3>
<p><strong>Trying the game</strong></p>
</div></section><section class="slide" data-pos="2-2-7">
<span class="pos">2-2-7</span>
<div class="slidecontent"><h3 id="building-the-docker-image">Building the Docker image</h3>
<p><pre><code>$ docker build . -t game:s0
</code></pre></p>
</div></section><section class="slide" data-pos="2-2-8">
<span class="pos">2-2-8</span>
<div class="slidecontent"><h3 id="running-the-docker-image">Running the Docker image</h3>
<p><pre><code>$ docker run -p8080:8080 game:s0
</code></pre></p>
</div></section><section class="slide" data-pos="2-2-9">
<span class="pos">2-2-9</span>
<div class="slidecontent"><h3 id="running-detached">Running Detached</h3>
<p><pre><code>$ docker run -d -p8080:8080 game:s0
</code></pre></p>
</div></section><section class="slide" data-pos="2-2-10">
<span class="pos">2-2-10</span>
<div class="slidecontent"><h3 id="demo">Demo</h3>
<p><strong>Our isolated game</strong></p>
</div></section><section class="slide" data-pos="2-2-11">
<span class="pos">2-2-11</span>
<div class="slidecontent"><p><strong>Currently we have no way to debug our game while running in docker.</strong></p>
</div></section>
</section>
<!--ENDSECTION2--><!--ENDCHAPTERCONTENT-->
</div>
</div>
<script type="text/javascript">
var basehref = window.location.href.replace(/chapter\d.*?$/,'')
document.addEventListener("keydown",function(e){
var code = e.which || e.keyCode;
if (code===13){
window.location.href = basehref+"index.html?from="+(2-1);
} else if (code >= 49 && code <= 2+48) {
window.location.hash = "#/" + (code-48+1+0);
}
if (2 < 3) {
if (code===99){ // the letter C for next Chapter
window.location.href = basehref+"chapter"+(2+1)+".html"
}
}
});
</script>
<script src="mc2/scripts/head.js" type="text/javascript"></script>
<script src="mc2/scripts/reveal.js" type="text/javascript"></script>
<script src="mc2/scripts/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
showNotes: false,
transition: 'slide',
dependencies: [
{ src: 'mc2/scripts/plugin/notes/notes.js', async: true }
]
})
window.onload = function(){
var links = document.querySelectorAll("a.link");
for(var i=0;i<links.length;i++){
var link = links[i];
link.innerHTML = link.innerHTML.replace(/ /g,' ')
}
var posElem = document.getElementById('pos')
function updateReference(){
setTimeout(function(){
var currentpos = document.querySelector('section.present[data-pos]')
if (currentpos){
posElem.innerHTML = currentpos.getAttribute('data-pos')
} else {
posElem.innerHTML = ''
}
if (document.querySelector('.present.chaptertitle')){
document.body.classList.add('atchaptertitle');
} else {
document.body.classList.remove('atchaptertitle');
}
},10)
}
window.addEventListener("hashchange",updateReference);
updateReference();
};
</script>
<!--STARTCOURSESPECIFICSCRIPTS--><script type="text/javascript" src="/reload/reload.js"></script><!--ENDCOURSESPECIFICSCRIPTS-->
</body>
</html>