Open domenkozar opened 8 months ago
IIUC, it would be cool if it were this easy but the devenv command isn't available anywhere in the PATH within a container. Currently only the devenv-tasks
cmd exists within the bindir of the devenv derivation installed in the container and it's not available on the PATH either. We could make it so we could do devenv-tasks run devenv:enterShell
easily, that might help.
I'm currently executing this within a Dockerfile to generate a new image with the devenv container as a base:
# syntax=docker/dockerfile:1
# Derived from: https://docs.docker.com/language/python/build-images/
FROM ghcr.io/mcdonc/testpackages/climo:latest
USER user
WORKDIR /env
# creates layer where pip requirements are installed
RUN /bin/entershell
CMD /bin/runproject
Where entershell
is:
entershell = pkgs.writeShellScriptBin "entershell" ''
# XXX this would be way easier if i could figure out how to get
# the path to the devenv installed in the container within nix
devenv=`ls -x /nix/store|grep -P '.{32}\-devenv-\d\.'`
/nix/store/$devenv/bin/devenv-tasks run devenv:enterShell
'';
And runproject
is
runproject = pkgs.writeShellScriptBin "runproject" ''
${config.procfileScript}
'';
I add a layer using containers.climo.layers.copyToRoot
to put entershell
and runproject
into the root of the image produced by devenv container
, then I then run docker build --tag 'ghcr.io/mcdonc/testpackages/climo:depsinstalled' .
to get a derived image that has enterShell
run already.
We'd want to support Docker and Podman, the two most popular desktop container engines.
The only compatibility layer that exists is Docker RESTful API, where the workflow would be something like:
Build our container
curl -X POST http://localhost:2375/containers/{id}/start
I'm not sure yet what this would be called, but for now I propose
containers.<name>.impureShell = "...";
.cc @mcdonc