From 681fcdab8c940525d768213fb1a9e53179a2a382 Mon Sep 17 00:00:00 2001 From: Michael Hohn Date: Thu, 29 Aug 2024 13:22:59 -0700 Subject: [PATCH] Add new containers to streamline setup --- Makefile | 24 +++++++++++++++++++++ client/containers/ghmrva/Dockerfile | 30 ++++++++++++++++++++++++++ client/containers/mrvadata/Dockerfile | 22 +++++++++++++++++++ client/containers/mrvadata/Makefile | 16 ++++++++++++++ client/containers/qldbtools/Dockerfile | 29 +++++++++++++++++++++++++ 5 files changed, 121 insertions(+) create mode 100644 client/containers/ghmrva/Dockerfile create mode 100644 client/containers/mrvadata/Dockerfile create mode 100644 client/containers/mrvadata/Makefile create mode 100644 client/containers/qldbtools/Dockerfile diff --git a/Makefile b/Makefile index 6d93279..4e3a53b 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,30 @@ html: README.html %.html: %.md pandoc --toc=true --standalone $< --out $@ +# Build the qldbtools container image +dbt: client-qldbtools-container +client-qldbtools-container: + cd client/containers/qldbtools && \ + docker build -t $@ . + +# Run a shell in the container with the qldbtools +dbt-run: + docker run --rm -it client-qldbtools-container /bin/bash + +dbt-run: + docker run --rm -it client-qldbtools-container /bin/bash + +dbt-check: + docker run --rm -it client-qldbtools-container mc-db-initial-info + +ghm: client-ghmrva-container +client-ghmrva-container: + cd client/containers/ghmrva && \ + docker build -t $@ . +ghm-run: + docker run --rm client-ghmrva-container --help + + server: cd cmd/server && GOOS=linux GOARCH=arm64 go build diff --git a/client/containers/ghmrva/Dockerfile b/client/containers/ghmrva/Dockerfile new file mode 100644 index 0000000..e2e5cbf --- /dev/null +++ b/client/containers/ghmrva/Dockerfile @@ -0,0 +1,30 @@ +# Use an official Golang image as the base image +FROM golang:1.22 AS builder + +# Set the working directory inside the container +WORKDIR /work-gh/mrva/gh-mrva + +# Clone the repository +RUN git clone https://github.com/hohn/gh-mrva.git . &&\ + git checkout hohn-0.1.24-demo + +# Download dependencies +RUN go mod download + +# Build the Go binary +RUN go build . + +# # Set the entrypoint +# CMD ["/bin/bash"] + +# Use a minimal base image for the final container +FROM debian:bookworm + +# Set the working directory inside the final image +WORKDIR /app + +# Copy the binary from the builder stage +COPY --from=builder /work-gh/mrva/gh-mrva/gh-mrva /usr/local/bin/gh-mrva + +# Set the entrypoint to the binary +ENTRYPOINT ["gh-mrva"] diff --git a/client/containers/mrvadata/Dockerfile b/client/containers/mrvadata/Dockerfile new file mode 100644 index 0000000..260fa50 --- /dev/null +++ b/client/containers/mrvadata/Dockerfile @@ -0,0 +1,22 @@ +# Use a minimal base image +FROM busybox + +# This data container holds data from existing runs. It cannot be built without +# ready data. + +# Before running docker build, make sure you have set up the directory mirrors +# dbstore-data and scratch. + +# E.g.: + # cd ~/work-gh/mrva/mrvacommander/client/containers/mrvadata/ + # mkdir tmp + # cp -r ../../../dbstore-data tmp + # cp -r ../../qldbtools/scratch tmp + +# Mirror parts of the host directory structure in the container +COPY tmp/dbstore-data /data/mrvacommander/dbstore-data + +COPY tmp/scratch /data/mrvacommander/qldbtools/scratch + +# Just run sh if this container is ever started +CMD ["sh"] diff --git a/client/containers/mrvadata/Makefile b/client/containers/mrvadata/Makefile new file mode 100644 index 0000000..b355dc2 --- /dev/null +++ b/client/containers/mrvadata/Makefile @@ -0,0 +1,16 @@ +all: image + +image: + docker build -t mrvadata . + +image-shell: image + docker run --rm -it mrvadata sh + +image-push: image + docker tag mrvadata ghcr.io/hohn/mrvadata:0.1.24 + docker push ghcr.io/hohn/mrvadata:0.1.24 + +image-test: + docker pull ghcr.io/hohn/mrvadata:0.1.24 + docker run --rm -it --name test-mrvadata ghcr.io/hohn/mrvadata:0.1.24 sh + diff --git a/client/containers/qldbtools/Dockerfile b/client/containers/qldbtools/Dockerfile new file mode 100644 index 0000000..e679cca --- /dev/null +++ b/client/containers/qldbtools/Dockerfile @@ -0,0 +1,29 @@ +# Use a Python 3.11 image as the base +FROM python:3.11-slim + +# Install git +RUN apt-get update && apt-get install -y git + +# Create the required directory structure +RUN mkdir -p /work-gh/mrva/ + +# Change to the directory and clone the repository +WORKDIR /work-gh/mrva/ +RUN git clone https://github.com/hohn/mrvacommander.git && \ + cd mrvacommander && \ + git checkout hohn-0.1.24-demo + +# Change to the client directory +WORKDIR /work-gh/mrva/mrvacommander/client/qldbtools/ + +# We're in a container, so use pip globally -- no virtual env +RUN pip install --upgrade pip + +# Install the required Python packages from requirements.txt +RUN pip install -r requirements.txt + +# Install qldbtools +RUN pip install . + +# Set the default entrypoint +CMD ["/bin/bash"]