osrf / rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.
Apache License 2.0
584 stars 75 forks source link

Clarification on the build context #266

Closed blooop closed 10 months ago

blooop commented 10 months ago

I am interested in writing an extension for rocker that looks for a file called dependencies.yaml, parses it and apt install those dependencies.

so far I have something partially working as part of off-your-rocker. This is how I'm running it.

rocker --oyr-dependencies -- ubuntu:22.04

I see that the dockerfile is generated and run in a temporary directory. I am probably missing something very obvious but I can't work out how to pass the local dependencies.yaml file to the docker context. I can copy the parse_dependencies script by using the get_files() method in the RockerExtension but I don't think that applies to dynamic files that are on the hosts machine.

my Dockerfile snippet:

RUN apt-get update \
 && apt-get install -y python3-yaml \
 && apt-get clean 

COPY parse_dependencies parse_dependencies

#This does not work because dependencies.yaml is in the folder where I run rocker, but not in the temp dir
#COPY dependencies.yaml dependencies.yaml

RUN python3 /parse_dependencies apt_base > apt_base.deps
blooop commented 10 months ago

Sorry, I was missing something obvious. I can access the working directory with Path.cwd() when the rocker extension is run. I think this solves my problem.