Skip to content

Commit 2736bfc

Browse files
fix: fix enclave key volume binding from host
1 parent 4967551 commit 2736bfc

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

.github/workflows/reusable-api-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585

8686
- name: Prepare .env for Compose
8787
run: |
88-
printf "IMAGE_NAME=%s\nIMAGE_TAG=%s\nLOG_LEVEL=%s\n" "${{ env.IMAGE_NAME }}" "${{ inputs.tag }}" "${{ inputs.logLevel }}" > .env
88+
printf "IMAGE_NAME=%s\nIMAGE_TAG=%s\nENCLAVE_KEY_PATH=/opt/iapp-api/sig/enclave-key.pem\nLOG_LEVEL=%s\n" "${{ env.IMAGE_NAME }}" "${{ inputs.tag }}" "${{ inputs.logLevel }}" > .env
8989
shell: bash
9090

9191
- name: Copy files to remote server

api/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ services:
99
- /var/run/docker.sock:/var/run/docker.sock
1010
# .env.app already on the server
1111
- ./.env.app:/app/.env:ro
12-
# enclave key already on the server in sig/enclave-key.pem
13-
- ./sig/:/app/sig/:ro
1412
environment:
1513
- LOG_LEVEL=${LOG_LEVEL:-info}
14+
# enclave key already on the server in sig/enclave-key.pem
15+
- ENCLAVE_KEY_PATH=${ENCLAVE_KEY_PATH}
1616
healthcheck:
1717
test: ['CMD', 'curl', '-f', 'http://localhost:3000/health']
1818
interval: 30s

api/src/singleFunction/sconifyImage.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { join } from 'node:path';
2-
import { access, constants } from 'node:fs/promises';
2+
33
import Docker from 'dockerode';
44
import { SCONIFY_IMAGE_NAME } from '../constants/constants.js';
55
import { logger } from '../utils/logger.js';
@@ -10,7 +10,8 @@ import { removeContainer } from './removeContainer.js';
1010

1111
const docker = new Docker();
1212

13-
const ENCLAVE_KEY_PATH = join(process.cwd(), 'sig/enclave-key.pem');
13+
const ENCLAVE_KEY_PATH =
14+
process.env.ENCLAVE_KEY_PATH || join(process.cwd(), 'sig/enclave-key.pem');
1415

1516
/**
1617
* Sconifies an iapp docker image
@@ -47,19 +48,6 @@ export async function sconifyImage({
4748
logger.info({ sconifierImage }, 'Pulling sconifier image...');
4849
await pullSconeImage(sconifierImage);
4950

50-
if (prod) {
51-
// check signing key can be read on host
52-
try {
53-
await access(ENCLAVE_KEY_PATH, constants.R_OK);
54-
} catch (error) {
55-
logger.error(
56-
{ error, path: ENCLAVE_KEY_PATH },
57-
'Cannot read enclave key from host'
58-
);
59-
throw new Error('Cannot read enclave key from host');
60-
}
61-
}
62-
6351
const toImage = `${fromImage}-tmp-sconified-${Date.now()}`; // create an unique temporary identifier for the target image
6452
logger.info({ fromImage, toImage }, 'Sconifying...');
6553

@@ -87,7 +75,7 @@ export async function sconifyImage({
8775
: sconifyBaseCmd,
8876
HostConfig: {
8977
Binds: prod
90-
? baseBinds.concat(`${ENCLAVE_KEY_PATH}:/sig/enclave-key.pem:ro`) // mount signing key
78+
? baseBinds.concat(`${ENCLAVE_KEY_PATH}:/sig/enclave-key.pem:ro`) // mount signing key from host
9179
: baseBinds,
9280
},
9381
});

0 commit comments

Comments
 (0)