Skip to content

Commit 868271d

Browse files
authored
PCCS service containerization with non-interactive configuration (#191)
PCCS service containerization with non-interactive configuration Signed-off-by: Dmitrii Puzikov <dmitriix.puzikov@intel.com>
1 parent 65eb9c9 commit 868271d

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Dockerfile
2+
.dockerignore
3+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM ubuntu:20.04 AS builder
2+
3+
# DCAP version (github repo branch, tag or commit hash)
4+
ARG DCAP_VERSION=DCAP_1.12
5+
6+
# update and install packages
7+
RUN DEBIAN_FRONTEND=noninteractive \
8+
apt-get update -yq && \
9+
apt-get upgrade -yq && \
10+
apt-get install -yq --no-install-recommends \
11+
build-essential \
12+
ca-certificates \
13+
curl \
14+
git \
15+
zip
16+
17+
# install node.js
18+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
19+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends nodejs
20+
21+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
22+
23+
# clone DCAP repo
24+
RUN git clone https://github.com/intel/SGXDataCenterAttestationPrimitives.git -b ${DCAP_VERSION} --depth 1
25+
26+
# set PWD to PCKCertSelection dir
27+
WORKDIR /SGXDataCenterAttestationPrimitives/tools/PCKCertSelection/
28+
29+
# build libPCKCertSelection library and copy to lib folder
30+
RUN make && \
31+
mkdir -p ../../QuoteGeneration/pccs/lib && \
32+
cp ./out/libPCKCertSelection.so ../../QuoteGeneration/pccs/lib/ && \
33+
make clean
34+
35+
# set PWD to PCCS dir
36+
WORKDIR /SGXDataCenterAttestationPrimitives/QuoteGeneration/pccs/
37+
38+
# build pccs
39+
RUN npm config set proxy $http_proxy && \
40+
npm config set http-proxy $http_proxy && \
41+
npm config set https-proxy $https_proxy && \
42+
npm config set engine-strict true && \
43+
npm ci
44+
45+
# build final image
46+
FROM ubuntu:20.04
47+
48+
ARG USER=pccs
49+
ARG UID=65333
50+
51+
# create user and a group
52+
RUN useradd -M -U ${USER} --uid=${UID} -s /bin/false
53+
54+
COPY --from=builder /usr/bin/node /usr/bin/node
55+
COPY --from=builder --chown=${USER}:${USER} /SGXDataCenterAttestationPrimitives/QuoteGeneration/pccs/ /opt/intel/pccs/
56+
57+
WORKDIR /opt/intel/pccs/
58+
USER ${USER}
59+
60+
# entrypoint to start pccs
61+
ENTRYPOINT ["/usr/bin/node", "-r", "esm", "pccs_server.js"]
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
## 1. Build container image
2+
```
3+
docker build -t pccs:my_tag .
4+
```
5+
6+
## 2. Generate certificates to use with PCCS
7+
```
8+
mkdir -p ~/pccs_tls
9+
cd ~/pccs_tls
10+
openssl genrsa -out private.pem 2048
11+
openssl req -new -key private.pem -out csr.pem
12+
openssl x509 -req -days 365 -in csr.pem -signkey private.pem -out file.crt
13+
rm -rf csr.pem
14+
```
15+
and give read access to the certificate/key in order they're to be readable inside container by user other than host files owner:
16+
```
17+
chmod 644 ~/pccs_tls/*
18+
```
19+
20+
## 3. Fill up configuration file
21+
Create directory for storing configuration file:
22+
```
23+
mkdir -p ~/config
24+
```
25+
Copy `<path_to_repo>/SGXDataCenterAttestationPrimitives/QuoteGeneration/pccs/config/default.json`
26+
to this directory:
27+
```
28+
cp <path_to_repo>/SGXDataCenterAttestationPrimitives/QuoteGeneration/pccs/config/default.json ~/config/
29+
```
30+
Generate UserTokenHash:
31+
```
32+
echo -n "user_password" | sha512sum | tr -d '[:space:]-'
33+
```
34+
and AdminTokenHash:
35+
```
36+
echo -n "admin_password" | sha512sum | tr -d '[:space:]-'
37+
```
38+
and paste generated values into the `~/config/default.json`
39+
40+
Fill other required fields accordingly.
41+
42+
## 4. Run container
43+
```
44+
cd && \
45+
docker run \
46+
--user "65333:0" \
47+
-v $PWD/pccs_tls/private.pem:/opt/intel/pccs/ssl_key/private.pem \
48+
-v $PWD/pccs_tls/file.crt:/opt/intel/pccs/ssl_key/file.crt \
49+
-v $PWD/config/default.json:/opt/intel/pccs/config/default.json \
50+
-p 8081:8081 --name pccs -d pccs:my_tag
51+
```
52+
53+
## 5 . Check if pccs service is running and available:
54+
```
55+
docker logs -f pccs
56+
```
57+
58+
Output:
59+
60+
```
61+
2021-08-01 20:54:24.700 [info]: DB Migration -- Update pcs_version table
62+
2021-08-01 20:54:24.706 [info]: DB Migration -- update pck_crl.pck_crl from HEX string to BINARY
63+
2021-08-01 20:54:24.709 [info]: DB Migration -- update pcs_certificates.crl from HEX string to BINARY
64+
2021-08-01 20:54:24.711 [info]: DB Migration -- update platforms(platform_manifest,enc_ppid) from HEX string to BINARY
65+
2021-08-01 20:54:24.713 [info]: DB Migration -- update platforms_registered(platform_manifest,enc_ppid) from HEX string to BINARY
66+
2021-08-01 20:54:24.715 [info]: DB Migration -- Done.
67+
2021-08-01 20:54:24.831 [info]: HTTPS Server is running on: https://localhost:8081
68+
69+
```
70+
71+
Execute command:
72+
```
73+
curl -kv https://localhost:8081
74+
```
75+
to check if pccs service is available.
76+
77+
## 6. Stop container:
78+
```
79+
docker stop pccs
80+
```
81+

0 commit comments

Comments
 (0)