Skip to content

Commit 50ad504

Browse files
authored
Move to Astro Starlight (and Deno) (#72)
1 parent c2fa939 commit 50ad504

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+6967
-7356
lines changed

.github/workflows/deploy.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@ on:
44
branches:
55
- main
66
paths:
7-
- 'docker-compose.yml'
8-
- 'docs/**'
9-
- 'Makefile'
10-
- 'package.json'
11-
- 'package-lock.json'
12-
- '.github/workflows/deploy.yml'
13-
schedule:
14-
- cron: '0 6 1 * *'
7+
- ".github/workflows/deploy.yml"
8+
- "astro.config.mjs"
9+
- "compose.yml"
10+
- "deno.jsonc"
11+
- "deno.lock"
12+
- "Dockerfile"
13+
- "Makefile"
14+
- "public"
15+
- "src/**"
16+
# schedule:
17+
# - cron: "0 6 1 * *"
1518
jobs:
1619
deploy:
17-
runs-on: ubuntu-latest
20+
runs-on: ubuntu-24.04-arm
1821
steps:
19-
- uses: actions/checkout@v1
20-
- name: Deploy
21-
run: make ciDeploy
22-
env:
23-
ENV_CLOUDFLARE_BRANCH_NAME: ${{ vars.ENV_CLOUDFLARE_BRANCH_NAME }}
24-
ENV_CLOUDFLARE_PROJECT_NAME: ${{ vars.ENV_CLOUDFLARE_PROJECT_NAME }}
25-
ENV_SECRET_CLOUDFLARE_ACCOUNT_ID: ${{ secrets.ENV_SECRET_CLOUDFLARE_ACCOUNT_ID }}
26-
ENV_SECRET_CLOUDFLARE_API_TOKEN: ${{ secrets.ENV_SECRET_CLOUDFLARE_API_TOKEN }}
22+
- uses: actions/checkout@v5
23+
- name: Deploy
24+
run: make ciDeploy
25+
env:
26+
ENV_CLOUDFLARE_BRANCH_NAME: ${{ vars.ENV_CLOUDFLARE_BRANCH_NAME }}
27+
ENV_CLOUDFLARE_PROJECT_NAME: ${{ vars.ENV_CLOUDFLARE_PROJECT_NAME }}
28+
ENV_SECRET_CLOUDFLARE_ACCOUNT_ID: ${{ secrets.ENV_SECRET_CLOUDFLARE_ACCOUNT_ID }}
29+
ENV_SECRET_CLOUDFLARE_API_TOKEN: ${{ secrets.ENV_SECRET_CLOUDFLARE_API_TOKEN }}

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ on:
44
paths-ignore:
55
- demo/**
66
- diagrams/**
7-
- '*.drawio'
8-
- '*.md'
97
jobs:
108
test:
11-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-24.04-arm
1210
steps:
13-
- uses: actions/checkout@v1
14-
- name: Test
15-
run: make ciTest
11+
- uses: actions/checkout@v5
12+
- name: Test
13+
run: make ciTest

.gitignore

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1+
.astro
12
.vscode
23
.DS_Store
34
*.swp
45
node_modules
6+
vendor
57
*.log
68
.env*
79
.wrangler
8-
9-
# vitepress subfolder
10-
docs/.vitepress/**/*/
11-
!docs/.vitepress/components
12-
!docs/.vitepress/config.js
13-
!docs/.vitepress/public
14-
!docs/.vitepress/theme
10+
dist

CONTRIBUTING.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
# Contributing
22

3-
<!-- Copy of docs/guide/contributing.md -->
3+
<!-- Copy of ./src/content/docs/about/contributing.mdx -->
44

5-
Contributions are greatly appreciated and here are different ways:
6-
7-
1. :star: [Star it][linkProjectRepo]!
8-
1. :mega: Share with your friends!
9-
1. :thought_balloon: Feedback! Is there anything from the project that is not clear or missing? Let us know by filing an [issue][linkProjectIssue].
10-
1. :computer: Contributing code! The project follows the typical [GitHub pull request][linkGitHubPR] model. Before starting any work, please either comment on an existing [issue][linkProjectIssue] or file a new one.
11-
1. Read [3 Musketeers website development][linkProjectREADME]
12-
1. [Fork][linkGitHubFork] this [repository][linkProjectRepo]
13-
1. Clone the forked repository
14-
1. _Optionally_, create a new branch with a meaningful name
15-
1. Make your changes
16-
1. Execute `make test`
17-
1. Commit and push your changes
18-
1. Create a [pull request from a fork][linkGitHubPRFork]
5+
Contributions are greatly appreciated.
196

7+
1. :star: Show your support by
8+
[starring the project on GitHub][linkProjectStargazers]!
9+
1. :heart: Spread the word and help others discover this project.
10+
1. :thought_balloon: Share your thoughts, ideas, or issues on
11+
[GitHub][linkProjectIssue] to help the project grow.
12+
1. :computer: Contribute improvements, fixes, or new features following the
13+
[GitHub pull request][linkGitHubPR] model. Note: Before starting any work,
14+
please either comment on an existing [issue][linkProjectIssue] or file a new
15+
one.
16+
1. Read [3 Musketeers website development][linkProjectREADME]
17+
1. [Fork][linkGitHubFork] this [repository][linkProjectRepo]
18+
1. Clone the forked repository
19+
1. _Optionally_, create a new branch with a meaningful name
20+
1. Make your changes
21+
1. Execute `make ciTest`
22+
1. Commit and push your changes
23+
1. Create a [pull request from a fork][linkGitHubPRFork]
2024

25+
[linkProjectStargazers]: https://github.com/flemay/3musketeers/stargazers
2126
[linkGitHubFork]: https://help.github.com/en/github/getting-started-with-github/fork-a-repo
2227
[linkGitHubPRFork]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork
2328
[linkGitHubPR]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# TODO: Try to make it work with alpine
2+
# libstdc++ is needed for npm:sharp
3+
# FROM denoland/deno:alpine
4+
# RUN apk --no-cache update \
5+
# && apk --no-cache upgrade \
6+
# && apk --no-cache add --upgrade make bash libstdc++ vips-dev build-base
7+
# && apk --no-cache add --upgrade make bash libstdc++ vips-dev build-base
8+
9+
# FROM denoland/deno:debian
10+
# RUN apt update \
11+
# && apt install -y make nodejs npm \
12+
# && apt clean
13+
14+
# node is currently chosen because astro build somehow calls `npx`. If `npx is not present, pagefind search pages are not generated
15+
# It is also faster to install `deno` with `npm` than installing `nodejs` and `npm` from `denoland/deno:debian`
16+
FROM node:slim
17+
RUN apt update \
18+
&& apt install -y make git curl \
19+
&& apt clean
20+
RUN npm install -g deno \
21+
&& deno --version
22+
WORKDIR /opt/app

Makefile

Lines changed: 75 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,85 @@
1-
COMPOSE_PULL = docker compose pull
2-
COMPOSE_RUN_NODE = docker compose run --rm node
3-
COMPOSE_UP_NODE = docker compose up -d node
4-
COMPOSE_UP_NODE_DEV = docker compose up node_dev
1+
noTargetGuard:
2+
$(error Target is missing)
3+
4+
COMPOSE_PULL_BUSYBOX = docker compose pull busybox
5+
COMPOSE_RUN_BUSYBOX = docker compose run --rm busybox
6+
COMPOSE_BUILD_BASE = docker compose build base
7+
# COMPOSE_RUN_CI = COMPOSE_ENVFILE=$(ENVFILE) docker compose run --rm ci
8+
COMPOSE_RUN_CI = COMPOSE_ENVFILE=.env docker compose run --rm ci
9+
COMPOSE_UP_CI = COMPOSE_ENVFILE=.env docker compose up ci -d
10+
COMPOSE_RUN_DEV = COMPOSE_ENVFILE=.env docker compose run --service-ports --rm dev
11+
COMPOSE_UP_DEV = COMPOSE_ENVFILE=$(ENVFILE) docker compose up dev
12+
13+
ASTRO_URL ?= http://ci:4321
14+
# ENVFILE ?= $(if $(wildcard .env),.env,env.template)
515
ENVFILE ?= env.template
6-
SERVE_BASE_URL ?= http://node:5173
716

8-
all:
9-
ENVFILE=env.example $(MAKE) ciTest
10-
11-
ciTest: envfile pruneDocker deps build serve test prune
12-
13-
ciDeploy: envfile pruneDocker deps build serve test deploy prune
17+
ciTest: clean envfile deps check build preview testPreview clean
18+
ciDeploy: clean envfile deps check build preview testPreview deploy clean
1419

1520
envfile:
16-
cp -f $(ENVFILE) .env
21+
$(COMPOSE_RUN_BUSYBOX) sh -c "cp -f $(ENVFILE) .env"
1722

23+
# deps creates the base image used by other compose services
24+
# It installs dependencies
1825
deps:
19-
$(COMPOSE_PULL) node
20-
$(COMPOSE_RUN_NODE) npm install
21-
22-
depsUpgrade:
23-
$(COMPOSE_PULL)
24-
$(COMPOSE_RUN_NODE) npm upgrade
25-
26-
depsAudit:
27-
-$(COMPOSE_RUN_NODE) npm outdated
28-
$(COMPOSE_RUN_NODE) npm audit
29-
30-
depsCopy:
31-
rm -fr node_modules
32-
docker compose create deps
33-
docker compose cp deps:/opt/deps/node_modules .
34-
docker compose rm -f deps
35-
36-
shell:
37-
$(COMPOSE_RUN_NODE) bash
26+
$(COMPOSE_BUILD_BASE)
27+
$(COMPOSE_RUN_CI) deno task install
28+
29+
# It copies deps from Docker volumes to the host. This is handy for auto-completion from IDE among other things.
30+
# If there is a docker running and using the Docker volumes, it will fail deleting node_modules and vendor. Run command `docker compose down` to mitigate the issue
31+
# TODO: I could potentially look into [dev containers](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers)
32+
copyDepsToHost:
33+
$(COMPOSE_RUN_BUSYBOX) sh -c "rm -fr node_modules vendor"
34+
docker compose create ci
35+
docker compose cp ci:/opt/app/node_modules .
36+
docker compose cp ci:/opt/app/vendor .
37+
docker compose rm -f ci
38+
39+
fmt \
40+
check \
41+
build \
42+
deploy \
43+
toc \
44+
update:
45+
$(COMPOSE_RUN_CI) deno task $@
3846

3947
dev:
40-
COMPOSE_COMMAND="make _dev" $(COMPOSE_UP_NODE_DEV)
41-
_dev:
42-
npx vitepress dev --host 0.0.0.0 docs
48+
COMPOSE_COMMAND="deno task $@" $(COMPOSE_UP_DEV)
49+
50+
# TODO:
51+
# - Instead of `sleep` Could potentially look at compose service health_check
52+
# - https://docs.docker.com/reference/compose-file/services/#healthcheck
53+
preview:
54+
$(info Target `preview` will sleep 5 seconds to make sure the server is up)
55+
COMPOSE_COMMAND="deno task preview" $(COMPOSE_UP_CI)
56+
$(COMPOSE_RUN_CI) sleep 5
57+
58+
previewDev:
59+
COMPOSE_COMMAND="deno task preview" $(COMPOSE_UP_DEV)
60+
61+
# testPreview test against a running preview in ci container
62+
# If preview is running in dev container, run the following:
63+
# `make testPreview ASTRO_URL=http://dev:4321
64+
testPreview:
65+
$(COMPOSE_RUN_CI) make _testPreview ASTRO_URL=$(ASTRO_URL)
66+
67+
_testPreview:
68+
$(info Test home page)
69+
curl $(ASTRO_URL) | grep "Get started" > /dev/null
70+
$(info Test Getting started)
71+
curl $(ASTRO_URL)/guides/getting-started/ | grep "Getting Started" > /dev/null
72+
73+
# clean removes everything that has been created
74+
# It also deletes the deps folders, that could've been copied to the host (`make copyDepsToHost`), with `busybox` service as it does not mount them with volumens.
75+
# There is no need to call `deno clean` as `"vendor": true` is used in `deno.jsonc`
76+
clean:
77+
docker compose down
78+
$(COMPOSE_RUN_BUSYBOX) sh -c "rm -fr dist .env node_modules vendor .astro"
79+
docker compose down --rmi "all" --remove-orphans --volumes
4380

44-
build:
45-
$(COMPOSE_RUN_NODE) make _build
46-
_build:
47-
npx vitepress build docs
48-
49-
serve:
50-
$(info serve will sleep 5 seconds to make sure the server is up)
51-
COMPOSE_COMMAND="make _serve" $(COMPOSE_UP_NODE)
52-
$(COMPOSE_RUN_NODE) sleep 5
53-
_serve:
54-
npx vitepress serve docs --port 5173
55-
56-
serveDev:
57-
COMPOSE_COMMAND="make _serve" $(COMPOSE_UP_NODE_DEV)
58-
59-
test:
60-
$(COMPOSE_RUN_NODE) make _test SERVE_BASE_URL=$(SERVE_BASE_URL)
61-
_test:
62-
echo "Test home page"
63-
curl $(SERVE_BASE_URL) | grep "Get started" > /dev/null
64-
echo "Test docs page"
65-
curl $(SERVE_BASE_URL)/guide/getting-started.html | grep "Hello, World!" > /dev/null
66-
67-
deploy:
68-
$(COMPOSE_RUN_NODE) make _deploy
69-
_deploy:
70-
npx wrangler pages deploy docs/.vitepress/dist \
71-
--project-name=$(ENV_CLOUDFLARE_PROJECT_NAME) \
72-
--branch=$(ENV_CLOUDFLARE_BRANCH_NAME) \
73-
--commit-message="Deploy!"
74-
75-
pruneDocker:
76-
docker compose down --remove-orphans --volumes
77-
78-
prune:
79-
$(COMPOSE_RUN_NODE) bash -c "rm -fr docs/.vitepress/dist docs/.vitepress/.cache"
80-
$(MAKE) pruneDocker
81-
rm -fr .env node_modules
81+
shell:
82+
$(COMPOSE_RUN_CI) bash
8283

83-
toc:
84-
$(COMPOSE_RUN_NODE) make _toc
85-
_toc:
86-
npx doctoc README.md --notitle
84+
shellDev:
85+
$(COMPOSE_RUN_DEV) bash

0 commit comments

Comments
 (0)