From 13a065545e4d51896ac7ee4c5c79b893be712fac Mon Sep 17 00:00:00 2001 From: michael hohn Date: Wed, 26 Nov 2025 12:39:59 -0800 Subject: [PATCH] Standardize container build workflow for v0.4.5 - Build Go binaries (gh-mrva, mrvaserver, mrvaagent) in source repos before copying to container dirs - Apply consistent v0.4.5 tagging across all containers (ghmrva, vscode, hepc, server, agent) - Update hepc to sync mrvahepc source with venv and .git exclusions - Verify deployment with docker-compose-demo.yml and bin/ma.send-request tests --- README.org | 70 ++++++++++++++++++++++++++---------- containers/agent/Dockerfile | 27 +++----------- containers/ghmrva/Dockerfile | 25 +++---------- containers/server/Dockerfile | 27 +++----------- docker-compose-demo.yml | 12 ++++--- 5 files changed, 71 insertions(+), 90 deletions(-) diff --git a/README.org b/README.org index dc0f4ef..1f7f169 100644 --- a/README.org +++ b/README.org @@ -115,22 +115,54 @@ # enter vm (on mac) limactl shell ubu - cd ~/work-gh/mrva/mrva-docker/containers/ghmrva/ - docker build -t client-ghmrva-container:0.4.0 . + #** ghmrva + cont_dir=~/work-gh/mrva/mrva-docker/containers/ghmrva/ + build_dir=~/work-gh/mrva/gh-mrva + # + cd $build_dir + go build + # Copy the new binary + cp gh-mrva $cont_dir + # + cd $cont_dir + docker build -t mrva-gh-mrva:0.4.5 . + #** vscode cd ~/work-gh/mrva/mrva-docker/containers/vscode/ - docker build -t code-server-initialized:0.4.0 . + docker build -t code-server-initialized:0.4.5 . + #** hepc # *slow* in vm with shared folders - cd ~/work-gh/mrva/mrva-docker/containers/hepc &&\ - rm -fR ./mrvahepc && cp -r ../../../mrvahepc . - docker build -t mrva-hepc-container:0.4.0 -f Dockerfile . + cd ~/work-gh/mrva/mrva-docker/containers/hepc + rm -fR ./mrvahepc && + rsync -a --exclude='*/venv/*' \ + --exclude='*/\.git/*' \ + ../../../mrvahepc . + docker build -t mrva-hepc-container:0.4.5 -f Dockerfile . - cd ~/work-gh/mrva/mrva-docker/containers/server/ - docker build -t mrva-server:0.4.0 . + #** server + cont_dir=~/work-gh/mrva/mrva-docker/containers/server/ + build_dir=~/work-gh/mrva/mrvaserver + # + cd $build_dir + go build + # Copy the new binary + cp mrvaserver $cont_dir + # + cd $cont_dir + docker build -t mrva-server:0.4.5 . - cd ~/work-gh/mrva/mrva-docker/containers/agent/ - docker build -t mrva-agent:0.4.0 . + #** agent + cont_dir=~/work-gh/mrva/mrva-docker/containers/agent/ + build_dir=~/work-gh/mrva/mrvaagent + # + cd $build_dir + go build + # Copy the new binary + cp mrvaagent $cont_dir + # + cd $cont_dir + docker build -t mrva-agent:0.4.5 . # #* Start the containers @@ -140,14 +172,16 @@ docker-compose -f docker-compose-demo.yml up - # - #* Populate the db container if needed. - # Note: this requires - # /Users/hohn/work-gh/mrva/mrva-open-source-download , - # a large tree not part of this repository. - # - cd ~/work-gh/mrva/mrvacommander/client/qldbtools && uv sync - uv run bin/mc-db-populate-minio < scratch/db-info-3.csv + # # + # #* Populate the db container if needed. + # # Note: this requires + # # /Users/hohn/work-gh/mrva/mrva-open-source-download , + # # a large tree not part of this repository. + # # + # # This is older. With the use of hepc, this should not be necessary. + # # + # cd ~/work-gh/mrva/mrvacommander/client/qldbtools && uv sync + # uv run bin/mc-db-populate-minio < scratch/db-info-3.csv #* update the binaries in a running container #** compile server locally diff --git a/containers/agent/Dockerfile b/containers/agent/Dockerfile index c7d13cc..1f4ca47 100644 --- a/containers/agent/Dockerfile +++ b/containers/agent/Dockerfile @@ -1,24 +1,5 @@ -FROM golang:1.22 AS builder - -# Set the working directory inside the container -WORKDIR /app - -# Copy the host directory containing the git clone to the container -COPY mrvaagent.tmp /app/mrvaagent - -# Set the environment variables for Go modules -ENV GO111MODULE=on -ENV CGO_ENABLED=0 - -# Build the project -WORKDIR /app/mrvaagent -RUN go mod tidy && go build -o /app/mrvaagent-binary - -# # Download dependencies -# RUN go mod download - -# Create a runtime container -FROM ubuntu:24.04 AS runner +# Runtime container - binary built on host +FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive # Build argument for CodeQL version, defaulting to the latest release @@ -46,8 +27,8 @@ ENV CODEQL_CLI_PATH=/opt/codeql/codeql # This env var has no functional effect on CodeQL when running on x86_64 linux ENV CODEQL_JAVA_HOME=/usr -# Copy the built binary from the builder stage -COPY --from=builder /app/mrvaagent-binary /usr/local/bin/mrvaagent +# Copy the host-built binary +COPY mrvaagent /usr/local/bin/mrvaagent # Copy the binary-replacement support script to the container COPY entrypoint.sh /usr/local/bin/entrypoint.sh diff --git a/containers/ghmrva/Dockerfile b/containers/ghmrva/Dockerfile index e5c90f0..f407847 100644 --- a/containers/ghmrva/Dockerfile +++ b/containers/ghmrva/Dockerfile @@ -1,24 +1,7 @@ -# ###################### -# 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 . - # ###################### # Provide codeql and java -# -FROM ubuntu:24.04 AS runner +# Binary built on host +FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive # Build argument for CodeQL version, defaulting to the latest release @@ -54,8 +37,8 @@ ENV CODEQL_JAVA_HOME=/usr # 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 +# Copy the host-built binary +COPY gh-mrva /usr/local/bin/gh-mrva # Put CodeQL on the PATH ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/codeql diff --git a/containers/server/Dockerfile b/containers/server/Dockerfile index e272c1f..9f10f7e 100644 --- a/containers/server/Dockerfile +++ b/containers/server/Dockerfile @@ -1,24 +1,5 @@ -FROM golang:1.22 AS builder - -# Set the working directory inside the container -WORKDIR /app - -# Copy the host directory containing the git clone to the container -COPY mrvaserver.tmp /app/mrvaserver - -# Set the environment variables for Go modules -ENV GO111MODULE=on -ENV CGO_ENABLED=0 - -# Build the project -WORKDIR /app/mrvaserver -RUN go mod tidy && go build -o /app/mrvaserver-binary - -# # Download dependencies -# RUN go mod download - -# Create a runtime container -FROM ubuntu:24.04 AS runner +# Runtime container - binary built on host +FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive # Build argument for CodeQL version, defaulting to the latest release @@ -46,8 +27,8 @@ ENV CODEQL_CLI_PATH=/opt/codeql/codeql # This env var has no functional effect on CodeQL when running on x86_64 linux ENV CODEQL_JAVA_HOME=/usr -# Copy the built binary from the builder stage -COPY --from=builder /app/mrvaserver-binary /usr/local/bin/mrvaserver +# Copy the host-built binary +COPY mrvaserver /usr/local/bin/mrvaserver # Copy the binary-replacement support script to the container COPY entrypoint.sh /usr/local/bin/entrypoint.sh diff --git a/docker-compose-demo.yml b/docker-compose-demo.yml index da9076e..993f99b 100644 --- a/docker-compose-demo.yml +++ b/docker-compose-demo.yml @@ -38,15 +38,17 @@ services: client-ghmrva: # ./containers/ghmrva/Dockerfile container_name: mrva-ghmrva - image: client-ghmrva-container:0.4.0 + image: mrva-gh-mrva:0.4.5 network_mode: "service:server" # Share the 'server' network namespace environment: - SERVER_URL=http://localhost:8080 # 'localhost' now refers to 'server' + - MRVA_SERVER_URL=http://server:8080 + code-server: # ./containers/vscode/Dockerfile container_name: mrva-code-server - image: code-server-initialized:0.4.0 + image: code-server-initialized:0.4.5 ports: - "9080:9080" # XX: Include codeql binary in code-server (if it's not there already) @@ -57,7 +59,7 @@ services: hepc: # ./containers/hepc/Dockerfile - image: mrva-hepc-container:0.4.0 + image: mrva-hepc-container:0.4.5 container_name: mrva-hepc hostname: hepc command: >- @@ -89,7 +91,7 @@ services: server: # ./containers/server/Dockerfile - image: mrva-server:0.4.0 + image: mrva-server:0.4.5 command: [ '--mode=container', '--loglevel=debug' ] container_name: mrva-server hostname: server @@ -127,7 +129,7 @@ services: agent: # ./containers/agent/Dockerfile - image: mrva-agent:0.4.0 + image: mrva-agent:0.4.5 command: [ '--loglevel=debug' ] container_name: mrva-agent hostname: agent