Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Create a Dockerfile #193

Merged
merged 1 commit into from
Jun 20, 2020
Merged

Create a Dockerfile #193

merged 1 commit into from
Jun 20, 2020

Conversation

ynamiki
Copy link
Contributor

@ynamiki ynamiki commented Jun 4, 2020

A Dockerfile for the example described in README.md in the project root. By using this, a user can try our project without environment setup (i.e. installing SGX SDK, build, etc.). Note that, in this container, we use the SGX simulation mode so an Intel SGX-equipped processor is not required to run.

This is a part of #163. I'll try to create another Dockerfile for the HW mode later in another PR.

@ynamiki ynamiki self-assigned this Jun 4, 2020
@ynamiki ynamiki added this to the v0.1.0 milestone Jun 4, 2020
@ynamiki ynamiki marked this pull request as ready for review June 4, 2020 23:26
Copy link
Contributor

@nhoriguchi nhoriguchi left a comment

Choose a reason for hiding this comment

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

I confirmed that the sample application properly ran in Docker container, that's nice.

One concern is that you generate copies of YAML files for docker, which might be a burden from maintenance viewpoint (imagine that if we add some new config parameters, then we might have to update two places). I think that we can use viper's function to override configs from files with environment variables, and my brief check showed that keys in peer.yaml can be overridden by environment variable PEER_KEYS. Unfortunately, peers in consensus.yaml is loaded separately from peer.yaml so we need change application code to override it with environment variable. So I don't think this should be done in this PR.

README.md Outdated Show resolved Hide resolved
sample/docker/README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,29 @@
# Docker Image #
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the title can be more descriptive like "Running sample application as Docker containers".

Copy link
Contributor

Choose a reason for hiding this comment

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

It could also be a concise title followed by some short description.

## Prerequisites ##

To try this, be sure [Docker](https://www.docker.com) (Docker Engine
and Docker Compose) are installed on your system.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first time we mention docker in this project, so it would be kind to add some basic notes on docker (I mean for example that "you need to run this as root with sudo", or "you have to check that docker service is running" or something like that) or to point to some references (Hyperledger Fabric does this). With that, we can avoid questions about docker.

sample/docker/docker-compose.yml Show resolved Hide resolved
Copy link
Contributor

@sergefdrv sergefdrv left a comment

Choose a reason for hiding this comment

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

Thanks for great work. I particularly like the way the docker file is structured with multi-stage build. I think we could also consider adding top-level make targets to build docker images and use those in the example as future work.

README.md Outdated Show resolved Hide resolved
README.md Outdated
@@ -161,6 +164,9 @@ export SGX_MODE=SIM

## Getting Started ##

Note: We have [a Docker image](sample/docker/README.md) to try this
project quickly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just mention that the following steps apply to native build, and suggest trying out Docker to get started easily? Maybe we could even make it the default option at once?

sample/docker/Dockerfile Outdated Show resolved Hide resolved
sample/docker/Dockerfile Outdated Show resolved Hide resolved
sample/docker/Dockerfile Outdated Show resolved Hide resolved
@@ -0,0 +1,29 @@
# Docker Image #
Copy link
Contributor

Choose a reason for hiding this comment

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

It could also be a concise title followed by some short description.

sample/docker/README.md Outdated Show resolved Hide resolved
sample/docker/docker-entrypoint.sh Outdated Show resolved Hide resolved
sample/docker/docker-entrypoint.sh Outdated Show resolved Hide resolved
sample/docker/docker-entrypoint.sh Outdated Show resolved Hide resolved
@ynamiki
Copy link
Contributor Author

ynamiki commented Jun 11, 2020

@Naoya-Horiguchi @sergefdrv Thanks for your many suggestions. I have update the code as well as the document. I the latest commit, I deleted sample/docker/README.md and move the contents to an new section "Quick Start" of README.md at the root with revising based on your comments.

@ynamiki
Copy link
Contributor Author

ynamiki commented Jun 11, 2020

@Naoya-Horiguchi I understand your concern. In the last commit, I tried avoiding the duplication of the config files by creating consensus.yaml dynamically; rewriting by sed based on the original sample/config/consensus.yaml.

One concern is that you generate copies of YAML files for docker, which might be a burden from maintenance viewpoint (imagine that if we add some new config parameters, then we might have to update two places). I think that we can use viper's function to override configs from files with environment variables, and my brief check showed that keys in peer.yaml can be overridden by environment variable PEER_KEYS. Unfortunately, peers in consensus.yaml is loaded separately from peer.yaml so we need change application code to override it with environment variable. So I don't think this should be done in this PR.

README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved

This quick start shows you how to runnning this project using Docker
containers. This is the easiest way to try out this project with minimal
setup. If you want to build and run without Docker, skip this section.
Copy link
Contributor

@nhoriguchi nhoriguchi Jun 15, 2020

Choose a reason for hiding this comment

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

(EDITED) Actually I like putting this new section subtree just before "Roadmap" section and inserting short notes as you did in the previous version. But this might conflict with Sergey's suggestion, so I'm fine if you decide to go with this.

README.md Outdated Show resolved Hide resolved
@ynamiki ynamiki requested a review from sergefdrv June 17, 2020 22:26
Copy link
Contributor

@sergefdrv sergefdrv left a comment

Choose a reason for hiding this comment

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

Thank you, this PR looks to me much better now! I just left some minor comments.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
@ynamiki
Copy link
Contributor Author

ynamiki commented Jun 19, 2020

@Naoya-Horiguchi @sergefdrv Thanks for comments. I have updated.

Changes from the previous revision (diffs):

  • Fix some errors in English grammar in README.
  • Add docker-clean target in Makefile to delete the image.
  • Add User option to docker-compose.yml to run the process in the container as not root but a user who has the same UID as the current user in the host. By this, the owner of keys.yaml, which is created in the container in the directory shared with host, is now the current user in the host. So we don't need sudo for deleting the file (as described in the section Tear Down). Note that, $UID is not an environment variable but a shell variable of bash, we have to pass it to docker-compose by UID=$UID docker-compose .... I have set the default value, 1000, which is the common first UID for non-root, non-system user in Ubuntu.

nhoriguchi
nhoriguchi previously approved these changes Jun 19, 2020
Copy link
Contributor

@nhoriguchi nhoriguchi left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you 👍

Copy link
Contributor

@sergefdrv sergefdrv left a comment

Choose a reason for hiding this comment

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

Sorry, I just left a couple of tiny comments.

Makefile Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
This patch includes a Dockerfile for the example described in README.md.
By using this, a user can try our project without environment setup.

Signed-off-by: Yuta Namiki <[email protected]>
@ynamiki
Copy link
Contributor Author

ynamiki commented Jun 19, 2020

Thanks for suggestions! I have updated again (diffs).

Copy link
Contributor

@sergefdrv sergefdrv left a comment

Choose a reason for hiding this comment

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

👍 Thanks!

@ynamiki ynamiki merged commit c76eb0b into hyperledger-labs:master Jun 20, 2020
@ynamiki ynamiki deleted the docker branch June 20, 2020 06:35
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants