Add codeql to server container for standalone testing

For full test, we cannot have

       ERROR codeql database analyze failed: error="exec:
       \"codeql\": executable file not found in $PATH" job="{MirvaRequestID:0
       QueryPackId:54674 QueryLanguage:cpp ORepo:{Owner:psycopg Repo:psycopg2}}"

For linux/arm64, use a Dockerfile that:
       - uses ubuntu 22.04 base image
       - adds the 1.17 version of the codeql bundle
       - extracts the bundle
       - adds a recent version of the JRE
       - extracts it
       - sets the CODEQL_JAVA_HOME environment variable to point to the JRE

The instructions are updated
This commit is contained in:
Michael Hohn
2024-06-12 11:28:37 -07:00
committed by =Michael Hohn
parent 765a76f75a
commit 5730c330f4
4 changed files with 40 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ These are simple steps using a single container.
2. build docker image
cd cmd/server
docker build -t server-image .
3. Start container with shared directory
@@ -32,6 +33,8 @@ These are simple steps using a single container.
## Using docker-compose
### Steps to build and run the server in a multi-container environment set up by docker-compose.
1. Built the server-image, above
1. Build server on host
cd ~/work-gh/mrva/mrvacommander/cmd/server/

View File

@@ -1,14 +1,38 @@
# Use Ubuntu 22.04 as the base image
FROM arm64v8/ubuntu:22.04
# Use the ubuntu 22.04 base image
FROM ubuntu:22.04
# Set environment variables to non-interactive to avoid prompts during installation
# Set architecture to arm64
ARG ARCH=arm64
ARG AARCH=aarch64
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV CODEQL_VERSION=codeql-bundle-v2.17.5
ENV CODEQL_DOWNLOAD_URL=https://github.com/github/codeql-action/releases/download/${CODEQL_VERSION}/codeql-bundle-linux64.tar.gz
ENV JDK_VERSION=22.0.1
ENV JDK_DOWNLOAD_URL=https://download.oracle.com/java/21/latest/jdk-${JDK_VERSION}_linux-${AARCH}_bin.tar.gz
ENV JDK_DOWNLOAD_URL=https://download.java.net/java/GA/jdk${JDK_VERSION}/c7ec1332f7bb44aeba2eb341ae18aca4/8/GPL/openjdk-${JDK_VERSION}_linux-${AARCH}_bin.tar.gz
# Update the package list
ENV CODEQL_JAVA_HOME=/usr/local/jdk-${JDK_VERSION}
# Install necessary tools
RUN apt-get update && \
apt-get clean
apt-get install -y curl tar && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Add and extract the CodeQL bundle
RUN curl -L $CODEQL_DOWNLOAD_URL -o /tmp/${CODEQL_VERSION}.tar.gz && \
tar -xzf /tmp/${CODEQL_VERSION}.tar.gz -C /opt && \
rm /tmp/${CODEQL_VERSION}.tar.gz
# Add and extract the JDK
RUN curl -L $JDK_DOWNLOAD_URL -o /tmp/jdk-${JDK_VERSION}.tar.gz && \
tar -xzf /tmp/jdk-${JDK_VERSION}.tar.gz -C /usr/local && \
rm /tmp/jdk-${JDK_VERSION}.tar.gz
# Set PATH
ENV PATH=/opt/codeql:"$PATH"
# Prepare host mount point
RUN mkdir /mrva
# Set the default command
CMD ["bash"]

View File

@@ -35,11 +35,11 @@ services:
server:
image: ubuntu:22.04
image: server-image
container_name: server
environment:
- MRVA_SERVER_ROOT=/mrva/mrvacommander/cmd/server
command: sh -c "apt-get update && apt-get install -y curl && tail -f /dev/null"
command: sh -c "tail -f /dev/null"
ports:
- "8080:8080"
volumes:

View File

@@ -115,6 +115,9 @@ func ArtifactURL(js common.JobSpec, vaid int) (string, error) {
slog.Error("Error packaging results:", "error", err)
return "", err
}
// TODO Need url valid in container network and externally
// For now, we assume the container port 8080 is port 8080 on user's machine
hostname = "localhost"
au := fmt.Sprintf("http://%s:8080/download-server/%s", hostname, zfpath)
return au, nil
}