diff --git a/Makefile b/Makefile index 0899c73ed..76ae1d19d 100644 --- a/Makefile +++ b/Makefile @@ -197,6 +197,7 @@ gltestserver-image: docker/gl-testserver/Dockerfile --build-arg DOCKER_USER=$(shell whoami) \ --build-arg UID=$(shell id -u) \ --build-arg GID=$(shell id -g) \ + --build-arg REPO_PATH=$(shell git rev-parse --show-toplevel) \ -t gltestserver \ -f docker/gl-testserver/Dockerfile \ . @@ -208,5 +209,5 @@ gltestserver: gltestserver-image -e DOCKER_USER=$(shell whoami) \ --net=host \ -ti \ - -v $(shell pwd)/.testserver:/tmp/gltestserver \ + -v $(shell pwd)/:$(shell pwd) \ gltestserver diff --git a/docker/gl-testserver/Dockerfile b/docker/gl-testserver/Dockerfile index a19c557b5..3f736a7fb 100644 --- a/docker/gl-testserver/Dockerfile +++ b/docker/gl-testserver/Dockerfile @@ -1,17 +1,22 @@ FROM ubuntu:22.04 AS python-builder +ARG BITCOIN_VERSION=24.0 +ARG GID=0 +ARG UID=0 +ARG DOCKER_USER=dev +ARG REPO_PATH=/repo + ENV RUST_VERSION=1.74 ENV PATH=$CARGO_HOME/bin:$PATH ENV PROTOC_VERSION=3.19.3 ENV CFSSL_VERSION=1.6.5 ENV GL_TESTING_IGNORE_HASH=true -ARG BITCOIN_VERSION=24.0 -ARG GID=0 -ARG UID=0 -ARG DOCKER_USER=dev ENV PATH=$PATH:/home/$DOCKER_USER/.local/bin/:/opt/bitcoin/bin:/home/$DOCKER_USER/.cargo/bin -#ENV VIRTUAL_ENV=/tmp/venv -ENV CARGO_TARGET_DIR=/tmp/cargo +ENV REPO=$REPO_PATH + +# Force this target dir, so the scripts can find all the binaries. +#ENV CARGO_TARGET_DIR=${REPO}/target +ENV CARGO_TARGET_DIR=/tmp/target/ RUN apt update && apt install -qqy \ curl \ @@ -50,9 +55,15 @@ RUN cd /tmp/ && \ mv /tmp/bitcoin-$BITCOIN_VERSION/ /opt/bitcoin && \ rm -rf bitcoin.tar.gz /tmp/bitcoin-$BITCOIN_VERSION -ADD ../ /repo/libs -RUN chown $DOCKER_USER:users -R /repo +RUN mkdir -p ${REPO_PATH} && \ + chown $DOCKER_USER:users ${REPO_PATH} +ADD ../../libs/ ${REPO_PATH}/libs +ADD ../../pyproject.toml ${REPO_PATH}/ + +ADD ../../ ${REPO_PATH}/ +RUN chown $DOCKER_USER:users -R ${REPO_PATH} +RUN chown $DOCKER_USER:users -R /home/$DOCKER_USER USER $DOCKER_USER RUN curl \ @@ -62,10 +73,13 @@ RUN curl \ -s -- -y --default-toolchain ${RUST_VERSION} RUN rustup default stable +WORKDIR ${REPO_PATH}/libs/gl-testserver/ + +RUN cargo build --bin gl-plugin +RUN cargo build --bin gl-signerproxy + RUN curl -LsSf https://astral.sh/uv/install.sh | sh -WORKDIR /repo/libs/gl-testserver/ -RUN echo $PATH RUN uv sync --locked -v RUN uv run clnvm get-all -CMD uv run gltestserver run --metadata /tmp/gltestserver +CMD uv run gltestserver run --metadata ${REPO}/ --directory ${REPO}/.gltestserver diff --git a/libs/gl-testserver/gltestserver/__main__.py b/libs/gl-testserver/gltestserver/__main__.py index d7b07efde..c598344d5 100644 --- a/libs/gl-testserver/gltestserver/__main__.py +++ b/libs/gl-testserver/gltestserver/__main__.py @@ -151,15 +151,16 @@ def run(directory, metadata=None): envfile = metadata / ".env" logger.info(f"Writing .env file to {envfile}") + import textwrap with envfile.open(mode="w") as f: - f.write(f"""\ + f.write(textwrap.dedent(f""" export GL_SCHEDULER_GRPC_URI={meta['scheduler_grpc_uri']} export GL_CERT_PATH={meta['cert_path']} export GL_CA_CRT={meta['ca_crt_path']} export GL_NOBODY_CRT={meta['nobody_crt_path']} export GL_NOBODY_KEY={meta['nobody_key_path']} export RUST_LOG=glclient=debub,info - """) + """)) pprint(meta) logger.info(