Skip to content

Commit d00f70b

Browse files
authored
Squashed commit of the following:
commit 347377c Author: Lars Kruse <[email protected]> Date: Sun Oct 5 12:09:57 2025 +0000 delete sample file commit eb43669 Author: Lars Kruse <[email protected]> Date: Sun Oct 5 12:09:19 2025 +0000 updated container commit 4d35ead Author: Lars Kruse <[email protected]> Date: Sun Oct 5 13:38:56 2025 +0200 Update Dockerfile path in devcontainer.json commit 35fd62e Author: Lars Kruse <[email protected]> Date: Sun Oct 5 11:28:18 2025 +0000 cleaning up - only have one container to rule them all commit 654f7af Author: Lars Kruse <[email protected]> Date: Sun Oct 5 13:21:38 2025 +0200 ready to run from codespace commit 8a0bed3 Author: Lars Kruse <[email protected]> Date: Sun Oct 5 11:12:11 2025 +0000 Added support for sparse checkout commit 6ae2e61 Author: Lars Kruse <[email protected]> Date: Sun Oct 5 07:26:52 2025 +0000 adding a new container commit 83d2429 Author: Lars Kruse <[email protected]> Date: Sun Oct 5 07:04:49 2025 +0000 added a new container commit 40a5059 Author: Lars Kruse <[email protected]> Date: Sun Oct 5 08:08:25 2025 +0200 Create dk-sample-main.yml commit 67a46c9 Author: Lars Kruse <[email protected]> Date: Sun Oct 5 07:51:34 2025 +0200 Update README with Hugo server options Added additional options for the Hugo server command in the README. commit 1cc2ef4 Author: Lars Kruse <[email protected]> Date: Fri Aug 23 07:32:19 2024 +0000 added a readme instruction on how to use the development devcontainer in a GitHub codespace
1 parent a7c543c commit d00f70b

File tree

7 files changed

+214
-1
lines changed

7 files changed

+214
-1
lines changed

.devcontainer/denmark/.gitconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[core]
2+
hooksPath = .githooks
3+
sparseCheckout = false
4+
5+
[push]
6+
default = current
7+
8+
[pull]
9+
rebase = true
10+
11+
[alias]
12+
undo-commit = reset --soft HEAD^
13+
addremove = add -A
14+
recommit = commit -C HEAD --amend
15+
co = checkout
16+
st = status
17+
root = rev-parse --show-toplevel
18+
tree = log --graph --full-history --all --color --date=short --pretty=format:\"%Cred%x09%h %Creset%ad%Cblue%d %Creset %s %C(bold)(%an)%Creset\"
19+
sweep = "!f() { git fetch --prune && git checkout main && git pull && for branch in $(git branch -vv | grep ': gone]' | awk \"{print \\$1}\"); do git branch -D \"$branch\"; done; }; f"
20+
sparse = "!f() { git config --file .devcontainer/denmark/.gitconfig core.sparseCheckout true && git read-tree -m -u HEAD; }"
21+
unsparse = "!f() { git config --file .devcontainer/denmark/.gitconfig core.sparseCheckout false && git read-tree -m -u HEAD; }"
22+
23+
24+
[safe]
25+
directory = /workspaces/devopsdays-web

