Skip to content

Commit 4f2fece

Browse files
authored
Merge pull request Huelse#62 from DreamingRaven/feature-dockerfile
Feature dockerfile re-introduction for latest code and git-submodules
2 parents 0b5f417 + 7eabf11 commit 4f2fece

File tree

3 files changed

+60
-14
lines changed

3 files changed

+60
-14
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# preventing .git files from entering context
2-
.git
32
.github

Dockerfile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:21.04
2+
3+
# define the folder where our src should exist/ be deposited
4+
ARG SRC=/python-seal
5+
6+
# prevents update and install asking for tz
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
# install dependencies
10+
RUN apt update && \
11+
apt install -y git build-essential cmake python3 python3-dev python3-pip && \
12+
mkdir -p ${SRC}
13+
14+
# copy into container requirements and install them before rest of code
15+
COPY ./requirements.txt ${SRC}/.
16+
RUN pip3 install -r ${SRC}/requirements.txt
17+
18+
# copy everything into container now that requirements stage is complete
19+
COPY . ${SRC}
20+
21+
# setting our default directory to the one specified above
22+
WORKDIR ${SRC}
23+
24+
# update submodules
25+
RUN cd ${SRC} && \
26+
git submodule update --init --recursive
27+
# git submodule update --remote
28+
29+
# build and install seal + bindings
30+
RUN cd ${SRC}/SEAL && \
31+
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF && \
32+
cmake --build build && \
33+
cd ${SRC} && \
34+
python3 setup.py build_ext -i
35+
36+
CMD ["/usr/bin/python3"]

README.md

+24-13
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ This is a python binding for the Microsoft SEAL library.
2424

2525
```shell
2626
# Optional
27-
sudo apt-get install build-essential cmake python3 python3-dev python3-pip
28-
27+
sudo apt-get install git build-essential cmake python3 python3-dev python3-pip
28+
2929
# Get the repository or download from the releases
3030
git clone https://github.com/Huelse/SEAL-Python.git
3131
cd SEAL-Python
32-
32+
3333
# Numpy is essential
3434
pip3 install -r requirements.txt
35-
35+
3636
# Init the SEAL and pybind11
3737
git submodule init && git submodule update
3838
# Get the newest repositories (unnecessary)
3939
git submodule update --remote
40-
40+
4141
# Build the SEAL lib
4242
cd SEAL
4343
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF
@@ -47,7 +47,7 @@ This is a python binding for the Microsoft SEAL library.
4747
# Run the setup.py
4848
python3 setup.py build_ext -i
4949
```
50-
50+
5151
* #### Windows
5252

5353
Visual Studio 2019 or newer is required. And use the **x64 Native Tools Command Prompt for Visual Studio 2019** command prompt to configure and build the Microsoft SEAL library. It's usually can be found in your Start Menu.
@@ -57,14 +57,26 @@ This is a python binding for the Microsoft SEAL library.
5757
# Build the SEAL library
5858
cmake -S . -B build -G Ninja -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF
5959
cmake --build build
60-
60+
6161
# Run the setup.py
6262
python setup.py build_ext -i
6363
```
64-
64+
6565
Generally, the Ninja generator is better than the "Visual Studio 16 2019" generator, and there is more information in the Microsoft SEAL official [illustrate](https://github.com/microsoft/SEAL#building-microsoft-seal-manually).
6666

6767

68+
* #### Docker
69+
requires: [Docker](https://www.docker.com/)
70+
71+
To build source code into a docker image (from this directory):
72+
```shell
73+
docker build -t huelse/seal -f Dockerfile .
74+
```
75+
76+
To use the image by running it as an interactive container:
77+
```shell
78+
docker run -it huelse/seal
79+
```
6880

6981
## Note
7082

@@ -74,7 +86,7 @@ This is a python binding for the Microsoft SEAL library.
7486

7587
```python
7688
cipher.save('cipher')
77-
89+
7890
load_cipher = Ciphertext()
7991
load_cipher.load(context, 'cipher') # work if the context is valid.
8092
```
@@ -86,10 +98,10 @@ This is a python binding for the Microsoft SEAL library.
8698
```shell
8799
# 1. Modify the serializable object's header file in SEAL and switch the wrapper.
88100
python helper.py
89-
101+
90102
# 2. Rebuild the SEAL lib like above
91103
cmake --build build
92-
104+
93105
# 3. Run the setup.py
94106
python setup.py build_ext -i
95107
```
@@ -98,7 +110,7 @@ This is a python binding for the Microsoft SEAL library.
98110

99111
```python
100112
import pickle
101-
113+
102114
cipher.set_parms(parms) # necessary
103115
cipher_dump = pickle.dumps(cipher)
104116
cipher_load = pickle.loads(cipher_dump)
@@ -142,4 +154,3 @@ This is a python binding for the Microsoft SEAL library.
142154
* Professor: [Dr. Chen](https://zhigang-chen.github.io/)
143155

144156
* [Contributors](https://github.com/Huelse/SEAL-Python/graphs/contributors)
145-

0 commit comments

Comments
 (0)