Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts: Add Dockerfile and make targets #551

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
.
Expand All @@ -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
36 changes: 25 additions & 11 deletions docker/gl-testserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -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
5 changes: 3 additions & 2 deletions libs/gl-testserver/gltestserver/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading