Skip to content

Commit

Permalink
test: Have the docker testserver emulate the host file structure
Browse files Browse the repository at this point in the history
We want to ensure that we can run both inside and outside the docker
container, thus we better make sure that the repo inside and outside
of the docker container use the same paths and permissions.
  • Loading branch information
cdecker committed Dec 19, 2024
1 parent f178d17 commit 22af6b6
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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-superproject-working-tree) \
-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
14 changes: 9 additions & 5 deletions docker/gl-testserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -9,9 +9,11 @@ ARG BITCOIN_VERSION=24.0
ARG GID=0
ARG UID=0
ARG DOCKER_USER=dev
ARG REPO_PATH=/repo
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

RUN apt update && apt install -qqy \
curl \
@@ -50,9 +52,11 @@ 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 ../../ ${REPO_PATH}/
RUN chown $DOCKER_USER:users -R ${REPO_PATH}
USER $DOCKER_USER

RUN curl \
@@ -64,8 +68,8 @@ RUN rustup default stable

RUN curl -LsSf https://astral.sh/uv/install.sh | sh

WORKDIR /repo/libs/gl-testserver/
RUN echo $PATH
WORKDIR ${REPO_PATH}/libs/gl-testserver/

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}/
5 changes: 3 additions & 2 deletions libs/gl-testserver/gltestserver/__main__.py
Original file line number Diff line number Diff line change
@@ -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(

0 comments on commit 22af6b6

Please sign in to comment.