-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85e6cd0
commit 0ef7251
Showing
10 changed files
with
387 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Publishes the latest version of edb-connect to the Azure Container Registry | ||
# Users will then have access to this latest version when they run the edb-connect.sh script on the node VMs. | ||
|
||
name: "[M] Publish EDB Connect" | ||
run-name: "[M] Publish EDB Connect" | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: "Set up Docker" | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: "Login to Azure docker registry" | ||
uses: azure/docker-login@v1 | ||
with: | ||
login-server: testnetobscuronet.azurecr.io | ||
username: testnetobscuronet | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
- name: "Login via Azure CLI" | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Build and Push Docker EDB Connect Image | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_EDB_CONNECT }} -f ./tools/edbconnect/Dockerfile . | ||
docker push ${{ vars.DOCKER_BUILD_TAG_EDB_CONNECT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Build Stages: | ||
# build-base = downloads modules and prepares the directory for compilation. Based on the ego-dev image | ||
# build-enclave = copies over the actual source code of the project and builds it using a compiler cache | ||
# deploy = copies over only the enclave executable without the source | ||
# in a lightweight base image specialized for deployment and prepares the /data/ folder. | ||
|
||
FROM ghcr.io/edgelesssys/ego-dev:v1.5.0 AS build-base | ||
|
||
# setup container data structure | ||
RUN mkdir -p /home/ten/go-ten | ||
|
||
# Ensures container layer caching when dependencies are not changed | ||
WORKDIR /home/ten/go-ten | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN ego-go mod download | ||
|
||
# Trigger new build stage for compiling the enclave | ||
FROM build-base as build-enclave | ||
COPY . . | ||
|
||
WORKDIR /home/ten/go-ten/tools/edbconnect/main | ||
|
||
# Build the enclave using the cross image build cache. | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
ego-go build | ||
|
||
# New build stage for compiling the enclave with restricted flags mode | ||
FROM build-enclave as sign-built-enclave | ||
# Sign the enclave executable | ||
RUN ego sign edb-enclave.json | ||
|
||
|
||
# Trigger a new build stage and use the smaller ego version: | ||
FROM ghcr.io/edgelesssys/ego-deploy:v1.5.0 | ||
|
||
# Copy the binary and the entrypoint script | ||
COPY --from=sign-built-enclave \ | ||
/home/ten/go-ten/tools/edbconnect/main /home/ten/go-ten/tools/edbconnect/main | ||
|
||
WORKDIR /home/ten/go-ten/tools/edbconnect/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
# Variables | ||
IMAGE_NAME="testnetobscuronet.azurecr.io/obscuronet/edbconnect:latest" | ||
CONTAINER_BASE_NAME="edb-connect" | ||
UNIQUE_ID=$(date +%s%3N) # Using milliseconds for uniqueness | ||
CONTAINER_NAME="${CONTAINER_BASE_NAME}-${UNIQUE_ID}" | ||
VOLUME_NAME="obscuronode-enclave-volume" | ||
NETWORK_NAME="node_network" | ||
SGX_ENCLAVE_DEVICE="/dev/sgx_enclave" | ||
SGX_PROVISION_DEVICE="/dev/sgx_provision" | ||
COMMAND="ego run /home/ten/go-ten/tools/edbconnect/main/main" | ||
|
||
# Function to destroy exited containers matching the base name | ||
destroy_exited_containers() { | ||
exited_containers=$(docker ps -a -q -f name=${CONTAINER_BASE_NAME} -f status=exited) | ||
if [ "$exited_containers" ];then | ||
echo "Removing exited containers matching ${CONTAINER_BASE_NAME}..." | ||
docker rm $exited_containers || true | ||
else | ||
echo "No exited containers to remove." | ||
fi | ||
} | ||
|
||
# Destroy exited containers that match the base name | ||
destroy_exited_containers | ||
|
||
# Pull the latest image from Azure Docker repository | ||
echo "Pulling the latest Docker image..." | ||
docker pull $IMAGE_NAME | ||
|
||
# Run the container with the specified command | ||
echo "Running the new container with name ${CONTAINER_NAME}..." | ||
docker run --name $CONTAINER_NAME \ | ||
--network $NETWORK_NAME \ | ||
-v $VOLUME_NAME:/enclavedata \ | ||
--device $SGX_ENCLAVE_DEVICE:$SGX_ENCLAVE_DEVICE:rwm \ | ||
--device $SGX_PROVISION_DEVICE:$SGX_PROVISION_DEVICE:rwm \ | ||
$IMAGE_NAME $COMMAND | ||
|
||
# After the REPL exits, destroy the container | ||
echo "Destroying the container ${CONTAINER_NAME} after command exits..." | ||
docker rm $CONTAINER_NAME || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"exe": "main", | ||
"key": "testnet.pem", | ||
"debug": true, | ||
"heapSize": 4096, | ||
"executableHeap": true, | ||
"productID": 1, | ||
"securityVersion": 1, | ||
"mounts": [ | ||
{ | ||
"source": "/enclavedata", | ||
"target": "/data", | ||
"type": "hostfs", | ||
"readOnly": false | ||
} | ||
], | ||
"env": [ | ||
] | ||
} |
Oops, something went wrong.