Skip to content

Commit 899edfa

Browse files
aditijannuaditijannu
andauthored
Update Readme (#6)
* Update readme and include an example to run a converted nitro app * Update shiplift crate - virtual_size optional field of docker image attributes * Fix SALM-559 - error while building the tests-container due to changes in the dnsmaq.conf file * Review changes --------- Co-authored-by: aditijannu <[email protected]>
1 parent 8e1e27e commit 899edfa

File tree

11 files changed

+3254
-756
lines changed

11 files changed

+3254
-756
lines changed

README.md

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,74 @@ Useful links
1919

2020
Quick Start Guide
2121
--------------
22-
23-
1. Install Rust:
24-
Follow [this](https://www.rust-lang.org/tools/install) guide.
25-
26-
27-
2. Install Docker:
28-
Follow [this](https://docs.docker.com/engine/install/) guide.
29-
30-
31-
3. Set up your Nitro-enabled AWS EC2 instance:
22+
This guide allows you to build salmiac from source and convert your docker application into a one that can run in a nitro enclave.
23+
24+
1. Set up your Ubuntu based build system:
25+
- Install Rust:
26+
Follow [this](https://www.rust-lang.org/tools/install) guide.
27+
- Install Docker:
28+
Follow [this](https://docs.docker.com/engine/install/) guide to install version 24.0.x
29+
OR
30+
```bash
31+
apt-get install docker-ce=5:24.0.1-1~ubuntu.20.04~focal docker-ce-cli=5:24.0.1-1~ubuntu.20.04~focal containerd.io
32+
```
33+
- Install tools needed to build the linux kernel:
34+
Follow [this](https://kernelnewbies.org/KernelBuild) guide.
35+
- Install additional dependencies:
36+
```bash
37+
apt-get install pkg-config libclang-dev cmake libpcap-dev
38+
```
39+
40+
2. Set up your Nitro-enabled AWS EC2 instance:
3241
- Install docker on your EC2:
33-
Follow step #2
42+
Follow [this](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-docker.html) guide.
3443
- Install nitro-cli on your EC2:
3544
Follow [this](https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave-cli-install.html) guide.
3645

3746

38-
4. Build requisite docker images needed to run container converter
47+
3. Build requisite docker images needed to run container converter
3948
```bash
4049
# Run from the root of the repository
4150
# build enclave-base image
4251
cd salmiac/docker/enclave-base
4352
docker build -t enclave-base .
4453
4554
# build parent-base image
46-
cd ..//parent-base
55+
cd ../parent-base
4756
docker build -t parent-base .
4857
```
4958

50-
5. Compile container converter:
59+
4. Build the enclave kernel. This step takes a long time and needs to be done only once. The artifacts produced by this step need not be cleaned up unless the kernel config is updated.
60+
```bash
61+
cd amzn-linux-nbd
62+
./build-enclave-kernel.sh build
63+
```
64+
65+
5. Build the converter image. To produce a debug build of the converter, ensure the release flag is removed from the step below.
5166
```bash
5267
# Run from the root of the repository
5368
cd salmiac
54-
./build-converter.sh
69+
# To produce a debug build of the converter, ensure the release flag is removed from the step below.
70+
./build-converter.sh --release
71+
72+
cd docker
73+
# If a debug build of the converter was produced, use debug as an argument to the below script
74+
./build-conv-container.sh release
5575
```
5676

57-
6. Create a simple conversion request json file
77+
6. Create a simple conversion request json file (say /tmp/req.json)
78+
More details about each field of the conversion request can be found in /salmiac/api-model/src/converter.rs
5879
```javascript
5980
{
6081
"input_image": {
61-
"name": "<your application image tag>",
82+
"name": "hello-world",
6283
},
6384
"output_image": {
64-
"name": "<your output image tag>",
85+
"name": "hello-world-nitro",
6586
},
6687
"converter_options": {
67-
"debug": true
88+
"push_converted_image": false,
89+
"enable_overlay_filesystem_persistence": false
6890
},
6991
"nitro_enclaves_options": {
7092
"cpu_count": 2,
@@ -73,19 +95,19 @@ Quick Start Guide
7395
}
7496
```
7597

76-
7. Make your application Nitro VM-capable by running container converter with the file from previous step
98+
7. Make your application Nitro VM-capable by running container converter with the file from previous step.
99+
The converter by default pulls the input image and pushes the output image to remote repositories. These images are then cleaned up from the local docker cache. In our example, the output image push is disabled in the request json and to preserve the images in the docker cache, 'PRESERVE_IMAGES' environment variable is specified.
77100
```bash
78-
# Run from the root of the repository
79-
cd tools/container-converter/target/debug
80-
./container-converter --request-file <path to file from step 4>
101+
docker run --rm --name converter --user 0 --privileged -v /var/run/docker.sock:/var/run/docker.sock -e PRESERVE_IMAGES=input,result -v /tmp/req-files:/app converter --request-file /app/req.json
81102
```
82103

83-
8. Copy converted image into your EC2 instance and run the image
104+
8. Copy converted image into your EC2 instance and run the image.
105+
Note the use of the environment variable which disables the use of default certificates, which allows you to skip access to Fortanix CCM. Read more about environment variables used in salmiac here - /salmiac/ENV_VARS.md
84106
```bash
85107
# Copy your converted image from step #7 into your EC2 isntance
86108
# ...
87109
# Run copied image inside EC2
88-
docker run -it --rm --privileged -v /run/nitro_enclaves:/run/nitro_enclaves <your image name>
110+
docker run -it --rm --privileged -v /run/nitro_enclaves:/run/nitro_enclaves -e ENCLAVEOS_DISABLE_DEFAULT_CERTIFICATE=true hello-world-nitro
89111
```
90112

91113
# Contributing
@@ -122,4 +144,4 @@ this project or the open source license(s) involved.
122144

123145
# License
124146

125-
This project is primarily distributed under the terms of the Mozilla Public License (MPL) 2.0, see [LICENSE](./LICENSE) for details.
147+
This project is primarily distributed under the terms of the Mozilla Public License (MPL) 2.0, see [LICENSE](./LICENSE) for details.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
set -exo pipefail
4+
5+
clonelinux() {
6+
7+
# Clone the amazon linux kernel repository and checkout
8+
# the branch which is used for nitro enclaves
9+
# You can find out the kernel version used by nitro-enclaves
10+
# by running uname -a in a converted app. In this case, we
11+
# use version 4.14.246
12+
# For more details about supported nitro enclave kernel
13+
# versions, refer to the aws-nitro-enclaves-cli github repository.
14+
15+
if [ -d "linux" ]; then
16+
cd linux
17+
git fetch
18+
else
19+
git clone https://github.com/amazonlinux/linux.git
20+
cd linux
21+
fi
22+
23+
git checkout microvm-kernel-4.14.246-198.474.amzn2
24+
25+
}
26+
27+
buildkernel() {
28+
29+
# Copy the enclave kernel config file into the kernel repository
30+
# The original file is available here:
31+
# https://github.com/aws/aws-nitro-enclaves-cli/blob/main/blobs/x86_64/bzImage.config
32+
# The config file available in this directory has been updated to
33+
# support salmiac features.
34+
cp ../bzImage.config .config
35+
36+
# Build the enclave kernel
37+
make prepare
38+
make modules_prepare
39+
make modules -j
40+
make -j
41+
make bzImage
42+
43+
# Once build is complete, we would need a copy of the bzImage file
44+
cp ./arch/x86/boot/bzImage ../
45+
cp .config ../bzImage.config
46+
47+
cd ../
48+
}
49+
50+
cleankernel() {
51+
if [ -d "linux" ]; then
52+
rm -rf linux
53+
fi
54+
}
55+
56+
if [ $1 == "build" ]; then
57+
clonelinux;
58+
buildkernel;
59+
elif [ $1 == "clean" ]; then
60+
cleankernel;
61+
else
62+
echo "Provide input arguments - build or clean"
63+
fi
64+

0 commit comments

Comments
 (0)