Skip to content

Commit 3a90bb6

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/web/npm_and_yarn-73ea615029
2 parents b27d770 + 4ca1c34 commit 3a90bb6

19 files changed

Lines changed: 472 additions & 50 deletions

File tree

‎.dockerignore‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**/dist/
2+
**/target/
3+
**/debug/
4+
**/*.rs.bk
5+
**/*.pdb
6+
**/.idea/
7+
**/node_modules/
8+
**/styled-system/
9+
**/styled-system-studio/
10+
**/src/components/ui/
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+"
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
packages: write
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-24.04-arm
16+
name: Test
17+
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
22+
- name: Run Tests
23+
uses: ./.github/workflows/composite/test
24+
25+
check-version:
26+
runs-on: ubuntu-24.04-arm
27+
name: Check Version
28+
29+
steps:
30+
- name: Checkout Repository
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+
33+
- name: Check Greater Than latest
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
run: |
37+
latest_version=$(gh release view --json tagName -q .tagName || echo "0.0.0")
38+
newest_version=$(printf "%s\n%s" "$latest_version" "${{ github.ref_name }}" | sort -V | tail -n1)
39+
40+
if [[ "${{ github.ref_name }}" != "$newest_version" ]]; then
41+
echo "Tag is not newer than the latest release" >> /dev/stderr
42+
exit 1
43+
fi
44+
45+
- name: Check Web Package Version
46+
run: |
47+
web_version=$(cat web/package.json | jq -r ".version")
48+
49+
if [[ "${{ github.ref_name }}" != "$web_version" ]]; then
50+
echo "Web package version does not match tag" >> /dev/stderr
51+
exit 1
52+
fi
53+
54+
- name: Check Backend Package Version
55+
run: |
56+
backend_version=$(awk -F' *= *' '
57+
$0 ~ /^\[package\]/ { in_package=1; next }
58+
in_package && $1 ~ /^version$/ {
59+
gsub(/["'\'']/, "", $2); print $2; exit
60+
}
61+
' backend/Cargo.toml)
62+
63+
if [[ "${{ github.ref_name }}" != "$backend_version" ]]; then
64+
echo "Backend package version does not match tag" >> /dev/stderr
65+
exit 1
66+
fi
67+
68+
build-and-push-amd64:
69+
runs-on: ubuntu-latest
70+
name: Build and Push for amd64
71+
needs:
72+
- test
73+
- check-version
74+
75+
steps:
76+
- name: Checkout Repository
77+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
78+
79+
- name: Build and Push
80+
uses: ./.github/workflows/composite/build-and-push
81+
with:
82+
platform: amd64
83+
84+
build-and-push-arm64:
85+
runs-on: ubuntu-24.04-arm
86+
name: Build and Push for arm64
87+
needs:
88+
- test
89+
- check-version
90+
91+
steps:
92+
- name: Checkout Repository
93+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
94+
95+
- name: Build and Push
96+
uses: ./.github/workflows/composite/build-and-push
97+
with:
98+
platform: arm64
99+
100+
publish:
101+
runs-on: ubuntu-24.04-arm
102+
name: Publish
103+
needs:
104+
- build-and-push-amd64
105+
- build-and-push-arm64
106+
107+
steps:
108+
- name: Checkout Repository
109+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
110+
with:
111+
fetch-depth: 0
112+
113+
- name: Generate Changelog
114+
env:
115+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
run: |
117+
latest_version=$(gh release view --json tagName -q .tagName || echo "")
118+
if [[ "$latest_version" == "" ]]; then
119+
git log --pretty=format:"%s" > /tmp/changelog.txt
120+
else
121+
latest_version_commit=$(git rev-parse "$latest_version")
122+
git log $latest_version_commit..${{ github.sha }} --pretty=format:"%s" > /tmp/changelog.txt
123+
fi
124+
125+
- name: Publish
126+
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # 2.3.3
127+
with:
128+
body_path: /tmp/changelog.txt
129+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build and Push
2+
3+
inputs:
4+
platform:
5+
description: the platform to build the Docker image for
6+
type: enum
7+
required: true
8+
options:
9+
- amd64
10+
- arm64
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@1583c0f09d26c58c59d25b0eef29792b7ce99d9a # v3.11.1
17+
18+
- name: Login to GitHub Container Registry
19+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ github.token }}
24+
25+
- name: Build and push
26+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
27+
with:
28+
push: true
29+
platforms: linux/${{ inputs.platform }}
30+
tags: ghcr.io/eraz1997/kiwi:${{ github.ref_name }}-${{ inputs.platform }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Install Node
7+
shell: bash -euo pipefail {0}
8+
run: |
9+
curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir ~/.fnm --skip-shell
10+
echo "$HOME/.fnm" >> $GITHUB_PATH
11+
export PATH="$PATH:$HOME/.fnm"
12+
eval "$(fnm env)"
13+
fnm install --corepack-enabled 22
14+
15+
- name: Install Cargo
16+
shell: bash -euo pipefail {0}
17+
run: |
18+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
19+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
20+
21+
- name: Lint Web
22+
shell: bash -euo pipefail {0}
23+
run: |
24+
cd web
25+
eval "$(fnm env)"
26+
fnm use 22
27+
pnpm install
28+
pnpm prettier . --check
29+
pnpm eslint .
30+
pnpm tsc --project tsconfig.lint.json
31+
cd ..
32+
33+
- name: Lint Backend
34+
shell: bash -euo pipefail {0}
35+
run: |
36+
cd backend
37+
cargo fmt --check
38+
cargo clippy -- --deny warnings
39+
cd ..

‎.github/workflows/test.yaml‎

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,13 @@ on:
44
push:
55

66
jobs:
7-
build:
8-
runs-on: ubuntu-latest
7+
test:
8+
runs-on: ubuntu-24.04-arm
99
name: Test
1010

1111
steps:
1212
- name: Checkout Repository
1313
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
14-
15-
- name: Install Node
16-
run: |
17-
curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir ~/.fnm --skip-shell
18-
echo "$HOME/.fnm" >> $GITHUB_PATH
19-
export PATH="$PATH:$HOME/.fnm"
20-
eval "$(fnm env)"
21-
fnm install --corepack-enabled 22
22-
23-
- name: Install Cargo
24-
run: |
25-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
26-
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
27-
28-
- name: Lint Web
29-
run: |
30-
cd web
31-
eval "$(fnm env)"
32-
fnm use 22
33-
pnpm install
34-
pnpm prettier . --check
35-
pnpm eslint .
36-
pnpm tsc --project tsconfig.lint.json
37-
cd ..
38-
39-
- name: Lint Backend
40-
run: |
41-
cd backend
42-
cargo fmt --check
43-
cargo clippy -- --deny warnings
44-
cd ..
14+
15+
- name: Test
16+
uses: ./.github/workflows/composite/test

‎Dockerfile‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Web Builder Stage (node:24.7.0-trixie)
2+
3+
from node@sha256:a22d64d626515462248d80659745c9de26454a527b0441ec796b3f8f6106bfc2 as web-builder
4+
5+
copy web /src
6+
workdir /src
7+
run npm install -g pnpm
8+
run pnpm install --frozen-lockfile
9+
run pnpm vite build --outDir /dist
10+
11+
# Backend Builder Stage (rust:1.89.0-trixie)
12+
13+
from rust@sha256:9e1b362e100b2c510355314491708bdc59d79b8ed93e94580aba9e4a370badab as backend-builder
14+
15+
copy backend /src
16+
workdir /src
17+
run cargo install --path . --root /dist
18+
19+
# Runtime (debian:trixie-20250908-slim)
20+
21+
from debian@sha256:c2880112cc5c61e1200c26f106e4123627b49726375eb5846313da9cca117337 as runtime
22+
23+
## Install System Dependencies
24+
25+
run apt update
26+
run apt install -y curl
27+
28+
## Install Artifacts
29+
30+
copy --from=web-builder /dist /static
31+
copy --from=backend-builder /dist /app
32+
33+
## Set Up Health Checks
34+
35+
healthcheck --interval=10s --timeout=1m --retries=5 --start-interval=20s cmd curl -k https://status.kiwi-local.com:5000
36+
37+
## Runtime Command
38+
39+
cmd /app/bin/kiwi-api \
40+
--config-folder-path /config \
41+
--dev-frontend-server-port 0 \
42+
--host 0.0.0.0 \
43+
--lets-encrypt-environment production \
44+
--log-level info \
45+
--port 443 \
46+
--static-files-path /static

‎README.md‎

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,68 @@
11
# Kiwi 🥝
22

3-
Self-hosted cloud platform for DIY projects.
3+
Self-hosted cloud platform for DIY projects, based on Docker containers.
4+
5+
## Installation (Linux Only) 🍓
6+
7+
1. Install Docker ([guide](https://docs.docker.com/engine/install/)).
8+
1. Follow the ["Linux post-installation steps for Docker Engine"](https://docs.docker.com/engine/install/linux-postinstall)
9+
1. Grant Docker permissions to publish on port 443:
10+
11+
```shell
12+
sudo setcap CAP_NET_BIND_SERVICE=+eip $(which docker)
13+
```
14+
15+
1. Create a file at `/lib/systemd/user/kiwi.service` with the following content, making sure to replace `<user>` with your user name and `<sha>` with a valid Kiwi Docker image SHA
16+
17+
```
18+
[Unit]
19+
Description=Kiwi
20+
After=docker.service
21+
Requires=docker.service
22+
23+
[Service]
24+
TimeoutStartSec=0
25+
Restart=always
26+
ExecStartPre=-/usr/bin/docker stop kiwi
27+
ExecStartPre=-/usr/bin/docker rm kiwi
28+
ExecStart=/usr/bin/docker run --rm --name kiwi \
29+
--volume /home/<user>/.kiwi:/config \
30+
--volume /var/run/docker.sock:/var/run/docker.sock \
31+
--network host \
32+
--add-host status.kiwi-local.com:127.0.0.1 \
33+
--stop-timeout 15 \
34+
ghrc.io/Eraz1997/kiwi@sha256:<sha>
35+
ExecStop=/usr/bin/docker exec kiwi stop
36+
37+
[Install]
38+
WantedBy=default.target
39+
```
40+
41+
1. Activate and run the service
42+
43+
```shell
44+
systemctl --user daemon-reload
45+
systemctl --user enable kiwi.service
46+
systemctl --user start kiwi.service
47+
```
48+
49+
1. Based on your operating system, make sure port 443 is reachable from the Internet at your public IP address.
50+
1. Configure a domain and a wildcard `A` record pointing to your public IP address. Kiwi won't work without a proper initial DNS setup. Do not worry about Dynamic DNS, it's part of the features Kiwi offers.
51+
52+
### Updates 🙃
53+
54+
1. Replace the Docker image `<sha>` with a newer value inside the `/lib/systemd/user/kiwi.service` file
55+
1. Reload and restart the service
56+
57+
```shell
58+
systemctl --user daemon-reload
59+
systemctl --user restart kiwi.service
60+
```
61+
62+
## Usage 🚀
63+
64+
Refer to the [user manual](./USAGE.md).
465

566
## Development 👨‍💻
667

7-
Please check the [development guidelines](./CONTRIBUTING.md).
68+
Refer to the [development guidelines](./CONTRIBUTING.md).

0 commit comments

Comments
 (0)