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
3.8 KiB
Overview
TODO diagram
TODO Style notes
- NO package init() functions
- Dynamic behaviour must be explicit
Cross-compile server on host, run it in container
These are simple steps using a single container.
-
build server on host
GOOS=linux GOARCH=arm64 go build -
build docker image
cd cmd/server docker build -t server-image . -
Start container with shared directory
docker run -it \ -v /Users/hohn/work-gh/mrva/mrvacommander:/mrva/mrvacommander \ server-image -
Run server in container
cd /mrva/mrvacommander/cmd/server/ && ./server
Using docker-compose
Steps to build and run the server in a multi-container environment set up by docker-compose.
-
Built the server-image, above
-
Build server on host
cd ~/work-gh/mrva/mrvacommander/cmd/server/ GOOS=linux GOARCH=arm64 go build -
Start the containers
cd ~/work-gh/mrva/mrvacommander/ docker-compose down docker-compose up -d -
Run server in its container
cd ~/work-gh/mrva/mrvacommander/ docker exec -it server bash cd /mrva/mrvacommander/cmd/server/ ./server -loglevel=debug -mode=container -
Test server via remote client by following the steps in gh-mrva
Some general docker-compose commands
-
Get service status
docker-compose ps -
Stop services
docker-compose down -
View all logs
docker-compose logs -
check containers from server container
docker exec -it server bash curl -I postgres:5432 curl -I http://rabbitmq:15672
Some postgres specific commands
-
Access PostgreSQL
psql -h localhost -p 5432 -U exampleuser -d exampledb -
List all tables
\dt -
Examine a table
select * from db_infos -
Show all columns in a specific table
\d+ db_infos -
Miscellany
\pset pager off \lo_import FILE [COMMENT]
Manually create needed postgres databases
docker-compose now runs a db init script, but this information is useful for debugging/manual work.
This is still necessary after docker-compose up to avoid
[error] failed to initialize database, got error failed to connect to
`user=exampleuser database=server_db`: 172.25.0.3:5432 (postgres): server
error: FATAL: database "server_db" does not exist (SQLSTATE 3D000)
from
./server -loglevel=debug -mode=container
The steps:
# on the host
psql -h localhost -p 5432 -U exampleuser -d postgres
# Conditionally create dbs
SELECT 'CREATE DATABASE server_db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'server_db')\gexec
SELECT 'CREATE DATABASE querypack_db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'querypack_db')\gexec
SELECT 'CREATE DATABASE qldb_db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'qldb_db')\gexec
# List all dbs
\l
To run pgmin, the minimal go/postgres test part of this repository
-
Run pgmin
cd ~/work-gh/mrva/mrvacommander/cmd/postgres GOOS=linux GOARCH=arm64 go build docker exec -it server bash /mrva/mrvacommander/cmd/postgres/postgresExit the container. Back on the host:
psql -h localhost -p 5432 -U exampleuser -d exampledb \dtShould show
List of relations Schema | Name | Type | Owner --------+-------------+-------+------------- public | owner_repos | table | exampleuser -
Check table contents
exampledb=# select * from owner_repos; owner | repo -------+--------- foo | foo/bar