-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerfile now takes --build-arg PYTHON_VERSION={major}.{minor}
- added .dockerignore file - cleaned up Dockerfile - updated contributing.md with example
- Loading branch information
1 parent
ffc8881
commit e0446dd
Showing
3 changed files
with
56 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git | ||
/third_party |
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,56 +1,67 @@ | ||
# Pull base image. | ||
FROM python:3.7-slim-buster | ||
# Pull base image | ||
ARG PYTHON_VERSION=3.7 | ||
FROM python:${PYTHON_VERSION}-slim-buster | ||
|
||
# Set environment variables. | ||
ENV HOME /root | ||
ENV PATH "/root/bin:${PATH}" | ||
# must be redefined after FROM | ||
ARG PYTHON_VERSION=$PYTHON_VERSION | ||
ARG BAZEL_VERSION=3.2.0 | ||
ARG BAZEL_INSTALLER=bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh | ||
ARG BAZEL_DOWNLOAD_URL=https://github.com/bazelbuild/bazel/releases/download | ||
|
||
# Define working directory. | ||
WORKDIR /root | ||
# Set environment variables | ||
ENV HOME=/root | ||
ENV PROJECT_DIR="${HOME}/PyDP" | ||
ENV PATH="/root/bin:${PATH}" | ||
|
||
# Install. | ||
RUN \ | ||
apt-get update && \ | ||
apt-get -y install software-properties-common \ | ||
# Define working directory | ||
WORKDIR ${HOME} | ||
|
||
# Install apt-get packages | ||
RUN apt-get update && \ | ||
apt-get -y install \ | ||
sudo \ | ||
wget \ | ||
unzip \ | ||
zip \ | ||
git \ | ||
software-properties-common \ | ||
gcc \ | ||
g++ \ | ||
build-essential \ | ||
python3-distutils \ | ||
pkg-config \ | ||
zip \ | ||
zlib1g-dev \ | ||
git && \ | ||
wget https://github.com/bazelbuild/bazel/releases/download/2.1.0/bazel-2.1.0-installer-linux-x86_64.sh && \ | ||
chmod +x bazel-2.1.0-installer-linux-x86_64.sh && \ | ||
./bazel-2.1.0-installer-linux-x86_64.sh --user && \ | ||
export PATH="$PATH:$HOME/bin" && \ | ||
rm bazel-2.1.0-installer-linux-x86_64.sh | ||
zlib1g-dev | ||
|
||
# get third-party dependencies | ||
WORKDIR /tmp/third_party | ||
# Download and Install Bazel | ||
RUN wget ${BAZEL_DOWNLOAD_URL}/${BAZEL_VERSION}/${BAZEL_INSTALLER} && \ | ||
chmod +x ${BAZEL_INSTALLER} && ./${BAZEL_INSTALLER} --user && rm ${BAZEL_INSTALLER} | ||
|
||
RUN git clone https://github.com/google/differential-privacy.git | ||
RUN pip3 install pipenv | ||
# Update pip and setuptools and install pipenv | ||
RUN pip install --upgrade pip setuptools wheel && \ | ||
pip install pipenv | ||
|
||
WORKDIR /root/PyDP | ||
COPY . /root/PyDP | ||
# Change working dir | ||
WORKDIR ${PROJECT_DIR} | ||
|
||
RUN rm -rf third_party/differential-privacy/ && \ | ||
cp -r /tmp/third_party/* /root/PyDP/third_party | ||
# Copy local source over | ||
COPY . ${PROJECT_DIR} | ||
|
||
# Get google dp dependency | ||
RUN mkdir -p third_party && \ | ||
cd third_party && \ | ||
git clone https://github.com/google/differential-privacy.git | ||
|
||
# Remove unused java code | ||
RUN rm -rf third_party/differential-privacy/java && \ | ||
rm -rf third_party/differential-privacy/examples/java | ||
|
||
# build the bindings using Bazel and create a fresh wheel file after deleting the old one in dist folder. | ||
RUN \ | ||
pipenv run bazel build src/python:bindings_test --verbose_failures && \ | ||
cp -f ./bazel-bin/src/bindings/pydp.so ./pydp && \ | ||
# Build the bindings using Bazel and create a python wheel | ||
RUN pipenv --python ${PYTHON_VERSION} && \ | ||
pipenv run bazel build src/python:bindings_test --verbose_failures | ||
|
||
RUN cp -f ./bazel-bin/src/bindings/pydp.so ./pydp && \ | ||
rm -rf dist/ && \ | ||
pipenv run python3 setup.py bdist_wheel && \ | ||
pip3 install dist/*.whl | ||
pipenv run python setup.py bdist_wheel && \ | ||
pip install dist/*.whl | ||
|
||
# Define default command. | ||
CMD ["bash"] | ||
# Default entrypoint | ||
CMD ["/bin/bash"] |
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