Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
pull_request:
branches:
- '**'

jobs:
build-simulith:
runs-on: ubuntu-latest
container:
image: tryspaceorg/tryspace-lab
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
- name: Build Simulith
run: |
cd cfg
python3 tryspace-orchestrator.py
cd ..
for dir in $(pwd)/comp/*/sim ; do
if [ -d "$dir" ] && [ -f "$dir/Makefile" ]; then
echo "Building component in $dir"
make -C "$dir" build-sim
fi
done
cd simulith
make build-sim
build-fsw:
runs-on: ubuntu-latest
container:
image: tryspaceorg/tryspace-lab
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
- name: Build FSW
run: |
cd cfg
python3 tryspace-orchestrator.py
cd ../fsw
make build-fsw
162 changes: 88 additions & 74 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,58 +1,33 @@
# Makefile for TrySpace Lab development
.PHONY: all build build-fsw build-gsw build-sim build-cli cfg cli clean container debug fsw gsw real-clean runtime sim start stop
.PHONY: build clean clean-cli clean-fsw clean-gsw clean-sim cfg cli container debug env fsw gsw help sim start stop uninstall

export BUILD_IMAGE_NAME ?= tryspace-lab
# Build image name
export BUILD_IMAGE ?= tryspaceorg/tryspace-lab

# Commands
all: runtime

env:
@if [ ! -f $(CURDIR)/cfg/.env ]; then \
echo "Creating $(CURDIR)/cfg/.env with current user UID/GID..."; \
mkdir -p $(CURDIR)/cfg; \
echo "UID=$$(id -u)" > $(CURDIR)/cfg/.env; \
echo "GID=$$(id -g)" >> $(CURDIR)/cfg/.env; \
echo "Created $(CURDIR)/cfg/.env"; \
fi
$(MAKE) cfg

# Configure orchestrator (merges configs and updates active.yaml) using Docker
cfg:
@echo "[Makefile] Running orchestrator to merge configs in Docker..."
docker run --rm -v $(CURDIR):$(CURDIR) -w $(CURDIR)/cfg --user $(shell id -u):$(shell id -g) $(BUILD_IMAGE_NAME) python3 tryspace-orchestrator.py
# Common paths
CFG_DIR := $(CURDIR)/cfg
ENV_FILE := $(CFG_DIR)/.env

# Commands
build: env
$(MAKE) build-sim
$(MAKE) build-gsw
$(MAKE) build-fsw

build-cli: env
$(MAKE) container
@for dir in $(CURDIR)/comp/*/cli ; do \
if [ -f "$$dir/Makefile" ]; then \
$(MAKE) -C "$$dir" runtime; \
fi; \
done
cd $(CURDIR)/simulith && $(MAKE) director && $(MAKE) server

build-fsw:
docker run --rm -it -v $(CURDIR):$(CURDIR) --name "tryspace_fsw_build" -w $(CURDIR)/fsw --user $(shell id -u):$(shell id -g) --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $(BUILD_IMAGE_NAME) make -j build-fsw

build-gsw:
cd $(CURDIR)/gsw && $(MAKE) runtime

build-sim:
docker run --rm -it -v $(CURDIR):$(CURDIR) --name "tryspace_sim_build" -w $(CURDIR)/simulith --user $(shell id -u):$(shell id -g) $(BUILD_IMAGE_NAME) make -j build-sim
$(MAKE) sim
$(MAKE) fsw
$(MAKE) gsw

debug: env
docker run --rm -it -v $(CURDIR):$(CURDIR) --name "tryspace_fsw_debug" -w $(CURDIR) --user $(shell id -u):$(shell id -g) --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $(BUILD_IMAGE_NAME) /bin/bash
cfg: container
docker run --rm -v $(CURDIR):$(CURDIR) -w $(CURDIR)/cfg --user $(shell id -u):$(shell id -g) $(BUILD_IMAGE) python3 tryspace-orchestrator.py

