diff --git a/.github/actions/compose/action.yml b/.github/actions/compose/action.yml index fc83b7dbc..fcd20a0fa 100644 --- a/.github/actions/compose/action.yml +++ b/.github/actions/compose/action.yml @@ -14,7 +14,3 @@ runs: sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin shell: bash - - run: pip install --upgrade pip - shell: bash - - run: pip install -e . - shell: bash diff --git a/.github/actions/k8s/action.yml b/.github/actions/k8s/action.yml index 300734863..e54a45346 100644 --- a/.github/actions/k8s/action.yml +++ b/.github/actions/k8s/action.yml @@ -17,13 +17,10 @@ runs: docker image ls -a echo Installing warnet python package for cli - pip install --upgrade pip - pip install -e . + uv pip install --system --break-system-packages --no-cache -r requirements.txt + uv pip install --system --break-system-packages --no-cache -e . - echo patching k8s configs to use local image - echo Patching warnet-rpc-statefulset-dev to use local registry - sed -i "s|imagePullPolicy: Always|imagePullPolicy: Never|g" src/templates/rpc/warnet-rpc-statefulset-dev.yaml - sed -i "s|bitcoindevproject/warnet-rpc:dev|local/warnet-rpc:ci|g" src/templates/rpc/warnet-rpc-statefulset-dev.yaml + echo "Using warnet-rpc-statefulset-dev.yaml:" cat src/templates/rpc/warnet-rpc-statefulset-dev.yaml echo Setting up k8s diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73d848e5e..7d029023e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: with: file: src/templates/rpc/Dockerfile_rpc context: . - tags: local/warnet-rpc:ci + tags: warnet/dev cache-from: type=gha cache-to: type=gha,mode=max outputs: type=docker,dest=/tmp/warnet.tar @@ -46,6 +46,7 @@ jobs: test: [scenarios_test.py, rpc_test.py, graph_test.py, ln_test.py, get_service_ip_test.py] steps: - uses: actions/checkout@v4 + - uses: hynek/setup-cached-uv@v1 - if: matrix.backend == 'compose' uses: ./.github/actions/compose - if: matrix.backend == 'k8s' @@ -54,11 +55,20 @@ jobs: run: | kubectl port-forward svc/rpc 9276:9276 & - name: Run tests - run: ./test/${{matrix.test}} ${{matrix.backend}} + run: | + uv venv + source .venv/bin/activate + uv pip install . + test/${{matrix.test}} ${{matrix.backend}} build-test: needs: [build-image] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: hynek/setup-cached-uv@v1 - uses: ./.github/actions/compose - - run: ./test/build_branch_test.py compose + - run: | + uv venv + source .venv/bin/activate + uv pip install . + test/build_branch_test.py compose diff --git a/justfile b/justfile index 4d557ac43..4e1ea9638 100644 --- a/justfile +++ b/justfile @@ -21,6 +21,10 @@ start: minikube start --mount --mount-string="$PWD:/mnt/src" + # Build image in local registry and load into minikube + docker build -t warnet/dev -f src/templates/rpc/Dockerfile_rpc_dev . --load + minikube image load warnet/dev + # Setup k8s kubectl apply -f src/templates/rpc/namespace.yaml kubectl apply -f src/templates/rpc/rbac-config.yaml @@ -87,4 +91,4 @@ installlogging: ./src/templates/k8s/install_logging.sh connectlogging: - ./src/templates/k8s/connect_logging.sh \ No newline at end of file + ./src/templates/k8s/connect_logging.sh diff --git a/src/templates/rpc/Dockerfile_rpc b/src/templates/rpc/Dockerfile_rpc index 82da4a185..1fa750519 100644 --- a/src/templates/rpc/Dockerfile_rpc +++ b/src/templates/rpc/Dockerfile_rpc @@ -1,17 +1,25 @@ # Use an official Python runtime as the base image -FROM python:3.11-slim +FROM python:3.12-slim # Install procps, which includes pgrep RUN apt-get update && \ apt-get install -y procps openssh-client && \ rm -rf /var/lib/apt/lists/* +# Install `uv` packge installer (https://github.com/astral-sh/uv) +RUN pip install uv + # Set the working directory in the container WORKDIR /root/warnet +# Get better caching by installing before copying code +COPY requirements.txt . +RUN uv pip install --system -r requirements.txt + # Copy the source directory contents into the container COPY . /root/warnet -RUN pip install . +# Install Warnet scripts +RUN uv pip install --system . # Make port 9276 available to the world outside this container # Change the port if your server is running on a different port diff --git a/src/templates/rpc/Dockerfile_rpc_dev b/src/templates/rpc/Dockerfile_rpc_dev index f200a0727..e5e5dcc1a 100644 --- a/src/templates/rpc/Dockerfile_rpc_dev +++ b/src/templates/rpc/Dockerfile_rpc_dev @@ -1,11 +1,14 @@ # Use an official Python runtime as the base image -FROM python:3.11-slim +FROM python:3.12-slim # Install procps, which includes pgrep RUN apt-get update && \ apt-get install -y procps openssh-client && \ rm -rf /var/lib/apt/lists/* +# Install `uv` packge installer (https://github.com/astral-sh/uv) +RUN pip install uv + # Set the working directory in the container WORKDIR /root/warnet diff --git a/src/templates/rpc/entrypoint.sh b/src/templates/rpc/entrypoint.sh index e2a63bf58..3ec29d745 100644 --- a/src/templates/rpc/entrypoint.sh +++ b/src/templates/rpc/entrypoint.sh @@ -31,7 +31,7 @@ done if check_setup_toml; then echo "Installing package from ${SOURCE_DIR}..." cd ${SOURCE_DIR} - pip install -e . + uv pip install --system -e . fi # Execute the CMD from the Dockerfile diff --git a/src/templates/rpc/warnet-rpc-statefulset-dev.yaml b/src/templates/rpc/warnet-rpc-statefulset-dev.yaml index dfc54508b..9825705e2 100644 --- a/src/templates/rpc/warnet-rpc-statefulset-dev.yaml +++ b/src/templates/rpc/warnet-rpc-statefulset-dev.yaml @@ -16,8 +16,8 @@ spec: spec: containers: - name: warnet-rpc - imagePullPolicy: Always - image: bitcoindevproject/warnet-rpc:dev + imagePullPolicy: Never + image: warnet/dev ports: - containerPort: 9276 volumeMounts: