Skip to content

Commit 60c4016

Browse files
authored
Add Dockerfile variant for building virtual app (#7)
1 parent 694d731 commit 60c4016

File tree

6 files changed

+76
-6
lines changed

6 files changed

+76
-6
lines changed

.github/workflows/ci.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,16 @@ jobs:
1818
- name: Build app
1919
run: mkdir -p build && cd build && CC="/opt/oe_lvi/clang-10" CXX="/opt/oe_lvi/clang++-10" cmake -GNinja .. && ninja
2020

21-
- name: Build container
22-
run: docker build -t ccf-app-template .
21+
build-containers:
22+
runs-on: ubuntu-20.04
23+
container: mcr.microsoft.com/ccf/app/dev:lts-devcontainer
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v3
28+
29+
- name: Build enclave container
30+
run: docker build -t ccf-app-template:enclave -f docker/ccf_app.enclave .
31+
32+
- name: Build virtual container
33+
run: docker build -t ccf-app-template:virtual -f docker/ccf_app.virtual .

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,20 @@ $ curl https://127.0.0.1:8000/app/log?id=1 --cacert ./workspace/sandbox_common/s
6767
It is possible to build a runtime image of this application via docker:
6868

6969
```bash
70-
$ docker build -t ccf-app-template .
71-
$ docker run --device /dev/sgx_enclave:/dev/sgx_enclave --device /dev/sgx_provision:/dev/sgx_provision -v /dev/sgx:/dev/sgx ccf-app-template
70+
$ docker build -t ccf-app-template:enclave -f docker/ccf_app.enclave .
71+
$ docker run --device /dev/sgx_enclave:/dev/sgx_enclave --device /dev/sgx_provision:/dev/sgx_provision -v /dev/sgx:/dev/sgx ccf-app-template:enclave
7272
...
7373
2022-01-01T12:00:00.000000Z -0.000 0 [info ] ../src/node/node_state.h:1790 | Network TLS connections now accepted
7474
# It is then possible to interact with the service
7575
```
7676

77+
Or, for the non-SGX (a.k.a. virtual) variant:
78+
79+
```bash
80+
$ docker build -t ccf-app-template:virtual -f docker/ccf_app.virtual .
81+
$ docker run ccf-app-template:virtual
82+
```
83+
7784
## Dependencies
7885

7986
If this repository is checked out on a bare VM (e.g. [for SGX deployments](https://docs.microsoft.com/en-us/azure/confidential-computing/quick-create-portal)), the dependencies required to build and run the CCF app can be installed as follows:
File renamed without changes.

config/cchost_config_virtual.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"enclave": {
3+
"file": "/app/libccf_app.virtual.so",
4+
"type": "Virtual"
5+
},
6+
"network": {
7+
"node_to_node_interface": { "bind_address": "127.0.0.1:8081" },
8+
"rpc_interfaces": {
9+
"main_interface": {
10+
"bind_address": "0.0.0.0:8080"
11+
}
12+
}
13+
},
14+
"command": {
15+
"type": "Start",
16+
"service_certificate_file": "/app/service_cert.pem",
17+
"start": {
18+
"constitution_files": [
19+
"/app/validate.js",
20+
"/app/apply.js",
21+
"/app/resolve.js",
22+
"/app/actions.js"
23+
],
24+
"members": [
25+
{
26+
"certificate_file": "/app/member0_cert.pem",
27+
"encryption_public_key_file": "/app/member0_enc_pubk.pem"
28+
}
29+
]
30+
}
31+
}
32+
}

Dockerfile docker/ccf_app.enclave

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ FROM mcr.microsoft.com/ccf/app/run:2.0.7-sgx
1111
COPY --from=builder /build/libccf_app.enclave.so.signed /app/
1212
COPY --from=builder /opt/ccf/bin/*.js /app/
1313
COPY --from=builder /opt/ccf/bin/keygenerator.sh /app/
14-
COPY ./config/cchost_config.json /app/
14+
COPY ./config/cchost_config_enclave.json /app/
1515
WORKDIR /app/
1616
RUN /app/keygenerator.sh --name member0 --gen-enc-key
1717

1818
EXPOSE 8080/tcp
1919

20-
CMD ["/usr/bin/cchost", "--config", "/app/cchost_config.json"]
20+
CMD ["/usr/bin/cchost", "--config", "/app/cchost_config_enclave.json"]

docker/ccf_app.virtual

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build
2+
FROM mcr.microsoft.com/ccf/app/dev:2.0.7-sgx as builder
3+
COPY . /src
4+
RUN mkdir -p /build/
5+
WORKDIR /build/
6+
RUN CC="/opt/oe_lvi/clang-10" CXX="/opt/oe_lvi/clang++-10" cmake -GNinja /src && ninja
7+
8+
# Run
9+
FROM mcr.microsoft.com/ccf/app/run:2.0.7-sgx
10+
11+
COPY --from=builder /build/libccf_app.virtual.so /app/
12+
COPY --from=builder /opt/ccf/bin/*.js /app/
13+
COPY --from=builder /opt/ccf/bin/keygenerator.sh /app/
14+
COPY ./config/cchost_config_virtual.json /app/
15+
WORKDIR /app/
16+
RUN /app/keygenerator.sh --name member0 --gen-enc-key
17+
18+
EXPOSE 8080/tcp
19+
20+
CMD ["/usr/bin/cchost", "--config", "/app/cchost_config_virtual.json"]

0 commit comments

Comments
 (0)