initial docker development setup

pull/826/head
Damon C 2019-03-12 17:31:49 -07:00
parent 52a4aaffbd
commit e70d781ccb
13 changed files with 199 additions and 13 deletions

View File

@ -81,6 +81,8 @@ and accept bug reports.
If you're interested in contributing code, please check out our [Contribution Guide](https://docs.nucypher.com/en/latest/guides/contribution_guide.html)
and browse our [Open Issues](https://github.com/nucypher/nucypher/issues) for potential areas to contribute.
Get up and running quickly by using our [docker development setup](dev/docker/README.md)
# Security
If you identify vulnerabilities with _any_ nucypher code, please email security@nucypher.com with relevant information to your findings.
@ -98,3 +100,4 @@ Please see our [documentation](https://docs.nucypher.com) to get started.
We ask that you please respect testnet machines and their owners.
If you find a vulnerability that you suspect has given you access to a machine against the owner's permission, stop what you're doing and immediately email security@nucypher.com.

61
dev/docker/3-ursulas.yml Normal file
View File

@ -0,0 +1,61 @@
version: '3'
# runs 3 ursulas, each on a different "host", similar to real world
# similar to real world conditions
# ex. docker-compose -f 3-ursulas.yml up
services:
nucypher-dev:
volumes:
- ../..:/code
ports:
- 11500
build:
context: ../..
dockerfile: dev/docker/Dockerfile
image: dev:nucypher
container_name: nucypher-dev
ursula1:
volumes:
- ../..:/code
ports:
- 11500
image: dev:nucypher
command: nucypher ursula run --dev --federated-only --rest-host 172.28.1.1 --rest-port 11500
networks:
nucypher_net:
ipv4_address: 172.28.1.1
container_name: ursula1
ursula2:
volumes:
- ../..:/code
ports:
- 11500
image: dev:nucypher
depends_on:
- ursula1
command: nucypher ursula run --dev --federated-only --rest-host 172.28.1.2 --rest-port 11500 --teacher-uri 172.28.1.1:11500
networks:
nucypher_net:
ipv4_address: 172.28.1.2
container_name: ursula2
ursula3:
volumes:
- ../..:/code
ports:
- 11500
image: dev:nucypher
depends_on:
- ursula1
command: nucypher ursula run --dev --federated-only --rest-host 172.28.1.3 --rest-port 11500 --teacher-uri 172.28.1.1:11500
networks:
nucypher_net:
ipv4_address: 172.28.1.3
container_name: ursula3
networks:
nucypher_net:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16

20
dev/docker/Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM python:3.7.0
ENV PYTHONUNBUFFERED 1
# Update
RUN apt update -y && apt upgrade -y && apt install gcc libffi-dev wget git -y
EXPOSE 11500
RUN mkdir /code
WORKDIR /code
ADD . /code
# install reqs and solc
RUN pip install --upgrade pip \
&& pip install pipenv \
&& pip3 install -r dev-requirements.txt --src /usr/local/src \
&& ./scripts/installation/install_solc.sh
# finish install with some local volume ops
CMD ["./dev/docker/scripts/install/entrypoint.sh"]

34
dev/docker/Dockerfile-pg Normal file
View File

@ -0,0 +1,34 @@
FROM postgres:latest
ENV PYTHONUNBUFFERED 1
# Update
RUN apt update -y && apt upgrade -y
RUN apt install gcc libffi-dev wget git -y
USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'nucypher';" &&\
createdb -O nucypher nucypher
USER root
# Expose port range
EXPOSE 11500
RUN mkdir /code
WORKDIR /code
ADD . /code/
# pip stuff
RUN pip install --upgrade pip
RUN pip install pipenv
# pip install
RUN pipenv install --dev --system
RUN pip3 install -e .
RUN ./scripts/install_solc.sh
# will rarely get run.
CMD ["echo", "Ursula up"]

34
dev/docker/README.md Normal file
View File

@ -0,0 +1,34 @@
### Developing with Docker
The intention of the Docker configurations in this directory is to enable anyone to develop and test NuCypher on all major operating systems with minimal prerequisites and installation hassle.
#### quickstart
* install [Docker](https://docs.docker.com/install/)
* install [Docker Compose](https://docs.docker.com/compose/install/)
* cd to dev/docker (where this README is located)
* `docker-compose up` **this must be done once to complete install**
Then you can do things like:
* run the tests:
`docker run -it dev:nucypher pytest`
* start up an ursula:
`docker run -it dev:nucypher nucypher ursula run --dev --federated-only"`
* open a shell:
`docker run -it dev:nucypher bash`
* try some of the scripts in `dev/docker/scripts/`
**tested on (Ubuntu 16, MacOS 10.14, Windows 10)*
From there you can develop, modify code, test as normal.
### other cases
* run a network of three independent Ursulas
`docker-compose -f 3-ursulas.yml up`
* get the local ports these ursulas will be exposed on
`docker ps`
* to stop them...
`docker-compose -f 3-ursulas.yml stop`

View File

@ -0,0 +1,13 @@
version: '3'
services:
nucypher-dev:
volumes:
- ../..:/code
ports:
- 11500
build:
context: ../..
dockerfile: dev/docker/Dockerfile
image: dev:nucypher
container_name: nucypher-dev

View File

@ -0,0 +1,11 @@
#!/bin/bash
# runs inside docker container with access to local volume.
# this is needed for local development
# so that the local repository is accessed
# by shared volume and is executable by 'nucypher' cli
if [ ! -e /code/nucypher.egg-info ]; then
echo "First time install..."
pip3 install -e .
fi

View File

@ -0,0 +1 @@
docker-compose run --entrypoint "bash" nucypher-dev

2
dev/docker/scripts/shell.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
docker run -it dev:nucpyher bash

View File

@ -0,0 +1 @@
docker run -it dev:nucypher pytest $args

3
dev/docker/scripts/test.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
args="$@"
docker run -it dev:nucpyher pytest $args

View File

@ -0,0 +1 @@
docker run -it dev:nucypher nucypher ursula run --dev --federated-only

2
dev/docker/scripts/ursula.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
docker run -it dev:nucypher nucypher ursula run --dev --federated-only