Skip to content

Commit

Permalink
FIXUP: Have only one list of build-dependent files
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Oct 2, 2024
1 parent 1705633 commit 09aaee2
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions dev_scripts/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,28 @@ def get_current_date():
return date.today().strftime("%Y-%m-%d")


def get_build_dir_sources(distro, version):
"""Return the files needed to build an image."""
sources = [
git_root() / "pyproject.toml",
git_root() / "poetry.lock",
git_root() / "dev_scripts" / "storage.conf",
git_root() / "dev_scripts" / "containers.conf",
]

if distro == "ubuntu" and version in ("22.04", "jammy"):
sources.extend(
[
git_root() / "dev_scripts" / "apt-tools-prod.pref",
git_root() / "dev_scripts" / "apt-tools-prod.sources",
]
)
return sources


def image_name_build_dev(distro, version):
"""Get the container image for the dev variant of a Dangerzone environment."""
hash = hash_files(
get_files_in("dev_scripts")
+ [
git_root() / "pyproject.toml",
git_root() / "poetry.lock",
]
)
hash = hash_files(get_build_dir_sources(distro, version))

return IMAGE_NAME_BUILD_DEV_FMT.format(
distro=distro, version=version, hash=hash, date=get_current_date()
Expand Down Expand Up @@ -695,15 +708,9 @@ def build_dev(self, show_dockerfile=DEFAULT_SHOW_DOCKERFILE, sync=False):
os.makedirs(build_dir, exist_ok=True)

# Populate the build context.
shutil.copy(git_root() / "pyproject.toml", build_dir)
shutil.copy(git_root() / "poetry.lock", build_dir)
shutil.copy(git_root() / "dev_scripts" / "storage.conf", build_dir)
shutil.copy(git_root() / "dev_scripts" / "containers.conf", build_dir)
if self.distro == "ubuntu" and self.version in ("22.04", "jammy"):
shutil.copy(git_root() / "dev_scripts" / "apt-tools-prod.pref", build_dir)
shutil.copy(
git_root() / "dev_scripts" / "apt-tools-prod.sources", build_dir
)
for source in get_build_dir_sources(self.distro, self.version):
shutil.copy(source, build_dir)

with open(build_dir / "Dockerfile", mode="w") as f:
f.write(dockerfile)

Expand Down

0 comments on commit 09aaee2

Please sign in to comment.