Skip to content

Commit

Permalink
RFC, SQUASHME: Keep compatibility with existing Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoRoth committed Nov 20, 2021
1 parent fdac009 commit 6268155
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion repo2docker/buildpacks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def __init__(self):
self.log = logging.getLogger("repo2docker")
self.appendix = ""
self.labels = {}
self.build_src_subdir = "src/"
if sys.platform.startswith("win"):
self.log.warning(
"Windows environment detected. Note that Windows "
Expand Down Expand Up @@ -565,6 +566,8 @@ def _filter_tar(tar):
tar.gname = ""
tar.uid = int(build_args.get("NB_UID", DEFAULT_NB_UID))
tar.gid = int(build_args.get("NB_UID", DEFAULT_NB_UID))
if tar.name in ("./Dockerfile", "Dockerfile"):
return None
return tar

for src in sorted(self.get_build_script_files()):
Expand All @@ -574,7 +577,7 @@ def _filter_tar(tar):
for fname in ("repo2docker-entrypoint", "python3-login"):
tar.add(os.path.join(HERE, fname), fname, filter=_filter_tar)

tar.add(".", "src/", filter=_filter_tar)
tar.add(".", self.build_src_subdir, filter=_filter_tar)

tar.close()
tarf.seek(0)
Expand Down
4 changes: 4 additions & 0 deletions repo2docker/buildpacks/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
class DockerBuildPack(BuildPack):
"""Docker BuildPack"""

def __init__(self):
super().__init__()
self.build_src_subdir = "."

def detect(self):
"""Check if current repo should be built with the Docker BuildPack"""
return os.path.exists(self.binder_path("Dockerfile"))
Expand Down
4 changes: 2 additions & 2 deletions tests/dockerfile/binder-dir/binder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ RUN pip install --no-cache notebook

CMD "/bin/sh"

ADD /src/sayhi.sh /usr/local/bin/sayhi.sh
ADD /src/verify verify
ADD sayhi.sh /usr/local/bin/sayhi.sh
ADD verify verify

ARG NB_UID
ENV HOME /tmp
Expand Down
2 changes: 1 addition & 1 deletion tests/dockerfile/editable/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN pip install --no-cache notebook

CMD "/bin/sh"

ADD /src/change.sh /usr/local/bin/change.sh
ADD change.sh /usr/local/bin/change.sh

ARG NB_UID
ENV HOME /tmp
Expand Down
2 changes: 1 addition & 1 deletion tests/dockerfile/jupyter-stack/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jupyter/base-notebook:b4dd11e16ae4

RUN pip install there
ADD /src/verify verify
ADD verify verify
4 changes: 2 additions & 2 deletions tests/dockerfile/simple/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ RUN pip install --no-cache notebook

CMD "/bin/sh"

ADD /src/sayhi.sh /usr/local/bin/sayhi.sh
ADD /src/verify verify
ADD sayhi.sh /usr/local/bin/sayhi.sh
ADD verify verify

ARG NB_UID
ENV HOME /tmp
Expand Down

0 comments on commit 6268155

Please sign in to comment.