Skip to content

Commit

Permalink
Make base_image configurable
Browse files Browse the repository at this point in the history
Fixes #487
  • Loading branch information
yuvipanda committed Jun 25, 2022
1 parent d26c1f1 commit f6fe9e0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 11 additions & 1 deletion repo2docker/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,16 @@ def _user_name_default(self):
""",
)

base_image = Unicode(
"buildpack-deps:bionic",
config=True,
help="""
Base image to use when building docker images.
Should be an ubuntu derivative, minimum 18.04.
""",
)

def get_engine(self):
"""Return an instance of the container engine.
Expand Down Expand Up @@ -757,7 +767,7 @@ def build(self):

with chdir(checkout_path):
for BP in self.buildpacks:
bp = BP()
bp = BP(base_image=self.base_image)
if bp.detect():
picked_buildpack = bp
break
Expand Down
10 changes: 7 additions & 3 deletions repo2docker/buildpacks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Only use syntax features supported by Docker 17.09
TEMPLATE = r"""
FROM buildpack-deps:focal
FROM {{base_image}}
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -204,7 +204,6 @@ class BuildPack:
Specifically used for creating Dockerfiles for use with repo2docker only.
Things that are kept constant:
- base image
- some environment variables (such as locale)
- user creation & ownership of home directory
- working directory
Expand All @@ -214,9 +213,13 @@ class BuildPack:
"""

def __init__(self):
def __init__(self, base_image):
"""
base_image specifies the base image to use when building docker images
"""
self.log = logging.getLogger("repo2docker")
self.appendix = ""
self.base_image = base_image
self.labels = {}
if sys.platform.startswith("win"):
self.log.warning(
Expand Down Expand Up @@ -516,6 +519,7 @@ def render(self, build_args=None):
appendix=self.appendix,
# For docker 17.09 `COPY --chown`, 19.03 would allow using $NBUSER
user=build_args.get("NB_UID", DEFAULT_NB_UID),
base_image=self.base_image,
)

@staticmethod
Expand Down
3 changes: 3 additions & 0 deletions repo2docker/buildpacks/legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class LegacyBinderDockerBuildPack:
This buildpack has been deprecated.
"""

def __init__(self, *args, **kwargs):
pass

def detect(self):
"""Check if current repo should be built with the Legacy BuildPack."""
log = logging.getLogger("repo2docker")
Expand Down

0 comments on commit f6fe9e0

Please sign in to comment.