Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra] Prevent mounting local checkout to $SRC + clean up Dockerfiles (#1699). #1700

Merged
merged 1 commit into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions infra/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,10 @@ def _env_to_docker_args(env_list):
return sum([['-e', v] for v in env_list], [])


def _workdir_from_dockerfile(dockerfile_path):
"""Parse WORKDIR from the Dockerfile."""
WORKDIR_REGEX = re.compile(r'\s*WORKDIR\s*([^\s]+)')
def _workdir_from_dockerfile(project_name):
"""Parse WORKDIR from the Dockerfile for the given project."""
WORKDIR_REGEX = re.compile(r'\s*WORKDIR\s*(\$SRC/[^\s]+)')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the addition of $SRC needed in the regex? There are lots of Dockerfiles without $SRC in their WORKDIR command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be an elegant way to avoid WORKDIR $SRC cases, but you're right, I also avoid WORKDIR project now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example this is wrong:

>>> import helper
>>> helper._workdir_from_dockerfile('firefox')
'/src/firefox'
Should be:
'/src/mozilla-central'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah :( let me upload another fix.

dockerfile_path = _get_dockerfile_path(project_name)

with open(dockerfile_path) as f:
lines = f.readlines()
Expand Down Expand Up @@ -435,8 +436,7 @@ def build_fuzzers(args):
command += [
'-v',
'%s:%s' % (_get_absolute_path(args.source_path),
_workdir_from_dockerfile(
_get_dockerfile_path(args.project_name))),
_workdir_from_dockerfile(args.project_name)),
]
command += [
'-v', '%s:/out' % project_out_dir,
Expand Down
4 changes: 2 additions & 2 deletions projects/curl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN git clone --depth 1 https://github.com/curl/curl.git /src/curl
RUN git clone --depth 1 https://github.com/curl/curl-fuzzer.git /src/curl_fuzzer

# Use curl-fuzzer's scripts to get latest dependencies.
RUN /src/curl_fuzzer/scripts/ossfuzzdeps.sh
RUN $SRC/curl_fuzzer/scripts/ossfuzzdeps.sh

WORKDIR /src/curl_fuzzer
WORKDIR $SRC/curl_fuzzer
COPY build.sh $SRC/
2 changes: 1 addition & 1 deletion projects/envoy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
RUN apt-get update && apt-get install -y bazel

RUN git clone https://github.com/envoyproxy/envoy.git
WORKDIR /src/envoy/
WORKDIR $SRC/envoy/
COPY find_corpus.py build.sh $SRC/
2 changes: 1 addition & 1 deletion projects/grpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ RUN chmod +x ./bazel-0.10.0-installer-linux-x86_64.sh
RUN ./bazel-0.10.0-installer-linux-x86_64.sh

RUN git clone --recursive https://github.com/grpc/grpc grpc
WORKDIR /src/grpc/
WORKDIR $SRC/grpc/
COPY build.sh $SRC/