Skip to content

Latest commit

 

History

History
145 lines (115 loc) · 4.35 KB

File metadata and controls

145 lines (115 loc) · 4.35 KB

Common Developer Tasks for Polar

If you have mask installed, you can use it to quickly perform these common operations. If not, consider installing it to further oxidize your life.

For example, from here in the root of the project, try running mask build agents to quickly build the cargo workspace with nix. this will give you all the binaries we have defined for the project.

Our team primarily uses podman as a container runtime. So feel free to alias it for your favorite/compatible runtime.

build-image

dev

Builds the Polar Dev image. A contaienrized Rust development environment in case you don't want to do local development.

echo "Building the Polar development environment. This may take a moment."

export def greet [] {
  print "Current Weather"
  print $env.WEATHER_INFO
}  nix build .#containers.devContainer --show-trace
echo "Loading the development image."
podman load < result

cassini

Build's cassini's container image

echo "building cassini image..."
nix build .#polarPkgs.cassini.cassiniImage -o cassini
echo "loading image..."
podman load < cassini 

gitlab

builds the gitlab agents and their images

echo "Building gitlab agent images..."
nix build .#polarPkgs.gitlabAgent.observerImage -o gitlab-observer
nix build .#polarPkgs.gitlabAgent.consumerImage -o gitlab-consumer
echo "loading images..."
podman load < gitlab-observer
podman load < gitlab-consumer

kube

builds the kube agents and their images

echo "Building kubernetes agent images..."
nix build .#polarPkgs.kubeAgent.observerImage -o kube-observer
nix build .#polarPkgs.kubeAgent.consumerImage -o kube-consumer
echo "loading images..."
podman load < kube-observer
podman load < kube-consumer

start-dev (public_key)

Enters the Polar Dev container.

This command mounts your project directory into the container at the /workspace directory, allowing you to work on your project files within the container.

  podman run --it \
  --user 0 --userns=keep-id \
  -v ./:/workspace:rw \
  -p 2222:2223 \
  -e CREATE_USER="$USER" \
  -e CREATE_UID="$(id -u)" \
  -e CREATE_GID="$(id -g)" \
  -e DROPBEAR_ENABLE=1 \
  -e DROPBEAR_PORT=2223 \
  -e AUTHORIZED_KEYS_B64="$(base64 -w0 $public_key)" \
  polar-dev:latest
  

start-compose

Starts the docker compose file to start up the docker compose for local testing. Runs in background

podman compose -f src/conf/docker-compose.yml up -d

build

agents

Builds all of the polar agents and outputs their binaries

nix build .#default -o polar

cassini

Builds all of the polar agents and outputs their binaries

nix build .#polarPkgs.cassini.cassini .#polarPkgs.cassini.harnessProducer .#polarPkgs.cassini.harnessSink

get-tls

Runs the nix derivation to generate TLS certificates for testing.

nix build .#tlsCerts -o certs

ls -alh certs

render (environment) (output_dir)

Uses the render-manifests.sh script to render all manifests in the polar/deploy repository, ensure you have the proper environment variables set. See the deployment docs for details.

    sh $MASKFILE_DIR/scripts/render-manifests.sh "$MASKFILE_DIR/src/deploy/$environment" $MASKFILE_DIR/$output_dir

static-analysis

uses the static-tools.sh script to run various static analysis tools on the rust source code.

sh scripts/static-tools.sh --manifest-path src/agents/Cargo.toml

run-ci

Runs the gitlab-ci.sh script to run the CI/CD job locally on your machine. NOTE: You will need to set all of the environment variables appropriately.' See our example.env and the Gitlab Documentation for details.

podman run --rm \
--name polar-dev \
--env-file=ci.env  \
--env CI_COMMIT_REF_NAME=$(git symbolic-ref --short HEAD) \
--env CI_COMMIT_SHORT_SHA=$(git rev-parse --short=8 HEAD) \
--env SSL_CERT_FILE="./src/conf/certs/proxy-ca.pem" \
--user 0 \
--userns=keep-id \
-v $(pwd):/workspace:rw \
-p 2222:2223 \
polar-dev:0.1.0 \
bash -c "start.sh; chmod +x scripts/gitlab-ci.sh; chmod +x scripts/static-tools.sh ; scripts/gitlab-ci.sh"