clean:
$(MAKE) stop
$(MAKE) clean-cli
$(MAKE) clean-fsw
$(MAKE) clean-gsw
$(MAKE) clean-sim
@if docker image inspect $(BUILD_IMAGE):latest >/dev/null 2>&1; then \
$(MAKE) clean-cli; \
$(MAKE) clean-fsw; \
$(MAKE) clean-gsw; \
$(MAKE) clean-sim; \
else \
echo "Docker image $(BUILD_IMAGE) does not exist. Skipping clean subcommands."; \
fi
rm -f $(ENV_FILE) $(CFG_DIR)/active.yaml $(CFG_DIR)/build.yaml

clean-cli:
@for dir in $(CURDIR)/comp/*/cli ; do \
Expand All @@ -68,53 +43,92 @@ clean-gsw:
cd gsw && $(MAKE) clean

clean-sim:
@for dir in $(CURDIR)/comp/* ; do \
if [ -d "$$dir" ] && [ -f "$$dir/Makefile" ]; then \
$(MAKE) -C "$$dir" clean; \
fi; \
done
cd simulith && $(MAKE) clean

cli: env
$(MAKE) build-cli
$(MAKE) container
@for dir in $(CURDIR)/comp/*/cli ; do \
if [ -f "$$dir/Makefile" ]; then \
$(MAKE) -C "$$dir" runtime; \
fi; \
done
cd $(CURDIR)/simulith && $(MAKE) director && $(MAKE) server
docker compose -f ./cfg/cli-compose.yml up

container:
docker build -t $(BUILD_IMAGE_NAME) -f cfg/Dockerfile.base --build-arg USER_ID=$(shell id -u) --build-arg GROUP_ID=$(shell id -g) .
container: cfg/Dockerfile.base
docker build -t $(BUILD_IMAGE) -f cfg/Dockerfile.base --build-arg USER_ID=$(shell id -u) --build-arg GROUP_ID=$(shell id -g) .

debug: env
docker run --rm -it -v $(CURDIR):$(CURDIR) --name "tryspace_fsw_debug" -w $(CURDIR) --user $(shell id -u):$(shell id -g) --sysctl fs.mqueue.msg_max=10000 --ulimit rtprio=99 --cap-add=sys_nice $(BUILD_IMAGE) /bin/bash

env:
@command -v docker >/dev/null 2>&1 || { echo "Error: docker is not installed or not in PATH."; exit 1; }
@if [ ! -f $(ENV_FILE) ]; then \
echo "Creating $(ENV_FILE) with current user UID/GID..."; \
mkdir -p $(CFG_DIR); \
echo "UID=$$(id -u)" > $(ENV_FILE); \
echo "GID=$$(id -g)" >> $(ENV_FILE); \
echo "Created $(ENV_FILE)"; \
fi
$(MAKE) cfg

fsw: env
cd $(CURDIR)/fsw && $(MAKE) runtime

gsw: env
$(MAKE) build-gsw
cd $(CURDIR)/gsw && $(MAKE) runtime

help:
@echo "Usage: make <target>"
@echo "Targets:"
@echo " build - Build the full runtime environment"
@echo " cfg - Run orchestrator to configure environment"
@echo " cli - Build CLI and start CLI services"
@echo " clean - Remove build artifacts and stop services"
@echo " clean-cli - Clean CLI components"
@echo " clean-fsw - Clean FSW components"
@echo " clean-gsw - Clean GSW components"
@echo " clean-sim - Clean simulation components"
@echo " container - Build the Docker container"
@echo " debug - Start a debug shell in the container"
@echo " env - Create .env file and check required tools"
@echo " fsw - Build FSW"
@echo " gsw - Build GSW"
@echo " sim - Build Simulith and component simulators"
@echo " start - Start lab services"
@echo " stop - Stop lab and CLI services, clean up Docker images"
@echo " uninstall - Remove containers, images, volumes, and networks"

