-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.html
More file actions
271 lines (245 loc) · 10.3 KB
/
static.html
File metadata and controls
271 lines (245 loc) · 10.3 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="description" content="Leo Castro Project 1 - Docker Example" />
<meta name="author" content="Leo Castro" />
<title>Static Website with Nginx</title>
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Google Font -->
<link
href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<!-- Bootstrap Icons -->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css"
rel="stylesheet"
/>
<!-- Core Theme CSS (includes Bootstrap) -->
<link href="css/styles.css" rel="stylesheet" />
<!-- Syntax Highlighting Theme -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark-dimmed.min.css"
/>
<style>
/* Optional: keep code boxes visually consistent with your cards */
.code-box pre {
background-color: #1e1e1e;
color: #4434;
padding: 1rem;
border-radius: 0.5rem;
overflow-x: auto;
font-size: 1.5rem;
}
/*line height spacing in paragraphs */
p {
line-height: 1.65;
}
.code-box pre {
background-color: #1b263b; /* dark navy background */
color: #f8f9fa; /* light text for contrast */
border-left: 4px solid #9b2dd1; /* purple accent line to match header */
line-height: 2.5;
padding: 0rem 1rem 0rem 1rem; /* top | right | bottom | left */
border-radius: 10px;
font-size: 0.95rem;
line-height: 1.3;
overflow-x: auto; /* prevent overflow on smaller screens */
height: auto;
box-shadow: 0 2px 8px rgba(0,0,0,0.15); /* soft shadow for depth */
}
.code-box code {
background-color: transparent;
color: inherit; /* keeps text consistent */
font-family: 'Fira Code', monospace; /* optional: clean coding font */
}
.inline-boxed-code {
background-color: #eaeaea;
border: 1px solid #ddd;
border-radius: 4px;
padding: 2px 6px;
font-family: monospace;
font-size: 0.95rem;
color: #333;
}
img{
float:right;
margin:10px;
}
</style>
</head>
<body class="d-flex flex-column h-100 bg-light">
<main class="flex-shrink-0">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-white py-3">
<div class="container px-5">
<a class="navbar-brand" href="index.html"
><span class="fw-bolder text-primary">Leo Castro</span></a
>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div
class="collapse navbar-collapse"
id="navbarSupportedContent"
>
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 small fw-bolder">
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="projects.html">Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<section class="py-5">
<div class="container px-5">
<h1 class="fw-bold text-center mb-4" style="color:#9b2dd1;">
Static Website with Nginx and Docker
</h1>
<!-- Project Card -->
<div class="row gx-5 justify-content-center">
<div class="col-lg-12 col-xl-10">
<!-- Docker Project Example Section -->
<section>
<div class="card shadow border-0 rounded-4 mb-5">
<div class="card-body p-5">
<div class="text-center mb-4"></div>
<span style="font-weight:bold; font-size:16px;color: #9b2dd1;">
11.02.2025
</span>
<br><br>
<p>
Having just graduated, I wasn’t quite sure where to start showcasing my work. While taking my Data Science SQL course, I followed <a href="https://www.youtube.com/@amigoscode" target="_blank" rel="noopener noreferrer">@amigoscode </a>
tutorials alongside the class and found him to be an excellent instructor. I had bookedmarked Nelson's and Nana's <a href="https://www.youtube.com/watch?v=Wf2eSG3owoA" target="_blank" rel="noopener noreferrer">Docker and Kubernetes –
Full Course for Beginners </a> a while back and finally had the time to finish watching it. Now was the perfect time to dive into containerization and build a personal website. I used
a <a href="https://startbootstrap.com" target="_blank" rel="noopener noreferrer">Bootstrap template</a> to streamline the development
process.
</p>
<p>
I built and deployed a static webpage using Nginx as the web server. The official <a href=" https://hub.docker.com/_/nginxNginx" target="_blank" rel="noopener noreferrer"> Nginx Docker </a>image
documentation is a great reference for creating and customizing configurations. Nginx
functions as a reverse proxy and web server that supports HTTP, HTTPS, SMTP, POP3, and IMAP protocols, while also providing caching capabilitie.
</p>
<p>
This is more of my personal overview of running a setup than an actual tutorial. Below is an overview of the basic git commands. It seems scary at first, but once you have done it a number of
times, it becomes a breeze.
</p>
<!-- Image on Top, Text Below -->
<div class="card border-0 text-center my-3">
<!-- Image on top -->
<img src="assets/git_diagram.png"
alt="Git diagram"
class="card-img-top mx-auto d-block"
style="max-width:410px; height:auto;">
<!-- Text content below -->
<div class="card-body text-start">
<h4 class="fw-bold">Exposing Port</h4>
<p>
I then exposed my directory contents to an external port and opened my browser to <code class="inline-boxed-code">http://localhost:8000</code>. Name your container <i>custom_name</i> and the
image <i> some-image.</i>
</p>
<div class="code-box mb-4">
<pre><code class="language-bash">
# create Docker image
docker run --name custom_name -d -p 8000:80 some-image
</code></pre>
</code></pre>
<h4 class="fw-bold">Enter Container Shell</h4>
<p>
If you want to view your directory inside your container, the <code class="inline-boxed-code">docker exec</code> commands allows entry using <code class="inline-boxed-code">sh</code>.
</p>
<div class="code-box mb-4">
<pre><code class="language-bash">
# enter Docker interactive mode
docker exec -it some-image-nginx sh
# Docker root
ls -al
cd usr/share/nginx/html
</code></pre>
<h4 class="fw-bold">Commit and Push</h4>
<p>
I used Github Pages to publish my static webpage. After setting up my SSH key, I was able to commit and push changes directly from my local directory to Github.
</p>
<div class="code-box mb-4">
<pre><code class="language-bash">
# Commit and push to main or master
git add .
git commit -m “description”
git push -u origin main
</code></pre>
<br>
<p>
The above is a simplistic overview, but in reality it took about a week of of playing with Docker and Git commands. CSS and HTML editing took another week, though the Bootstrap
documentation and web searches facilitated this. I used ChatGP intermittently, but it just turned out be a huge disaster. I don't always find it reliable and gives you word salad. At
one point, I contemplated creating a Next.js or Flask app with postgres for the <i>Contact Me</i> page, but opted to use formspree.io as I just needed to get the website up and
running. That could be for a future post. I also created a .gitignore file to keep unnecessary files out of version control as I continue building new projects.
</p>
<p>
Overall, this was a great foundational project to start with. I’ve worked with Docker before, but only at a surface level. Being an Arch user, I’m comfortable working from the
terminal, but my Neovim workflow improved significantly throughout this project. I did get sidetracked starting another project before circling back to complete this one. There were
plenty of headaches along the way trying to get everything fully implemented, but that’s the whole point of building projects—you learn the most by troubleshooting when things go wrong.
</p>
<p>
Thanks for reading if you made it this far!
</p>
</div>
</div>
</section>
<!-- Back Button -->
<div class="text-center">
<a class="btn btn-primary px-4 py-2 fw-semibold" href="projects.html">
← Back to Projects
</a>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="bg-white py-4 mt-auto">
<div class="container px-5">
<div
class="row align-items-center justify-content-between flex-column flex-sm-row"
>
<div class="col-auto">
<div class="small m-0">© Leo Castro 2025</div>
</div>
<div class="col-auto">
<a class="small" href="projects.html">Projects</a>
<span class="mx-1">·</span>
<a class="small" href="index.html">Home</a>
<span class="mx-1">·</span>
<a class="small" href="contact.html">Contact</a>
</div>
</div>
</div>
</footer>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
<script src="js/scripts.js"></script>
</body>
</html>