From bffa31c0b77afcb257060ce10b46ca3bf8698c38 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 28 Nov 2023 08:18:48 +0100 Subject: [PATCH 1/8] fix(worker): default to disk 0 if /host/root not found In order to avoid displaying 0 disk space on some systems, we default to the first disk found --- packages/worker/src/services/system/system.executors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/worker/src/services/system/system.executors.ts b/packages/worker/src/services/system/system.executors.ts index 38d43414..5069d2d7 100644 --- a/packages/worker/src/services/system/system.executors.ts +++ b/packages/worker/src/services/system/system.executors.ts @@ -37,7 +37,7 @@ export class SystemExecutors { } const disks = await si.fsSize(); - const disk0 = disks.find((disk) => disk.mount.startsWith('/host/root')); + const disk0 = disks.find((disk) => disk.mount.startsWith('/host/root')) || disks[0]; return { cpu: { load: currentLoad }, From 37c551da1f6e5bd7bc2802cd62314a71cc08b48d Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 28 Nov 2023 09:05:53 +0100 Subject: [PATCH 2/8] ci(releases): refactor to use non-outdated actions --- .github/workflows/alpha-release.yml | 37 +++++----- .github/workflows/beta-release.yml | 48 +++++-------- .github/workflows/e2e.yml | 7 +- .github/workflows/release.yml | 105 ++++++++++++++-------------- 4 files changed, 94 insertions(+), 103 deletions(-) diff --git a/.github/workflows/alpha-release.yml b/.github/workflows/alpha-release.yml index 9e32f04c..61abfbc7 100644 --- a/.github/workflows/alpha-release.yml +++ b/.github/workflows/alpha-release.yml @@ -11,19 +11,20 @@ jobs: create-tag: runs-on: ubuntu-latest outputs: - tagname: ${{ steps.create_tag.outputs.tagname }} - + tagname: ${{ steps.get_tag.outputs.tagname }} steps: - name: Checkout code uses: actions/checkout@v4 - - name: Create Tag - id: create_tag - uses: Klemensas/action-autotag@stable + - name: Get tag from package.json + id: get_tag + run: | + VERSION=$(npm run version --silent) + echo "tagname=v${VERSION}-alpha.${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + + - uses: rickstaa/action-create-tag@v1 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tag_prefix: 'v' - tag_suffix: '-alpha.${{ github.event.inputs.tag }}' + tag: ${{ steps.get_tag.outputs.tagname }} build-worker: runs-on: ubuntu-latest @@ -144,25 +145,21 @@ jobs: name: cli path: cli + - name: Rename CLI + run: | + mv cli/bin/cli-x64 ./runtipi-cli-linux-x64 + - name: Create alpha release id: create_release - uses: actions/create-release@v1 + uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: body: | **${{ needs.create-tag.outputs.tagname }}** tag_name: ${{ needs.create-tag.outputs.tagname }} - release_name: ${{ needs.create-tag.outputs.tagname }} + name: ${{ needs.create-tag.outputs.tagname }} draft: false prerelease: true - - - name: Upload X64 Linux CLI binary to release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: cli/bin/cli-x64 - asset_name: runtipi-cli-linux-x64 - asset_content_type: application/octet-stream + files: | + runtipi-cli-linux-x64 diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index 42a880d6..4b8d8cbe 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -11,18 +11,20 @@ jobs: create-tag: runs-on: ubuntu-latest outputs: - tagname: ${{ steps.create_tag.outputs.tagname }} + tagname: ${{ steps.get_tag.outputs.tagname }} steps: - name: Checkout code uses: actions/checkout@v4 - - name: Create Tag - id: create_tag - uses: Klemensas/action-autotag@stable + - name: Get tag from package.json + id: get_tag + run: | + VERSION=$(npm run version --silent) + echo "tagname=v${VERSION}-beta.${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + + - uses: rickstaa/action-create-tag@v1 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tag_prefix: 'v' - tag_suffix: '-beta.${{ github.event.inputs.tag }}' + tag: ${{ steps.get_tag.outputs.tagname }} build-worker: runs-on: ubuntu-latest @@ -144,38 +146,26 @@ jobs: name: cli path: cli + - name: Rename CLI + run: | + mv cli/bin/cli-x64 ./runtipi-cli-linux-x64 + mv cli/bin/cli-arm64 ./runtipi-cli-linux-arm64 + - name: Create beta release id: create_release - uses: actions/create-release@v1 + uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: body: | **${{ needs.create-tag.outputs.tagname }}** tag_name: ${{ needs.create-tag.outputs.tagname }} - release_name: ${{ needs.create-tag.outputs.tagname }} + name: ${{ needs.create-tag.outputs.tagname }} draft: false prerelease: true - - - name: Upload X64 Linux CLI binary to release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: cli/bin/cli-x64 - asset_name: runtipi-cli-linux-x64 - asset_content_type: application/octet-stream - - - name: Upload ARM64 Linux CLI binary to release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: cli/bin/cli-arm64 - asset_name: runtipi-cli-linux-arm64 - asset_content_type: application/octet-stream + files: | + runtipi-cli-linux-x64 + runtipi-cli-linux-arm64 e2e-tests: needs: [create-tag, publish-release] diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index dc9d23d5..32985ce2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -72,9 +72,6 @@ jobs: run: | while ! ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{ steps.get-droplet-ip.outputs.droplet_ip }} "echo 'SSH is ready'"; do sleep 5; done - - name: Wait 1 minute for Droplet to be ready - run: sleep 60 - - name: Create docker group on Droplet uses: fifsky/ssh-action@master with: @@ -85,6 +82,10 @@ jobs: user: root key: ${{ secrets.SSH_KEY }} + - name: Wait for dpkg lock to be released + run: | + while ! ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{ steps.get-droplet-ip.outputs.droplet_ip }} "dpkg --configure -a"; do sleep 5; done + - name: Deploy app to Droplet uses: fifsky/ssh-action@master with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe6723b6..1a94fdef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,28 +3,28 @@ on: workflow_dispatch: jobs: - get-tag: + create-tag: runs-on: ubuntu-latest + needs: [build-images, build-cli] outputs: - tag: ${{ steps.get_tag.outputs.tag }} + tagname: ${{ steps.get_tag.outputs.tagname }} steps: - name: Checkout code uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Get tag from VERSION file + - name: Get tag from package.json id: get_tag run: | VERSION=$(npm run version --silent) - echo "tag=v${VERSION}" >> $GITHUB_OUTPUT + echo "tagname=v${VERSION}" >> $GITHUB_OUTPUT + + - uses: rickstaa/action-create-tag@v1 + with: + tag: ${{ steps.get_tag.outputs.tagname }} build-images: if: github.repository == 'runtipi/runtipi' - needs: get-tag + needs: create-tag runs-on: ubuntu-latest steps: - name: Checkout @@ -49,14 +49,45 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true - tags: ghcr.io/${{ github.repository_owner }}/runtipi:${{ needs.get-tag.outputs.tag }},ghcr.io/${{ github.repository_owner }}/runtipi:latest + tags: ghcr.io/${{ github.repository_owner }}/runtipi:${{ needs.create-tag.outputs.tagname }},ghcr.io/${{ github.repository_owner }}/runtipi:latest cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/runtipi:buildcache cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/runtipi:buildcache,mode=max + build-worker: + runs-on: ubuntu-latest + needs: create-tag + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push images + uses: docker/build-push-action@v5 + with: + context: . + file: ./packages/worker/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/${{ github.repository_owner }}/worker:${{ needs.create-tag.outputs.tagname }},ghcr.io/${{ github.repository_owner }}/worker:latest + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/worker:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/worker:buildcache,mode=max + build-cli: runs-on: ubuntu-latest timeout-minutes: 10 - needs: get-tag + needs: create-tag steps: - name: Checkout code uses: actions/checkout@v4 @@ -90,7 +121,7 @@ jobs: run: pnpm install - name: Set version - run: pnpm -r --filter cli set-version ${{ needs.get-tag.outputs.tag }} + run: pnpm -r --filter cli set-version ${{ needs.create-tag.outputs.tagname }} - name: Build CLI run: pnpm -r --filter cli package @@ -101,22 +132,6 @@ jobs: name: cli path: packages/cli/dist - create-tag: - runs-on: ubuntu-latest - needs: [build-images, build-cli] - outputs: - tagname: ${{ steps.create_tag.outputs.tagname }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Create Tag - id: create_tag - uses: Klemensas/action-autotag@stable - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tag_prefix: 'v' - publish-release: runs-on: ubuntu-latest needs: [create-tag] @@ -129,38 +144,26 @@ jobs: name: cli path: cli + - name: Rename CLI + run: | + mv cli/bin/cli-x64 ./runtipi-cli-linux-x64 + mv cli/bin/cli-arm64 ./runtipi-cli-linux-arm64 + - name: Create release id: create_release - uses: actions/create-release@v1 + uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: body: | **${{ needs.create-tag.outputs.tagname }}** tag_name: ${{ needs.create-tag.outputs.tagname }} - release_name: ${{ needs.create-tag.outputs.tagname }} + name: ${{ needs.create-tag.outputs.tagname }} draft: false prerelease: true - - - name: Upload X64 Linux CLI binary to release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: cli/bin/cli-x64 - asset_name: runtipi-cli-linux-x64 - asset_content_type: application/octet-stream - - - name: Upload ARM64 Linux CLI binary to release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: cli/bin/cli-arm64 - asset_name: runtipi-cli-linux-arm64 - asset_content_type: application/octet-stream + files: | + runtipi-cli-linux-x64 + runtipi-cli-linux-arm64 e2e-tests: needs: [create-tag, publish-release] From 4d69fc4cffefe993a12f3aed4c60c2db5c40623d Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 28 Nov 2023 14:22:01 +0100 Subject: [PATCH 3/8] ci(e2e): update upgrade before running install script --- .github/workflows/e2e.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 32985ce2..fea580bb 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -82,9 +82,8 @@ jobs: user: root key: ${{ secrets.SSH_KEY }} - - name: Wait for dpkg lock to be released - run: | - while ! ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${{ steps.get-droplet-ip.outputs.droplet_ip }} "dpkg --configure -a"; do sleep 5; done + - name: Wait 90 seconds for Docker to be ready on Droplet + run: sleep 90 - name: Deploy app to Droplet uses: fifsky/ssh-action@master From 42349c5a27bb0b8f9c3c4503e09ec20122c3342d Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 28 Nov 2023 22:02:52 +0100 Subject: [PATCH 4/8] fix(worker): no need to mount host --- docker-compose.dev.yml | 2 -- docker-compose.prod.yml | 1 - packages/cli/assets/docker-compose.yml | 2 -- packages/worker/src/services/system/system.executors.ts | 3 +-- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index ff732da9..5f85b16d 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -60,7 +60,6 @@ services: context: . dockerfile: ./packages/worker/Dockerfile.dev container_name: tipi-worker - user: root healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:3000/healthcheck'] interval: 5s @@ -80,7 +79,6 @@ services: # Dev mode - ${PWD}/packages/worker/src:/app/packages/worker/src # Production mode - - /:/host/root:ro - /proc:/host/proc:ro - /var/run/docker.sock:/var/run/docker.sock - ${PWD}/.env:/app/.env diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 0e0a5db5..309eaf22 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -76,7 +76,6 @@ services: environment: NODE_ENV: production volumes: - - /:/host/root:ro - /proc:/host/proc - /var/run/docker.sock:/var/run/docker.sock - ${PWD}/.env:/app/.env diff --git a/packages/cli/assets/docker-compose.yml b/packages/cli/assets/docker-compose.yml index e5d6d40d..4aa6fe06 100644 --- a/packages/cli/assets/docker-compose.yml +++ b/packages/cli/assets/docker-compose.yml @@ -60,7 +60,6 @@ services: container_name: tipi-worker image: ghcr.io/runtipi/worker:${TIPI_VERSION} restart: unless-stopped - user: root healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:3000/healthcheck'] interval: 5s @@ -78,7 +77,6 @@ services: NODE_ENV: production volumes: # Core - - /:/host/root:ro - /proc:/host/proc - /var/run/docker.sock:/var/run/docker.sock # App diff --git a/packages/worker/src/services/system/system.executors.ts b/packages/worker/src/services/system/system.executors.ts index 5069d2d7..80f63421 100644 --- a/packages/worker/src/services/system/system.executors.ts +++ b/packages/worker/src/services/system/system.executors.ts @@ -36,8 +36,7 @@ export class SystemExecutors { this.logger.error(`Unable to read /host/proc/meminfo: ${e}`); } - const disks = await si.fsSize(); - const disk0 = disks.find((disk) => disk.mount.startsWith('/host/root')) || disks[0]; + const [disk0] = await si.fsSize(); return { cpu: { load: currentLoad }, From ca3dc64fd434cb4a111fc1b549f7b803b2b6e5e9 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 28 Nov 2023 22:30:30 +0100 Subject: [PATCH 5/8] ci(release): fix dependency on first job --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a94fdef..8f5513e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,6 @@ on: jobs: create-tag: runs-on: ubuntu-latest - needs: [build-images, build-cli] outputs: tagname: ${{ steps.get_tag.outputs.tagname }} steps: From 92d5a7b6a363011aadc119e45af220e2fa0c037f Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 28 Nov 2023 22:31:44 +0100 Subject: [PATCH 6/8] ci(release): make publish dependant on all builds --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f5513e0..cf39f0d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -133,7 +133,7 @@ jobs: publish-release: runs-on: ubuntu-latest - needs: [create-tag] + needs: [create-tag, build-images, build-worker, build-cli] outputs: id: ${{ steps.create_release.outputs.id }} steps: From ba3d860176b03840286d800e8a36120c23123813 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Wed, 29 Nov 2023 18:15:50 +0100 Subject: [PATCH 7/8] hotfix(install.sh): ask to re-run install script after docker is installed --- scripts/install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index eb8d887e..f9c264c5 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -121,16 +121,12 @@ if ! command -v docker >/dev/null; then install_docker "${OS}" docker_result=$? - if [[ docker_result -eq 0 ]]; then - echo "Docker installed" - else + if [[ docker_result -ne 0 ]]; then echo "Your system ${OS} is not supported trying with sub_os ${SUB_OS}" install_docker "${SUB_OS}" docker_sub_result=$? - if [[ docker_sub_result -eq 0 ]]; then - echo "Docker installed" - else + if [[ docker_sub_result -ne 0 ]]; then echo "Your system ${SUB_OS} is not supported please install docker manually" exit 1 fi @@ -138,11 +134,15 @@ if ! command -v docker >/dev/null; then # Make sure user is in docker group if ! groups | grep -q '\bdocker\b'; then + echo "Adding user to docker group" sudo usermod -aG docker "$USER" + echo "✓ Docker installed. Please re-run the installation script to continue with the installation. (curl -L https://setup.runtipi.io | bash)" fi # Reload user groups newgrp docker + + exit 0 fi function check_dependency_and_install() { From 03e2604ca07516a496c255599725a1253969f373 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Fri, 1 Dec 2023 08:44:53 +0100 Subject: [PATCH 8/8] hotfix(docker): make postgres restart policy "unless-stopped" instead of "on-failure" --- package.json | 2 +- packages/cli/assets/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7306622..967b8346 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "runtipi", - "version": "2.2.0", + "version": "2.2.1", "description": "A homeserver for everyone", "scripts": { "knip": "knip", diff --git a/packages/cli/assets/docker-compose.yml b/packages/cli/assets/docker-compose.yml index 4aa6fe06..58b3d5d0 100644 --- a/packages/cli/assets/docker-compose.yml +++ b/packages/cli/assets/docker-compose.yml @@ -21,7 +21,7 @@ services: tipi-db: container_name: tipi-db image: postgres:14 - restart: on-failure + restart: unless-stopped stop_grace_period: 1m ports: - ${POSTGRES_PORT:-5432}:5432