.devcontainer/denmark/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Update the NODE_VERSION arg in docker-compose.yml to pick a Node version: 18, 16, 14
2+
ARG NODE_VERSION=16
3+
FROM mcr.microsoft.com/devcontainers/javascript-node:${NODE_VERSION}
4+
5+
# VARIANT can be either 'hugo' for the standard version or 'hugo_extended' for the extended version.
6+
ARG VARIANT=hugo_extended
7+
# VERSION can be either 'latest' or a specific version number
8+
ARG VERSION=latest
9+
10+
# Download Hugo
11+
RUN apt-get update && apt-get install -y ca-certificates openssl git curl && \
12+
rm -rf /var/lib/apt/lists/* && \
13+
case ${VERSION} in \
14+
latest) \
15+
export VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') ;;\
16+
esac && \
17+
echo ${VERSION} && \
18+
case $(uname -m) in \
19+
aarch64) \
20+
export ARCH=ARM64 ;; \
21+
*) \
22+
export ARCH=64bit ;; \
23+
esac && \
24+
echo ${ARCH} && \
25+
wget -O ${VERSION}.tar.gz https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${VARIANT}_${VERSION}_Linux-${ARCH}.tar.gz && \
26+
tar xf ${VERSION}.tar.gz && \
27+
mv hugo /usr/bin/hugo
28+
29+
# Hugo dev server port
30+
EXPOSE 1313
31+
32+
# [Optional] Uncomment this section to install additional OS packages you may want.
33+
#
34+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
35+
&& apt-get -y install --no-install-recommends bc
36+
37+
# [Optional] Uncomment if you want to install more global node packages
38+
# RUN sudo -u node npm install -g <your-package-list-here>

.devcontainer/denmark/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This development container is designed to run on a CodeSpace.
2+
3+
**Contrary to the default container this development container doesn't run a `postCreateCommand`. So when the container is done loading you can start the `hugo server` command with the parameters of your liking.**
4+
5+
A few helpful notes...
6+
7+
## Run `development` configuration as CodeSpace from GitHub
8+
9+
When you Create the codespace, use the options (the three dots: **...**) rather than the default to main (the plus sign **+**)
10+
11+
<img width="691" alt="image" src="https://github.com/user-attachments/assets/faa6862a-4565-4d7e-b721-db3904d723d5">
12+
13+
Then in the form flip the Dev Container Configuration option to `Development`
14+
15+
<img width="793" alt="image" src="https://github.com/user-attachments/assets/4502d58a-a141-49d1-bcff-bdcc9612b032">
16+
17+
## Build and serve
18+
19+
You run `hugo serve` to build and serve the website, but you need to tweak a few parameters to make i compliant with the codespace environment:
20+
21+
In the `hugo serve` command the parameters `--baseURL`, `--appendPort` and `--port` are all required for compliancy with a GitHub codespace.
22+
23+
Execute the following command in the terminal and you'll be fine:
24+
25+
```shell
26+
hugo server \
27+
--port 1313 \
28+
--bind=0.0.0.0 \
29+
-D \
30+
-F \
31+
-liveReloadPort=443 \
32+
--logLevel=debug
33+
--appendPort=false \
34+
--baseURL https://$CODESPACE_NAME-1313.$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN
35+
```
36+
37+
Run `hugo --help` to lean a ton of other options you can apply to tweek the development to your liking. Especially these two may prove themselves useful.
38+
39+
```
40+
-D, --buildDrafts include content marked as draft
41+
-F, --buildFuture include content with publishdate in the future
42+
```
43+
44+
## When the port hangs
45+
When you kill the command `hugo serve` it should tear down and release the port as well. Occasionally that doesn't happen. Which means that the port `1313` is bound and you can't strt the command again on port `1313`. Instead you get an error:
46+
47+
```shell
48+
Error: command error: server startup failed: listen tcp 127.0.0.1:1313: bind: address already in use
49+
```
50+
51+
When that happens run the following command to learn which process is listening to the port:
52+
53+
```shell
54+
netstat -pna | grep "1313"
55+
```
56+
57+
It will reveal the process like this:
58+
59+
```shell
60+
tcp6 0 0 :::1313 :::* LISTEN 19729/hugo
61+
```
62+
In this case PID `19729`.
63+
64+
Now simply kill it (e.g. `kill 19729`) and the port is released.
65+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"hostRequirements": {
3+
"cpus": 4,
4+
"memory": "16gb",
5+
"storage": "32gb"
6+
},
7+
"name": "Hugo (DevOpsDays Denmark)",
8+
// "image": "mcr.microsoft.com/devcontainers/universal:2",
9+
"build": {
10+
"dockerfile": "Dockerfile",
11+
"args": {
12+
// Update VARIANT to pick hugo variant.
13+
// Example variants: hugo, hugo_extended
14+
// Rebuild the container if it already exists to update.
15+
"VARIANT": "hugo_extended",
16+
// Update VERSION to pick a specific hugo version.
17+
// Example versions: latest, 0.73.0, 0,71.1
18+
// Rebuild the container if it already exists to update.
19+
"VERSION": "latest",
20+
// Update NODE_VERSION to pick the Node.js version: https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/javascript-node/tags
21+
"NODE_VERSION": "20-bookworm"
22+
}
23+
},
24+
"forwardPorts": [
25+
1313
26+
],
27+
"postCreateCommand": ".devcontainer/postCreateCommand.sh",
28+
"features": {
29+
"ghcr.io/devcontainers/features/common-utils:2": {},
30+
"ghcr.io/devcontainers/features/github-cli:1": {},
31+
"ghcr.io/devcontainers-extra/features/npm-packages:1": {
32+
"packages": [
33+
"cspell",
34+
"markdownlint-cli2"
35+
]
36+
}
37+
},
38+
"customizations": {
39+
"vscode": {
40+
"extensions": [
41+
"GitHub.copilot",
42+
"GitHub.copilot-chat",
43+
"DavidAnson.vscode-markdownlint",
44+
"streetsidesoftware.code-spell-checker"
45+
]
46+
}
47+
}
48+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
PREFIX="🍰 "
6+
echo "$PREFIX Running $(basename $0)"
7+
8+
9+
echo "$PREFIX Setting up git configuration to support .gitconfig in devcontainer root"
10+
git config --local --get include.path | grep -e ../.devcontainer/denmark/.gitconfig >/dev/null 2>&1 || git config --local --add include.path ../.devcontainer/denmark/.gitconfig
11+
12+
echo "$PREFIX Setting up GitHub CLI to use devopsdays-dk/devopsdays-web as default repo"
13+
gh repo set-default devopsdays-dk/devopsdays-web
14+
15+
# echo "$PREFIX Setting up sparse checkout"
16+
# ln -sf /workspaces/devopsdays-web/.devcontainer/denmark/sparse-checkout .git/info/sparse-checkout
17+
18+
echo "$PREFIX SUCCESS"
19+
exit 0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Only checkout files relevant for development
2+
.devcontainer/
3+
README.md
4+
package.json
5+
netlify.toml
6+
config/
7+
content/blog/
8+
content/page/
9+
content/speaking/
10+
content/events/2026*/
11+
data/events/2026/
12+
themes/
13+
utilities/
14+
makefile
15+
CONTRIBUTING.md

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,7 @@ hugo.log
8787
yarn.lock
8888

8989
# hugo rendering folder
90-
resources/_gen/
90+
resources/_gen/
91+
92+
# cache files
93+
.*cache

0 commit comments

Comments
 (0)