Skip to content

Commit 82a180f

Browse files
committed
feat: Add docker support
1 parent 876126b commit 82a180f

7 files changed

Lines changed: 160 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ jobs:
1111
uses: shalzz/zola-deploy-action@master
1212
env:
1313
PAGES_BRANCH: gh-pages
14+
ZOLA_CONFIG: config.github.toml
1415
TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM ghcr.io/getzola/zola:v0.21.0 AS build
2+
3+
ARG ZOLA_CONFIG=config.toml
4+
ENV ZOLA_CONFIG=${ZOLA_CONFIG}
5+
6+
WORKDIR /src
7+
8+
COPY . /src
9+
10+
RUN [ "zola", "build" ]
11+
12+
FROM nginx:1.29.3-alpine
13+
14+
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
15+
COPY --from=build /src/public /usr/share/nginx/html/
16+
17+
EXPOSE 80

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,38 @@ Polecenie buduje stronę w trybie developerskim i udostępnia ją pod adresem `h
6565
- Wyślij zmiany w osobnej gałęzi, opisz krótko nowy wpis i poproś o review.
6666

6767
Po wdrożeniu wpis pojawi się automatycznie w blogu oraz na stronie archiwum (`/archiwum/`), zgodnie z datą publikacji i przypisanymi tagami.
68+
69+
## Docker
70+
71+
Poniżej znajdziesz przykładowe kroki budowania obrazu Docker, który generuje stronę za pomocą Zola podczas etapu build i serwuje ją przez Nginx.
72+
73+
- Domyślna komenda buduje używając pliku konfiguracyjnego `config.toml` (domyślnie ustawionego w `Dockerfile`):
74+
75+
```bash
76+
docker build -t rustlab-page:latest .
77+
```
78+
79+
- Aby użyć innego pliku konfiguracyjnego przekaż go jako build-arg `ZOLA_CONFIG`:
80+
81+
```bash
82+
docker build --build-arg ZOLA_CONFIG=some-other-config.toml -t rustlab-page:latest .
83+
```
84+
85+
- Uwaga dotycząca motywu (`themes/tabi`): motyw jest dołączony jako submodule Git. Upewnij się, że submoduły zostały zainicjalizowane przed budowaniem obrazu (w przeciwnym razie Zola nie znajdzie `theme.toml` i build zakończy się niepowodzeniem):
86+
87+
```bash
88+
# jeśli już sklonowałeś repozytorium
89+
git submodule update --init --recursive
90+
91+
# lub przy klonowaniu
92+
git clone --recurse-submodules <repo-url>
93+
```
94+
95+
- Po zbudowaniu obrazu możesz go uruchomić lokalnie i przekierować port 80 kontenera na inny port hosta:
96+
97+
```bash
98+
docker run --rm -p 8080:80 rustlab-page:latest
99+
# potem odwiedź http://localhost:8080
100+
```
101+
102+
W środowiskach CI/CD pamiętaj, by klonować repozykotorium z submodułami lub wykonać `git submodule update --init --recursive` przed etapem budowania obrazu.

config.github.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# The URL the site will be built for
2+
base_url = "https://rust-lab-pjatk.github.io"
3+
title = "Rust Lab PJATK"
4+
theme = "tabi"
5+
default_language = "pl"
6+
taxonomies = [{ name = "tags", feed = true }]
7+
8+
# Whether to automatically compile all Sass files in the sass directory
9+
compile_sass = true
10+
11+
# Whether to build a search index to be used later on by a JavaScript library
12+
build_search_index = false
13+
14+
[markdown]
15+
# Whether to do syntax highlighting
16+
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
17+
highlight_code = true
18+
highlight_theme = "css"
19+
bottom_footnotes = true
20+
21+
[extra]
22+
# Put all your custom variables here
23+
skin = "pjatk"
24+
browser_theme_color = "#e30613"
25+
favicon_emoji = "🦀"
26+
toc = true
27+
quick_navigation_buttons = true
28+
show_author = true
29+
katex = true
30+
mermaid = true
31+
menu = [
32+
{ name = "blog", url = "blog" },
33+
{ name = "tags", url = "tags" },
34+
{ name = "archive", url = "archiwum" },
35+
]
36+
socials = [
37+
{ name = "email", url = "mailto:rustlab@pjwstk.edu.pl", icon = "email" },
38+
{ name = "github", url = "https://github.com/Rust-Lab-PJATK", icon = "github" },
39+
{ name = "linkedin", url = "https://www.linkedin.com/company/rust-lab-pjatk", icon = "linkedin" },
40+
{ name = "instagram", url = "https://www.instagram.com/rustlabpjatk", icon = "instagram" },
41+
]
42+
copyright = "© $CURRENT_YEAR Rust Lab PJATK $SEPARATOR Materiały na tej stronie są udostępniane na licencji [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0)."

config.pjatk.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# The URL the site will be built for
2+
base_url = "https://rustlab.pja.edu.pl"
3+
title = "Rust Lab PJATK"
4+
theme = "tabi"
5+
default_language = "pl"
6+
taxonomies = [{ name = "tags", feed = true }]
7+
8+
# Whether to automatically compile all Sass files in the sass directory
9+
compile_sass = true
10+
11+
# Whether to build a search index to be used later on by a JavaScript library
12+
build_search_index = false
13+
14+
[markdown]
15+
# Whether to do syntax highlighting
16+
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
17+
highlight_code = true
18+
highlight_theme = "css"
19+
bottom_footnotes = true
20+
21+
[extra]
22+
# Put all your custom variables here
23+
skin = "pjatk"
24+
browser_theme_color = "#e30613"
25+
favicon_emoji = "🦀"
26+
toc = true
27+
quick_navigation_buttons = true
28+
show_author = true
29+
katex = true
30+
mermaid = true
31+
menu = [
32+
{ name = "blog", url = "blog" },
33+
{ name = "tags", url = "tags" },
34+
{ name = "archive", url = "archiwum" },
35+
]
36+
socials = [
37+
{ name = "email", url = "mailto:rustlab@pjwstk.edu.pl", icon = "email" },
38+
{ name = "github", url = "https://github.com/Rust-Lab-PJATK", icon = "github" },
39+
{ name = "linkedin", url = "https://www.linkedin.com/company/rust-lab-pjatk", icon = "linkedin" },
40+
{ name = "instagram", url = "https://www.instagram.com/rustlabpjatk", icon = "instagram" },
41+
]
42+
copyright = "© $CURRENT_YEAR Rust Lab PJATK $SEPARATOR Materiały na tej stronie są udostępniane na licencji [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0)."

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The URL the site will be built for
2-
base_url = "https://rust-lab-pjatk.github.io"
2+
base_url = "http://localhost"
33
title = "Rust Lab PJATK"
44
theme = "tabi"
55
default_language = "pl"

nginx/nginx.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name _;
5+
6+
access_log /var/log/nginx/host.access.log main;
7+
8+
gzip on;
9+
gzip_comp_level 6;
10+
gzip_types
11+
text/html
12+
text/css
13+
application/javascript
14+
image/svg+xml
15+
font/woff2;
16+
17+
root /usr/share/nginx/html;
18+
19+
location / {
20+
index index.html;
21+
}
22+
}

0 commit comments

Comments
 (0)