m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/blog/gitlab-namecheap.html
blob: cd87ef355a72340502c0b6cdbb63b19b117fded5 (plain)
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
title: GitLab Pages + Namecheap
date: June 29, 2019
---
<p>
This website is currently hosted as a GitLab Pages page. In addition to the
free m-chrzan.gitlab.io domain name that GitLab provides, it's also
pointed to by m-chrzan.xyz. This was my first time hosting a static
site and interacting with a domain name registrar/DNS settings, so I wanted to
write down some thoughts and tips while it's all still fresh in my mind.
</p>

<h3>Static site generation for GitLab Pages</h3>
<p>
Unlike some other static site hosts (like Git<em>Hub</em> Pages), GitLab doesn't
have you just upload the html/css/js files for your static site and host them
directly, but gives you the option to maintain a repo that uses some sort of
static site generator (say Jekyll, a popular option). It then has you use the
gitlab-ci system available for every repo to actually compile the website, and
if that succeeds, makes your website available. 
</p>

<p>
You still have the option to host a set of plain html files, and GitLab provides
<a href='https://gitlab.com/pages/plain-html'>a template</a> for that setup.
</p>

<p>
One slight point of confusion I encountered was when I missed that the build
directory has to be called <code>public</code>. Just looking at different
<code>.gitlab-ci.yml</code> examples, I thought GitLab would look under whatever
path was specified with
<code><pre>
pages:
    artifacts:
        paths:
        - &lt;path&gt;
</pre></code>
Initially my generator was putting build files in a <code>build</code>
directory. This would result in my CI build succeeding, but the external build
that GitLab does to actually publish the website would fail, without a useful
error message. A little embarassing how much time I spent debugging this one...
</p>

<h3>DNS configuration</h3>
<p>
I picked Namecheap as my registrar because they're considered reliable, have
cheap registration (got this .xyz for $1 for the first year!), and they're not
GoDaddy. Registration and payment was super simple, would recommend. The DNS
configuration page can be slow to respond unfortunately.
</p>

<p>
I've never played around with configuring DNS records, but GitLab's
documentation had fairly clear explanations. The biggest gripe I had was that
the official documentation
<a href='https://docs.gitlab.com/ee/user/project/pages/getting_started_part_three.html#dns-a-record'>
    recommends against using a CNAME record
</a>, while the Pages UI under my repo had a CNAME record (and no A record) made
available for copying, as if that were the recommended route. I ended up
creating an A record pointing to 35.185.44.232 as described in the docs.
</p>

<p>
I had a few issues that I'm not sure if they were caused by Namecheap or just
expected DNS propagation delays. It took several hours for the A record to
appear in DNS queries. Additionally, I missed the part where when creating the
<a href='https://docs.gitlab.com/ee/user/project/pages/getting_started_part_three.html#dns-txt-record'>
    TXT record
</a> that verifies ownership of a domain name, if you're creating it for an A
record, you should just use your top-level domain. Again, confusingly, the
Pages UI provides a copyable text field to a dummy subdomain and I had to dig
through the docs to find the correct approach.
</p>