sim: env
cd $(CURDIR)/comp/demo/sim && $(MAKE) runtime
@for dir in $(CURDIR)/comp/*/sim ; do \
if [ -d "$$dir" ] && [ -f "$$dir/Makefile" ]; then \
echo "Building component in $$dir"; \
$(MAKE) -C "$$dir" runtime; \
fi; \
done
cd $(CURDIR)/simulith && $(MAKE) director && $(MAKE) server

real-clean: clean
docker ps -a --filter "name=tryspace-" -q | xargs -r docker rm -f
docker images "tryspace-*" -q | xargs -r docker rmi
docker volume ls -q --filter "name=gsw-data" | xargs -r docker volume rm
docker volume ls -q --filter "name=simulith_ipc" | xargs -r docker volume rm
docker network ls -q --filter "name=tryspace-net" | xargs -r docker network rm
docker network ls -q --filter "name=cfg_tryspace-net" | xargs -r docker network rm

runtime: env
$(MAKE) container
$(MAKE) sim
$(MAKE) fsw
$(MAKE) gsw

start: env
docker compose -f ./cfg/lab-compose.yml up

start-fsw:
cd fsw && $(MAKE) start

start-gsw:
cd gsw && $(MAKE) start

start-sim:
cd simulith && $(MAKE) start

stop:
docker compose -f ./cfg/cli-compose.yml down
docker compose -f ./cfg/lab-compose.yml down
docker images -f "dangling=true" -q | xargs -r docker rmi

uninstall: clean
docker ps -a --filter "name=tryspace-" -q | xargs -r docker rm -f
docker images "tryspace-*" -q | xargs -r docker rmi
docker volume ls -q --filter "name=gsw-data" | xargs -r docker volume rm
docker volume ls -q --filter "name=simulith_ipc" | xargs -r docker volume rm
docker network ls -q --filter "name=tryspace-net" | xargs -r docker network rm
docker network ls -q --filter "name=cfg_tryspace-net" | xargs -r docker network rm
@echo ""
@echo "To remove everything docker run: "
@echo " docker system prune -a"
@echo ""
23 changes: 12 additions & 11 deletions cfg/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
# https://github.com/TrySpaceOrg/tryspace-lab
#
# Assumes build using `make container` from top level of tryspace-lab repository
#
# docker push ghcr.io/tryspaceorg/tryspace-lab:latest
#
# docker push tryspaceorg/tryspace-lab:<tag>
#

FROM debian:bookworm-slim@sha256:6ac2c08566499cc2415926653cf2ed7c3aedac445675a013cc09469c9e118fdd
ENV DEBIAN_FRONTEND=noninteractive
LABEL maintainer="TrySpaceOrg" description="Base image for TrySpace Lab"

# Install required tools
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential=12.9 \
cmake=3.25.1-1 \
git=1:2.39.5-0+deb12u2 \
libsocketcan-dev=0.0.12-1 \
libzmq3-dev=4.3.4-6 \
pkg-config=1.8.1-1 \
python3=3.11.2-1+b1 \
python3-pip=23.0.1+dfsg-1 \
build-essential \
cmake \
git \
libsocketcan-dev \
libzmq3-dev \
pkg-config \
python3 \
python3-pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install orchestrator requirements for python
COPY cfg/requirements.txt /requirements.txt
RUN pip3 install --break-system-packages --no-cache-dir -r /requirements.txt
RUN pip3 install --break-system-packages --no-cache-dir --upgrade -r /requirements.txt && pip cache purge

# Create user for development (matches host user)
ARG USER_ID=1000
Expand Down
2 changes: 1 addition & 1 deletion comp/demo
2 changes: 1 addition & 1 deletion fsw
Submodule fsw updated 2 files
+3 −3 Makefile
+1 −1 tools/Dockerfile.fsw
2 changes: 1 addition & 1 deletion gsw
Submodule gsw updated 1 files
+12 −15 Makefile
2 changes: 1 addition & 1 deletion simulith