Skip to content

compose build options added #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: erf_2025
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ HOST_HOME="${HOST_HOME:-/home/coresense/}"
HOST_WORKSPACE_FOLDER="${HOST_WORKSPACE_FOLDER:-${HOST_HOME}/workspaces/k_ws/}"

CONTAINER_USER_HOME="/home/ros/"
CONTAINER_DEV_WORKSPACE="/workspaces/mesh_ws/"

DYNAMIC_MESH_GEN_SRC_HOST_DIR="${HOST_WORKSPACE_FOLDER}/src/dynamic_mesh/"
DYNAMIC_MESH_GEN_SRC_CONTAINER_DIR="${CONTAINER_DEV_WORKSPACE}/src/dynamic_mesh/"
DYNAMIC_MESH_TARGET_WS="/workspaces/mesh_ws/"
DYNAMIC_MESH_SRC_SUBDIR="src/dynamic_mesh/"
DYNAMIC_MESH_SRC_CONTAINER_DIR="${DYNAMIC_MESH_TARGET_WS}/${DYNAMIC_MESH_SRC_SUBDIR}"

DISPLAY=${DISPLAY:-"coresense-nuc:1.0"}
7 changes: 7 additions & 0 deletions build.docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

services:

dynamic_mesh_gen:
extends:
file: ./container/docker_compose/build.dynamic_mesh.docker-compose.yaml
service: dynamic_mesh_gen
35 changes: 35 additions & 0 deletions container/docker_compose/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
###########################################
# docker build
# -t user/repo:tag # assign user, repo and tag. if tag is omitted, will default to 'latest'
# --rm # (optional) clean up intermediate images
# --build-context name=location
# --build-arg name=value
# -f Dockerfilename . # build from file with context (. is current pwd)
#
# docker build -t erf2025.demo/dynamic_mesh_gen --build-arg DYNAMIC_MESH_TARGET_WS=/workspaces/dynamic_mesh_ws --build-arg DYNAMIC_MESH_SRC_SUBDIR=src/dynamic_mesh -f build.Dockerfile .
#
###########################################
# docker push user/repo:tag
###########################################

# hadolint global ignore=DL3004

FROM scancontrol:latest

ARG DYNAMIC_MESH_TARGET_WS="/CHANGEME_ws"
ARG DYNAMIC_MESH_SRC_SUBDIR="src/dynamic_mesh"

USER ros

RUN sudo mkdir -p "${DYNAMIC_MESH_TARGET_WS}/${DYNAMIC_MESH_SRC_SUBDIR}" && sudo chown -R ros:ros "${DYNAMIC_MESH_TARGET_WS}"

WORKDIR ${DYNAMIC_MESH_TARGET_WS}/${DYNAMIC_MESH_SRC_SUBDIR}

COPY ${DYNAMIC_MESH_SRC_SUBDIR} ${DYNAMIC_MESH_TARGET_WS}/${DYNAMIC_MESH_SRC_SUBDIR}

WORKDIR ${DYNAMIC_MESH_TARGET_WS}

# Remember to source ROS here if the script requires ROS variables!
RUN [ "/bin/bash", "-c", "source /opt/ros/humble/setup.sh && ${DYNAMIC_MESH_TARGET_WS}/${DYNAMIC_MESH_SRC_SUBDIR}/container/docker_compose/scripts/build_app.sh -t ${DYNAMIC_MESH_TARGET_WS}" ]

ENTRYPOINT [ "/bin/bash", "-c", "tail -f /dev/null" ]
37 changes: 37 additions & 0 deletions container/docker_compose/build.dynamic_mesh.docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

services:
dynamic_mesh_gen:

build:
context: ${HOST_WORKSPACE_FOLDER:-/CHANGEMEws}
args:
DYNAMIC_MESH_TARGET_WS: ${DYNAMIC_MESH_TARGET_WS:-/CHANGEMEcached_target_ws}
DYNAMIC_MESH_SRC_SUBDIR: ${DYNAMIC_MESH_SRC_SUBDIR:-src/CHANGEMEcached}
dockerfile: ${HOST_WORKSPACE_FOLDER}/${DYNAMIC_MESH_SRC_SUBDIR}/container/docker_compose/build.Dockerfile

image: erf2025.demo/dynamic_mesh_c
container_name: dynamic_mesh_gen_c

environment:
DEV_WORKSPACE: ${DYNAMIC_MESH_TARGET_WS:-/CHANGEMEcached_target_ws}

env_file:
- path: variables.env
required: true # default

network_mode: host

# entrypoint: tail -f /dev/null
entrypoint: ${DYNAMIC_MESH_SRC_CONTAINER_DIR}/container/docker_compose/scripts/run_app.sh -t ${DYNAMIC_MESH_TARGET_WS}

working_dir: ${DYNAMIC_MESH_TARGET_WS:-/CHANGEMEwrkdir}

user: ${PUID:-1000}:${PGID:-1000}

ipc: host

mem_limit: 12gb # TODO confirm this

privileged: true

tty: true
34 changes: 29 additions & 5 deletions container/docker_compose/scripts/build_app.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
#! /bin/bash
#!/bin/bash

cd "${DEV_WORKSPACE}" || exit
SOURCE_WS="$DEV_WORKSPACE"

# Auto-build everything in the background:
# export ROSDEP_SKIP_KEYS=snp_msgs
# "${DEV_WORKSPACE}"/src/dynamic_mesh/setup.sh -t "${DEV_WORKSPACE}"
USAGE="
build.sh usage

-t <path> \
SOURCE_WS: the location of the workspace you wish to cache inside an image

"

while getopts t:h flag; do
case "${flag}" in
t) SOURCE_WS=${OPTARG} ;;
h)
echo -e "${USAGE}"
exit 0
;;
*)
echo 'Unknown parameter' >&2
echo 'use -h for usage information'
exit 1
;;
esac
done

echo "Target workspace: ${SOURCE_WS}"

cd "${SOURCE_WS}" || exit

# Auto-build everything in the background:
source /opt/ros/humble/setup.bash

# install dependencies
Expand Down
31 changes: 29 additions & 2 deletions container/docker_compose/scripts/run_app.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
#! /bin/bash

cd "${DEV_WORKSPACE}" || exit
SOURCE_WS="$DEV_WORKSPACE"

USAGE="
build.sh usage

-t <path> \
SOURCE_WS: the location of the workspace you wish to cache inside an image

"

while getopts t:h flag; do
case "${flag}" in
t) SOURCE_WS=${OPTARG} ;;
h)
echo -e "${USAGE}"
exit 0
;;
*)
echo 'Unknown parameter' >&2
echo 'use -h for usage information'
exit 1
;;
esac
done

echo "Target workspace: ${SOURCE_WS}"

cd "${SOURCE_WS}" || exit

source ~/.bashrc
source install/setup.bash
source "${SOURCE_WS}/install/setup.bash"

# launch processes here

Expand Down