Skip to content

Commit 4107b87

Browse files
committed
Merge remote-tracking branch 'old_origin/20-merge-karmacomputingserver-bootstrap-into-public-karmacomput' into 27-recieve-merge-of-karmacomputingserver-bootstrap-ncl
2 parents 72504c1 + 207da9f commit 4107b87

27 files changed

Lines changed: 854 additions & 1 deletion

File tree

.github/workflows/git-auto-issue-branch-creation.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
jobs:
77
create-issue-branch:
88
runs-on: ubuntu-latest
9+
permissions:
10+
pull-requests: write
11+
contents: write
12+
issues: write
913
steps:
1014
- name: Checkout code
1115
uses: actions/checkout@v4
@@ -22,7 +26,7 @@ jobs:
2226
# Given an issue title: "Fix the 2'nd bug in UI where there's a # in the form"
2327
# Becomes:
2428
#
25-
# Note there is a space here, to keep both '-' and spaces ' '
29+
# Note there is a space here, to keep both '-' and spaces ' '
2630
echo ISSUE_BRANCH_NAME=`echo "${{ github.event.issue.title }}" | \
2731
# Remove non alpha/numeric chars
2832
tr -cd '[:alnum:]- ' | \
@@ -41,3 +45,12 @@ jobs:
4145
git checkout -b "${{ steps.issue.outputs.number }}-${{ env.ISSUE_BRANCH_NAME }}"
4246
git push -u origin HEAD
4347
48+
- name: Creating PR based on branch name ${{ github.ref_name }}
49+
run: |
50+
curl -L \
51+
-X POST \
52+
-H "Accept: application/vnd.github+json" \
53+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
54+
-H "X-GitHub-Api-Version: 2022-11-28" \
55+
https://api.github.com/repos/Subscribie/subscribie/pulls \
56+
-d '{"title": "#${{ steps.issue.outputs.number }} ${{ env.ISSUE_BRANCH_NAME }}","body":"Pull request related issue: #${{ steps.issue.outputs.number }}. Please pull these awesome changes in!","head":"${{ steps.issue.outputs.number }}-${{ env.ISSUE_BRANCH_NAME }}","base":"master"}'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ node_modules
77
test-results/
88
playwright-report/
99
playwright/.cache/
10+
key*
11+
deploy/serve/www/*
12+
!deploy/serve/www/bootfile
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Overview
2+
3+
> [!NOTE]
4+
> This repo & docs is very much in flux.
5+
> For project purpose see [Server Bootstrap Project Concise project summary & deliverables](https://docs.google.com/document/d/15YR0hAkHfq8g_2rFzpKjpKf1mytyygREyR7a1ZWfzhE/edit?usp=sharing)
6+
> For background reading also see [https://github.com/KarmaComputing/server-bootstrap](https://github.com/KarmaComputing/server-bootstrap)
7+
8+
![diagram](docs/diagram.drawio.png)
9+
10+
11+
## Table of contents
12+
13+
- [Alpine Mirroring](./deploy/alpine-mirror/README.md)
14+
15+
16+
17+
## Run for debugging
18+
19+
- In `internal/runner`
20+
21+
```sh
22+
URL=https://192.168.0.230 USERNAME=Administrator PASSWORD=A0F7HKUU VALIDCERT=false WIPEINTERVAL=300 go run .
23+
```
24+
25+
## Full deploy
26+
27+
1. Build
28+
- Building ipxe.iso image
29+
- Use new/existing iPXE config file in `deploy/build/ipxe/scripts`
30+
- Input its name as FILE variable in `deploy/scripts/build-ipxe-iso.sh`
31+
- Run `deploy/scripts/build-ipxe-iso.sh`
32+
- `ipxe.iso` is placed in `deploy/serve/www`
33+
- Building alpine-netboot image
34+
- Run `deploy/scripts/build-alpine.sh`
35+
- Files are placed in `deploy/serve/www/iso`
36+
- SSH keys
37+
- An SSH keypair is automatically generated upon building an `ipxe.iso` image with the above command
38+
- The **private** key is placed at `deploy/ssh/key`
39+
- The **public** key is placed at `deploy/serve/www/ssh/key.pub`
40+
- Up **re**building the `ipxe.iso`, the script will prompt to replace these keys or not
41+
42+
2. Run stack
43+
- Ensure the files are correctly placed from step 1
44+
- `podman compose up -d` in repository root
45+
46+
3. !! VM FOR TESTING !!
47+
- Ensure `qemu` is installed and runnable
48+
- Ensure web server is accessible at whatever address is defined in the iPXE boot script
49+
- `qemu-system-x86_64 -cdrom <ipxe.iso> -net nic -net user,hostfwd=tcp::2223-:22 -m 3072 -smp $(nproc)`
50+
- VM can be accessed over SSH at `localhost:2223`
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
controller:
3+
build: ./internal/runner
4+
# ports:
5+
# - 8081:8080
6+
volumes:
7+
- ./deploy/ssh/key:/app/key:z
8+
- ./deploy/ansible:/app/ansible:z
9+
environment:
10+
- LC_ALL=en_US.UTF-8
11+
- USERNAME=Administrator
12+
- PASSWORD=A0F7HKUU
13+
- URL=https://192.168.0.230
14+
- VALIDCERT=false
15+
- WIPEINTERVAL=300
16+
apache:
17+
build: ./deploy/serve
18+
volumes:
19+
- ./deploy/serve/www:/usr/local/apache2/htdocs:z
20+
ports:
21+
- 8080:80
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM docker.io/library/alpine:3.20
2+
3+
RUN apk add rsync
4+
5+
COPY ./synchroniser /app
6+
RUN cat /app/crontab >> /etc/crontabs/root
7+
8+
RUN chmod +x /app/mirror.sh
9+
10+
CMD ["crond", "-f"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# How to Use
2+
3+
- Adjust `synchroniser/crontab` for desired schedule of synchronising
4+
- Adjust `synchroniser/mirror.sh` for which repos to exclude, etc.
5+
- The container image must be re-built when `crontab` or `mirror.sh` are changed
6+
- Run by `<podman|docker> compose up`
7+
8+
# Notes
9+
10+
- [Alpine Wiki - How to setup a Mirror](https://wiki.alpinelinux.org/wiki/How_to_setup_a_Alpine_Linux_mirror)
11+
- You can trigger the syncs manually via
12+
- `<podman|docker> exec -it alpine-mirror-sync /app/mirror.sh`
13+
14+
# How I've Tested It
15+
16+
1. `git clone git@github.com:KarmaComputing/server-bootstrap-ncl.git`
17+
2. `cd server-bootstrap-ncl/deploy/alpine-mirror`
18+
3. `sudo docker compose up`
19+
4. `sudo docker run --rm -it --network host alpine:3.21 sh`
20+
- `echo -e "http://localhost/v3.21/main\nhttp://localhost/v3.21/community" > /etc/apk/repositories`
21+
- `apk update`
22+
- Feel free to install anything to test, with `apk add`
23+
- e.g. `apk add fastfetch` and `fastfetch`
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
sync:
3+
container_name: alpine-mirror-sync
4+
build: .
5+
volumes:
6+
- ./repo:/site:z
7+
server:
8+
container_name: alpine-mirror-server
9+
image: docker.io/library/httpd:alpine
10+
volumes:
11+
- ./repo:/usr/local/apache2/htdocs:z
12+
ports:
13+
- 8080:80
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# every 5 days
2+
* * */5 * * sh /app/mirror.sh
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
# make sure we never run 2 rsync at the same time
4+
lockfile="/tmp/alpine-mirror.lock"
5+
if [ -z "$flock" ] ; then
6+
exec env flock=1 flock -n $lockfile "$0" "$@"
7+
fi
8+
9+
src=rsync://rsync.alpinelinux.org/alpine/
10+
dest=/site
11+
12+
exclude="--exclude v2.* --exclude v3.0 --exclude v3.1 --exclude v3.2 --exclude v3.3 --exclude v3.4 --exclude v3.5 --exclude v3.6 --exclude v3.7 --exclude v3.8 --exclude v3.9 --exclude v3.10 --exclude v3.11 --exclude v3.12 --exclude v3.13 --exclude v3.14 --exclude v3.15 --exclude v3.16 --exclude v3.17"
13+
14+
echo "--- Starting Sync ---"
15+
16+
mkdir -p "$dest"
17+
/usr/bin/rsync \
18+
--archive \
19+
--update \
20+
--hard-links \
21+
--delete \
22+
--delete-after \
23+
--delay-updates \
24+
--timeout=600 \
25+
$exclude \
26+
"$src" "$dest"
27+
28+
echo "--- Finished Sync ---"

0 commit comments

Comments
 (0)