-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run CI builds as non-root user (#293)
It's useful to run the test suite as some arbitrary uid so that the runner has realistic file permissions constraints.
- Loading branch information
Showing
5 changed files
with
29 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
# Start with ubuntu:18.04 plus some apt packages | ||
# builds docker image for running test suite for the contextual miniwdl source tree | ||
# docker build -t miniwdl . | ||
# run the full test suite -- notice configuration needed for it to command the host dockerd | ||
# docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock --group-add $(stat -c %g /var/run/docker.sock) -v /tmp:/tmp miniwdl | ||
# or append 'bash' to that to enter interactive shell | ||
|
||
# start with ubuntu:18.04 plus some apt packages | ||
FROM ubuntu:18.04 | ||
ENV LC_ALL C.UTF-8 | ||
ENV LANG C.UTF-8 | ||
RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y \ | ||
python3 python3-pip python3-setuptools tzdata wget zip git-core \ | ||
default-jre jq graphviz shellcheck docker.io | ||
# pip install the requirements files for run & dev | ||
COPY requirements.txt requirements.dev.txt /miniwdl/ | ||
RUN bash -o pipefail -c "pip3 install --user -r <(cat /miniwdl/requirements.txt /miniwdl/requirements.dev.txt)" | ||
# Copy in the local source tree / build context. We've delayed this until after | ||
# requirements so that docker build doesn't reinstall the pip packages on every | ||
# minor source change. | ||
ADD . /miniwdl | ||
python3-pip python3-setuptools tzdata wget zip git-core default-jre jq shellcheck docker.io | ||
|
||
# add and become 'wdler' user -- it's useful to run the test suite as some arbitrary uid, because | ||
# the runner has numerous file permissions-related constraints | ||
RUN useradd -ms /bin/bash -u 1337 wdler | ||
USER wdler | ||
|
||
# pip install the requirements files -- we do this before adding the rest of the source tree, so | ||
# that docker build doesn't have to reinstall the pip packages for every minor source change | ||
COPY requirements.txt requirements.dev.txt /home/wdler/ | ||
RUN bash -o pipefail -c "pip3 install --user -r <(cat /home/wdler/requirements.txt /home/wdler/requirements.dev.txt)" | ||
|
||
# add the source tree | ||
ADD --chown=wdler:wdler . /miniwdl | ||
WORKDIR /miniwdl | ||
ENV PYTHONPATH $PYTHONPATH:/root/.local/lib/python3.6 | ||
ENV PATH $PATH:/root/.local/bin | ||
# will trigger typechecking & tests: | ||
|
||
# finishing touches | ||
ENV PYTHONPATH $PYTHONPATH:/home/wdler/.local/lib/python3.6 | ||
ENV PATH $PATH:/home/wdler/.local/bin | ||
CMD make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -747,6 +747,7 @@ def test_runtime_memory(self): | |
>>> | ||
runtime { | ||
memory: "~{memory}" | ||
disks: "ignored" | ||
} | ||
} | ||
""" | ||
|