Skip to content

Commit e88ddda

Browse files
authored
Update to ccf 5.0.0 (#25)
1 parent 575c6d0 commit e88ddda

File tree

9 files changed

+35
-34
lines changed

9 files changed

+35
-34
lines changed

.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-virtual
1+
FROM ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0
22

33
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - && sudo apt-get install -y nodejs

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build-cpp-app-sgx:
1111
runs-on: ubuntu-20.04
12-
container: mcr.microsoft.com/ccf/app/dev:4.0.14-sgx
12+
container: ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0
1313

1414
steps:
1515
- name: Checkout repository
@@ -21,7 +21,7 @@ jobs:
2121

2222
build-cpp-app-virtual:
2323
runs-on: ubuntu-20.04
24-
container: mcr.microsoft.com/ccf/app/dev:4.0.14-virtual
24+
container: ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0
2525

2626
steps:
2727
- name: Checkout repository
@@ -33,7 +33,7 @@ jobs:
3333

3434
build-containers:
3535
runs-on: ubuntu-20.04
36-
container: mcr.microsoft.com/ccf/app/dev:4.0.14-sgx
36+
container: ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0
3737

3838
steps:
3939
- name: Checkout repository

README.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Template repository for JavaScript and C++ CCF applications.
66

7-
Note: For complete sample apps, see https://github.com/microsoft/ccf-app-samples.
7+
Note: For complete sample apps, see https://github.com/microsoft/ccf-app-samples.
88

99
## Quickstart
1010

11-
The quickest way to build and run this sample CCF app is to checkout this repository locally in its development container by clicking:
11+
The quickest way to build and run this sample CCF app is to checkout this repository locally in its development container by clicking:
1212
[![Open in VSCode](https://img.shields.io/static/v1?label=Open+in&message=VSCode&logo=visualstudiocode&color=007ACC&logoColor=007ACC&labelColor=2C2C32)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/ccf-app-template)
1313

1414
All dependencies will be automatically installed (takes ~2 mins on first checkout).
@@ -85,29 +85,28 @@ To start a test CCF network on a Linux environment, it requires [CCF to be intal
8585
# Start the CCF network using the cchost in
8686

8787
# Enclave mode
88-
/opt/ccf/bin/cchost --config ./config/cchost_config_enclave_js.json
88+
/opt/ccf_sgx/bin/cchost --config ./config/cchost_config_enclave_js.json
8989

9090
# Or Virtual mode
91-
/opt/ccf/bin/cchost --config ./config/cchost_config_virtual_js.json
91+
/opt/ccf_virtual/bin/cchost --config ./config/cchost_config_virtual_js.json
9292
...
9393

9494
# Now the CCF network is started and further initialization needed before the interaction with the service
9595
```
9696

9797
The CCF network is started with one node and one member, please follow the [same governance steps as Docker](#network-governance) to initialize the network and check [CCF node config file documentation](https://microsoft.github.io/CCF/main/operations/configuration.html)
9898

99-
10099
### Managed CCF
101100

102-
The application can be tested using [Azure Managed CCF](https://techcommunity.microsoft.com/t5/azure-confidential-computing/microsoft-introduces-preview-of-azure-managed-confidential/ba-p/3648986) ``(Pre-release phase)``, you can create Azure Managed CCF service on your subscription, that will give you a ready CCF network
101+
The application can be tested using [Azure Managed CCF](https://techcommunity.microsoft.com/t5/azure-confidential-computing/microsoft-introduces-preview-of-azure-managed-confidential/ba-p/3648986) `(Pre-release phase)`, you can create Azure Managed CCF service on your subscription, that will give you a ready CCF network
103102

104103
- First, create the network's initial member certificate, please check [Certificates generation](https://microsoft.github.io/CCF/main/governance/adding_member.html)
105104
- Create a new Azure Managed CCF service (the initial member certificate required as input)
106105
- Build the application and [create a deployment proposal](https://microsoft.github.io/CCF/main/build_apps/js_app_bundle.html#deployment)
107106
- Deploy the application proposal, [using governance calls](https://microsoft.github.io/CCF/main/governance/proposals.html#creating-a-proposal)
108107
- Create and submit [an add users proposal](https://microsoft.github.io/CCF/main/governance/proposals.html#creating-a-proposal)
109108

110-
## <img src="https://user-images.githubusercontent.com/42961061/191275172-24269bf0-bb9c-402d-8900-2d589582a781.png" height=50px></img> C++
109+
## <img src="https://user-images.githubusercontent.com/42961061/191275172-24269bf0-bb9c-402d-8900-2d589582a781.png" height=50px></img> C++
111110

112111
CCF apps can also be written in C++. This offers better performance than JavaScript apps but requires a compilation step and a restart of the CCF node for deployment.
113112

@@ -175,13 +174,15 @@ $ docker run ccf-app-template:cpp-virtual
175174
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 C++ app can be installed as follows:
176175

177176
```bash
178-
$ wget https://github.com/microsoft/CCF/releases/download/ccf-4.0.14/ccf_virtual_4.0.14_amd64.deb
179-
$ sudo dpkg -i ccf_virtual_4.0.14_amd64.deb # Install CCF under /opt/ccf
180-
$ cat /opt/ccf_virtual/share/VERSION_LONG
181-
ccf-4.0.14
182-
$ /opt/ccf/getting_started/setup_vm/run.sh /opt/ccf/getting_started/setup_vm/app-dev.yml # Install dependencies
177+
$ wget https://github.com/microsoft/CCF/releases/download/ccf-5.0.0/ccf_sgx_5.0.0_amd64.deb
178+
$ sudo dpkg -i ccf_sgx_5.0.0_amd64.deb # Install CCF under /opt/ccf_sgx
179+
$ cat /opt/ccf_sgx/share/VERSION_LONG
180+
ccf-5.0.0
181+
$ /opt/ccf_sgx/getting_started/setup_vm/run.sh /opt/ccf_sgx/getting_started/setup_vm/app-dev.yml # Install dependencies
183182
```
184183

184+
For a non-SGX VM, replace `ccf_sgx` in all the commands above with `ccf_virtual`.
185+
185186
See the [CCF official docs](https://microsoft.github.io/CCF/main/build_apps/install_bin.html#install-ccf) for more info and [Modern JavaScript application development](https://microsoft.github.io/CCF/main/build_apps/js_app_bundle.html).
186187

187188
## Code Tour

cpp/app/app.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace app
1313
{
1414
// Key-value store types
15-
using Map = kv::Map<size_t, std::string>;
15+
using Map = ccf::kv::Map<size_t, std::string>;
1616
static constexpr auto RECORDS = "records";
1717

1818
// API types
@@ -31,7 +31,7 @@ namespace app
3131
class AppHandlers : public ccf::UserEndpointRegistry
3232
{
3333
public:
34-
AppHandlers(ccfapp::AbstractNodeContext& context) :
34+
AppHandlers(ccf::AbstractNodeContext& context) :
3535
ccf::UserEndpointRegistry(context)
3636
{
3737
openapi_info.title = "CCF Sample C++ App";
@@ -42,11 +42,11 @@ namespace app
4242

4343
auto write = [this](auto& ctx, nlohmann::json&& params) {
4444
const auto parsed_query =
45-
http::parse_query(ctx.rpc_ctx->get_request_query());
45+
ccf::http::parse_query(ctx.rpc_ctx->get_request_query());
4646

4747
std::string error_reason;
4848
size_t id = 0;
49-
if (!http::get_query_value(parsed_query, "id", id, error_reason))
49+
if (!ccf::http::get_query_value(parsed_query, "id", id, error_reason))
5050
{
5151
return ccf::make_error(
5252
HTTP_STATUS_BAD_REQUEST,
@@ -76,11 +76,11 @@ namespace app
7676

7777
auto read = [this](auto& ctx, nlohmann::json&& params) {
7878
const auto parsed_query =
79-
http::parse_query(ctx.rpc_ctx->get_request_query());
79+
ccf::http::parse_query(ctx.rpc_ctx->get_request_query());
8080

8181
std::string error_reason;
8282
size_t id = 0;
83-
if (!http::get_query_value(parsed_query, "id", id, error_reason))
83+
if (!ccf::http::get_query_value(parsed_query, "id", id, error_reason))
8484
{
8585
return ccf::make_error(
8686
HTTP_STATUS_BAD_REQUEST,
@@ -112,11 +112,11 @@ namespace app
112112
};
113113
} // namespace app
114114

115-
namespace ccfapp
115+
namespace ccf
116116
{
117117
std::unique_ptr<ccf::endpoints::EndpointRegistry> make_user_endpoints(
118-
ccfapp::AbstractNodeContext& context)
118+
ccf::AbstractNodeContext& context)
119119
{
120120
return std::make_unique<app::AppHandlers>(context);
121121
}
122-
} // namespace ccfapp
122+
} // namespace ccf

docker/ccf_app_cpp.enclave

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Build
2-
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-sgx as builder
2+
FROM ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0 as builder
33
COPY ./cpp /cpp
44
RUN mkdir -p /build/
55
WORKDIR /build/
66
RUN CC="clang-11" CXX="clang++-11" cmake -DCOMPILE_TARGET=sgx -GNinja /cpp && ninja
77

88
# Run
9-
FROM mcr.microsoft.com/ccf/app/run:4.0.14-sgx
9+
FROM ghcr.io/microsoft/ccf/app/run/sgx:ccf-5.0.0
1010

1111
COPY --from=builder /build/libccf_app.enclave.so.signed /app/
1212
COPY --from=builder /opt/ccf_sgx/bin/*.js /app/

docker/ccf_app_cpp.virtual

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Build
2-
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-virtual as builder
2+
FROM ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0 as builder
33
COPY ./cpp /cpp
44
RUN mkdir -p /build/
55
WORKDIR /build/
66
RUN CC="clang-15" CXX="clang++-15" cmake -GNinja -DCOMPILE_TARGET=virtual /cpp && ninja
77

88
# Run
9-
FROM mcr.microsoft.com/ccf/app/run:4.0.14-virtual
9+
FROM ghcr.io/microsoft/ccf/app/run/virtual:ccf-5.0.0
1010

1111
COPY --from=builder /build/libccf_app.virtual.so /app/
1212
COPY --from=builder /opt/ccf_virtual/bin/*.js /app/

docker/ccf_app_js.enclave

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Build
2-
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-sgx as builder
2+
FROM ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0 as builder
33

44
# Run
5-
FROM mcr.microsoft.com/ccf/app/run-js:4.0.14-sgx
5+
FROM ghcr.io/microsoft/ccf/app/run-js/sgx:ccf-5.0.0
66

77
COPY --from=builder /opt/ccf_sgx/bin/*.js /app/
88
COPY --from=builder /opt/ccf_sgx/bin/keygenerator.sh /app/

docker/ccf_app_js.virtual

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Build
2-
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-virtual as builder
2+
FROM ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0 as builder
33

44
# Run
5-
FROM mcr.microsoft.com/ccf/app/run-js:4.0.14-virtual
5+
FROM ghcr.io/microsoft/ccf/app/run-js/virtual:ccf-5.0.0
66

77
# Note: libjs_generic.virtual is not included in run-js container
88
COPY --from=builder /opt/ccf_virtual/lib/libjs_generic.virtual.so /usr/lib/ccf

js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"node": ">=14"
1111
},
1212
"dependencies": {
13-
"@microsoft/ccf-app": "^4.0.14"
13+
"@microsoft/ccf-app": "^5.0.0"
1414
},
1515
"devDependencies": {
1616
"@rollup/plugin-commonjs": "^17.1.0",

0 commit comments

Comments
 (0)