Skip to content

Commit 3f8c7e5

Browse files
authored
Merge pull request #199 from timvink/copilot/fix-alpine-build-issues
Add documentation for Alpine Linux Docker usage
2 parents 2dac8aa + 7311110 commit 3f8c7e5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

docs/howto/use-in-alpine-docker.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Use in Alpine Linux Docker
2+
3+
When using this plugin in a Docker container based on Alpine Linux, you may encounter the following error:
4+
5+
```text
6+
LookupError: Unknown timezone UTC
7+
```
8+
9+
This happens because Alpine Linux, being a minimal distribution, does not include timezone data by default. The [babel](https://github.com/python-babel/babel) library used by this plugin requires timezone information to function correctly.
10+
11+
## Solution
12+
13+
Install the `tzdata` package in your Alpine-based Docker image:
14+
15+
```dockerfile
16+
# Install timezone data
17+
RUN apk add --no-cache tzdata
18+
```
19+
20+
!!! example "Example Dockerfile"
21+
22+
```dockerfile
23+
FROM python:3.12-alpine
24+
25+
# Install timezone data for babel/mkdocs-git-revision-date-localized-plugin
26+
RUN apk add --no-cache tzdata git
27+
28+
# Install MkDocs and plugins
29+
RUN pip install mkdocs mkdocs-material mkdocs-git-revision-date-localized-plugin
30+
31+
WORKDIR /docs
32+
```
33+
34+
!!! tip "Why this is needed"
35+
36+
The Python `zoneinfo` module relies on system-level timezone data to resolve timezone names like "UTC". Without the `tzdata` package installed, Alpine Linux does not have this data available, causing the `LookupError`.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ nav:
1010
- howto/specify-locale.md
1111
- howto/custom-styling.md
1212
- howto/override-a-theme.md
13+
- howto/use-in-alpine-docker.md
1314
- options.md
1415

1516
theme:

0 commit comments

Comments
 (0)