WIP: Working individual containers and docker compose demo

This commit is contained in:
Michael Hohn
2024-09-12 09:49:25 -07:00
committed by =Michael Hohn
parent 259bac55fb
commit 34958e4cf4
9 changed files with 175 additions and 126 deletions

View File

@@ -118,6 +118,12 @@ docker-compose.
cd ~/work-gh/mrva/mrvacommander cd ~/work-gh/mrva/mrvacommander
docker-compose up --build docker-compose up --build
1. Start the server containers and the desktop/demo containers
cd ~/work-gh/mrva/mrvacommander/
docker-compose down --remove-orphans
docker-compose -f docker-compose-demo.yml up -d
1. Test server via remote client by following the steps in [gh-mrva](https://github.com/hohn/gh-mrva/blob/connection-redirect/README.org#compacted-edit-run-debug-cycle) 1. Test server via remote client by following the steps in [gh-mrva](https://github.com/hohn/gh-mrva/blob/connection-redirect/README.org#compacted-edit-run-debug-cycle)
### Some general docker-compose commands ### Some general docker-compose commands

View File

@@ -14,9 +14,6 @@ RUN go mod download
# Build the Go binary # Build the Go binary
RUN go build . RUN go build .
# # Set the entrypoint
# CMD ["/bin/bash"]
# Use a minimal base image for the final container # Use a minimal base image for the final container
FROM debian:bookworm FROM debian:bookworm
@@ -26,5 +23,5 @@ WORKDIR /app
# Copy the binary from the builder stage # Copy the binary from the builder stage
COPY --from=builder /work-gh/mrva/gh-mrva/gh-mrva /usr/local/bin/gh-mrva COPY --from=builder /work-gh/mrva/gh-mrva/gh-mrva /usr/local/bin/gh-mrva
# Set the entrypoint to the binary # Run forever
ENTRYPOINT ["gh-mrva"] CMD ["tail", "-f", "/dev/null"]

View File

@@ -25,5 +25,6 @@ RUN pip install -r requirements.txt
# Install qldbtools # Install qldbtools
RUN pip install . RUN pip install .
# Set the default entrypoint # Run forever
CMD ["/bin/bash"] CMD ["tail", "-f", "/dev/null"]

View File

@@ -0,0 +1,24 @@
DBT_TARGET := client-qldbtools-container:0.1.24
# Build the qldbtools container image
dbt: client-qldbtools-container
client-qldbtools-container:
docker build -t ${DBT_TARGET} .
touch $@
# Run a shell in the container with the qldbtools
dbt-run: dbt
docker run --rm -it ${DBT_TARGET} /bin/bash
# Run one of the scripts in the container as check. Should exit with error.
dbt-check: dbt
docker run --rm -it ${DBT_TARGET} mc-db-initial-info
dbt-push: dbt
docker tag ${DBT_TARGET} ghcr.io/hohn/${DBT_TARGET}
docker push ghcr.io/hohn/${DBT_TARGET}
touch $@
dbt-test:
docker pull ghcr.io/hohn/${DBT_TARGET}
docker run --rm -it --name test-dbt-server ghcr.io/hohn/${DBT_TARGET} sh

View File

@@ -1,18 +1,13 @@
* MRVA python tools container * MRVA python tools container
Set upDocker image with python 3.11 and pip and the qldbtools Set up Docker image with python 3.11 and pip and the qldbtools. The targets are
in the =Makefile=; most important are
#+BEGIN_SRC sh #+BEGIN_SRC sh
# Build # Build
cd ~/work-gh/mrva/mrvacommander
make dbt make dbt
# Check # Check
cd ~/work-gh/mrva/mrvacommander
make dbt-check make dbt-check
# Use
cd ~/work-gh/mrva/mrvacommander
make dbt-run
#+END_SRC #+END_SRC

View File

@@ -56,7 +56,9 @@ ENV CODEQL_JAVA_HOME=/usr
# to user settings. # to user settings.
# This is in addition to the environment variable CODEQL_JAVA_HOME which has no # This is in addition to the environment variable CODEQL_JAVA_HOME which has no
# effect on the plugin # effect on the plugin
USER root
COPY ./settings.json /home/coder/.local/share/code-server/User/ COPY ./settings.json /home/coder/.local/share/code-server/User/
RUN chown -R coder:coder /home/coder/.local/share/code-server/
# Start Code Server # Start Code Server
ENTRYPOINT ["dumb-init", "code-server", "--bind-addr", "0.0.0.0:9080", "."] ENTRYPOINT ["dumb-init", "code-server", "--bind-addr", "0.0.0.0:9080", "."]

View File

@@ -17,6 +17,7 @@
- Setup inside the container - Setup inside the container
#+BEGIN_SRC shell #+BEGIN_SRC shell
cd
export PATH=/opt/codeql:$PATH export PATH=/opt/codeql:$PATH
codeql pack init qldemo codeql pack init qldemo
cd qldemo cd qldemo
@@ -26,9 +27,12 @@
- Open a new file =qldemo/simple.ql= and add this this query to it. The plugin - Open a new file =qldemo/simple.ql= and add this this query to it. The plugin
will download the CodeQL binaries (but never use them -- the configuration will download the CodeQL binaries (but never use them -- the configuration
redirects) redirects)
#+BEGIN_SRC java #+BEGIN_SRC sh
cd
cat > qldemo/simple.ql <<eof
import python import python
select 42 select 42
eof
#+END_SRC #+END_SRC
- Create database. - Create database.
@@ -42,7 +46,7 @@
codeql database create --language=python -s . -v short-db codeql database create --language=python -s . -v short-db
#+END_SRC #+END_SRC
- Set the database as default and run the query. - Set the database as default and run the query on =simple.ql=
- Capture the state of this container and create a new image from it - Capture the state of this container and create a new image from it
#+BEGIN_SRC sh #+BEGIN_SRC sh
@@ -53,8 +57,6 @@
#+END_SRC #+END_SRC
- Push this container - Push this container
[[file:~/work-gh/mrva/mrvacommander/client/containers/vscode/Makefile::image-push: image]]
#+BEGIN_SRC sh #+BEGIN_SRC sh
docker images |head
make csi-push make csi-push
#+END_SRC #+END_SRC

View File

@@ -1,4 +1,4 @@
{ {
"codeQL.runningQueries.numberOfThreads": 2, "codeQL.runningQueries.numberOfThreads": 2,
"codeQl.cli.executablePath": "/opt/codeql" "codeQL.cli.executablePath": "/opt/codeql/codeql"
} }

View File

@@ -1,111 +1,133 @@
services: services:
code-server: mrvadata:
image: codercom/code-server image: ghcr.io/hohn/mrvadata:0.1.24
ports: container_name: mrvadata
- "9080:8080" volumes:
volumes: - mrvadata:/data/mrvacommander
- ./project:/home/coder/project networks:
- ~/.config/code-server:/home/coder/.config/code-server - backend
- ~/.local/share/code-server:/home/coder/.local/share/code-server
environment:
- PASSWORD=mrva
rabbitmq: client-qldbtools:
image: rabbitmq:3-management image: ghcr.io/hohn/client-qldbtools-container:0.1.24
hostname: rabbitmq volumes:
container_name: rabbitmq # data at /data/mrvacommander/qldbtools/scratch
volumes: - mrvadata:/data/mrvacommander
- ./init/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro depends_on:
- ./init/rabbitmq/definitions.json:/etc/rabbitmq/definitions.json:ro - mrvadata
ports: networks:
- "5672:5672" - backend
- "15672:15672"
networks:
- backend
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
timeout: 30s
retries: 10
server:
build:
context: .
dockerfile: ./cmd/server/Dockerfile
command: [ '--mode=container', '--loglevel=debug' ]
container_name: server
stop_grace_period: 1s
ports:
# - "8081:8080" # host:container for proxy
- "8080:8080" # host:container
depends_on:
- rabbitmq
- dbstore
- artifactstore
networks:
- backend
env_file:
- path: ./.env.container
required: true
dbstore: client-ghmrva:
image: minio/minio:RELEASE.2024-06-11T03-13-30Z # XX: redirect by changing code or using nginx proxy
container_name: dbstore # client.Get(fmt.Sprintf("http://localhost:8080/repos/%s/code-scanning/codeql/variant-analyses/%d", controller, runId), &response)
ports: image: ghcr.io/hohn/client-ghmrva-container:0.1.24
- "9000:9000" volumes:
- "9001:9001" - mrvadata:/data/mrvacommander
env_file: depends_on:
- path: .env.container - mrvadata
required: true networks:
- backend
command: server /data --console-address ":9001" code-server:
# Demo: Mount preloaded minio backing store image: ghcr.io/hohn/code-server-initialized:0.1.24
volumes: ports:
- type: volume - "9080:9080"
source: dbstore-volume volumes:
target: /data/dbs - mrvadata:/data/mrvacommander
volume: environment:
nocopy: true - PASSWORD=mrva
networks: depends_on:
- backend - mrvadata
artifactstore: rabbitmq:
image: minio/minio:RELEASE.2024-06-11T03-13-30Z image: rabbitmq:3-management
container_name: artifactstore hostname: rabbitmq
ports: container_name: rabbitmq
- "19000:9000" # host:container volumes:
- "19001:9001" - ./init/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
env_file: - ./init/rabbitmq/definitions.json:/etc/rabbitmq/definitions.json:ro
- path: ./.env.container ports:
required: true - "5672:5672"
command: server /data --console-address ":9001" - "15672:15672"
volumes: healthcheck:
- ./qpstore-data:/data test: rabbitmq-diagnostics check_port_connectivity
networks: interval: 30s
- backend timeout: 30s
retries: 10
networks:
- backend
agent: server:
build: image: ghcr.io/hohn/mrva-server:0.1.24
context: . command: [ '--mode=container', '--loglevel=debug' ]
dockerfile: ./cmd/agent/Dockerfile container_name: server
command: [ '--loglevel=debug' ] stop_grace_period: 1s
container_name: agent ports:
depends_on: - "8080:8080" # host:container
- rabbitmq depends_on:
- dbstore - rabbitmq
- artifactstore - dbstore
env_file: - artifactstore
- path: ./.env.container env_file:
required: true - path: ./.env.container
networks: required: true
- backend networks:
- backend
dbstore:
image: minio/minio:RELEASE.2024-06-11T03-13-30Z
container_name: dbstore
ports:
- "9000:9000"
- "9001:9001"
env_file:
- path: .env.container
required: true
command: server /data/mrvacommander/dbstore-data --console-address ":9001"
depends_on:
- mrvadata
volumes:
# data at /data/mrvacommander/dbstore-data
- mrvadata:/data/mrvacommander
networks:
- backend
artifactstore:
image: minio/minio:RELEASE.2024-06-11T03-13-30Z
container_name: artifactstore
ports:
- "19000:9000" # host:container
- "19001:9001"
env_file:
- path: ./.env.container
required: true
command: server /data --console-address ":9001"
volumes:
# data at /data/mrvacommander/qpstore-data
- mrvadata:/data/mrvacommander
# XX: use multiple storage containers?
# - ./qpstore-data:/data
networks:
- backend
agent:
image: ghcr.io/hohn/mrva-agent:0.1.24
command: [ '--loglevel=debug' ]
container_name: agent
depends_on:
- rabbitmq
- dbstore
- artifactstore
env_file:
- path: ./.env.container
required: true
networks:
- backend
networks: networks:
backend: backend:
driver: bridge driver: bridge
# Demo: Provide preloaded minio backing store
volumes: volumes:
dbstore-volume: mrvadata:
external: true
name: dbstore-container:/data