#ansible-builder

1 messages · Page 1 of 1 (latest)

warped walrus
#

I am trying to generate container images from ansible-builder with dagger. the build runs "**ansible-builder create -v3 -f execution-environment.yml --output-filename Dockerfile" that will create a context folder with the Dockerfile and needed files.

How to proceed from this point on is difficult to comprehend from the documentation.

royal dragon
#

let us know if that makes sense

warped walrus
#

so that Dockerfile are created inside the build_env and not in the sources

#

will give it a try

#

Tnx

#
@function
  def build(self, source: dagger.Directory) -> dagger.Container:
    """Build a ready-to-use development environment"""
    return (
      dag.container()
      .from_(self.buildenv_img)
      .with_exec("pip install --upgrade pip".split(" "))
      .with_exec("pip install --upgrade poetry".split(" "))
      .with_exec("apk add podman buildah".split(" "))
      .with_exec("echo ${PATH}".split(" "))
      .with_exec("rm -rf /app".split(" "))
      .with_exec("mkdir /app".split(" "))
      .with_directory("/app", source)
      .with_workdir("/app")
      .with_env_variable("POETRY_NO_INTERACTION", "1")
      .with_env_variable("POETRY_VIRTUALENVS_IN_PROJECT", "1")
      .with_env_variable("POETRY_VIRTUALENVS_CREATE", "1")
      .with_env_variable("POETRY_CACHE_DIR", "/tmp/poetry_cache")
      .with_exec("poetry install".split(" "))
      .with_env_variable("VIRTUAL_ENV", "/app/.venv")
      .with_env_variable("PATH", "/app/.venv/bin:${PATH}")
      .with_env_variable("PYTHONPATH", "${PYTHONPATH}:/app")
      .with_exec("ansible-builder create -v3 --output-filename Dockerfile".split(" "))
      .directory("/app/context")
      .docker_build()
    )

seems to work for now

royal dragon