diff --git a/.github/workflows/build-enclave.yml b/.github/workflows/build-enclave.yml index 8eb94f6..b271e17 100644 --- a/.github/workflows/build-enclave.yml +++ b/.github/workflows/build-enclave.yml @@ -17,7 +17,10 @@ jobs: uses: actions/checkout@v3 - name: Log in to Docker Hub - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - name: Verify required files are present run: | @@ -28,61 +31,68 @@ jobs: - name: Move files to folder structure run: | + # Ensure setup directory exists mkdir -p setup + + # Move files into setup/ directory if not already there mv Dockerfile setup/ || echo "Dockerfile already in setup/" mv setup.sh setup/ || echo "setup.sh already in setup/" mv supervisord.conf setup/ || echo "supervisord.conf already in setup/" - # Check and add outer Dockerfile and entrypoint.sh if not present + # Create outer Dockerfile if not present if [ ! -f Dockerfile ]; then echo "Creating outer Dockerfile" cat < Dockerfile - # base image - FROM marlinorg/nitro-cli - - # working directory - WORKDIR /app/setup - - # add files - COPY entrypoint.sh ./ - RUN chmod +x entrypoint.sh - - # entry point - ENTRYPOINT [ "/app/setup/entrypoint.sh" ] - EOF - fi - - if [ ! -f entrypoint.sh ]; then - echo "Creating entrypoint.sh" - cat < entrypoint.sh - #!/bin/sh - - dockerd & - sleep 10 - - # Determine architecture - ARCH=\$(uname -m) - if [ "\$ARCH" = "aarch64" ]; then - PLATFORM=linux/arm64 - else - PLATFORM=linux/amd64 - fi - - docker buildx create --name multiplatformEnclave --driver docker-container --bootstrap - docker buildx use multiplatformEnclave - - cd /app/mount/setup - docker buildx build --platform \$PLATFORM -t enclave:latest --load . - - mkdir -p /app/mount/enclave - mkdir -p /var/log/nitro_enclaves - touch /var/log/nitro_enclaves/nitro_enclaves.log - - nitro-cli build-enclave --docker-uri enclave:latest --output-file /app/mount/enclave/enclave.eif - EOF - fi - - - name: Build and Run Enclave - run: | - docker build -t enclave . - docker run --privileged -v `pwd`:/app/mount enclave + # Base image with Nitro CLI + FROM marlinorg/nitro-cli + + # Set working directory + WORKDIR /app/setup + + # Copy and make entrypoint executable + COPY entrypoint.sh ./ + RUN chmod +x entrypoint.sh + + # Set entry point to entrypoint.sh + ENTRYPOINT [ "/app/setup/entrypoint.sh" ] + EOF + fi + + # Create entrypoint.sh if not present + if [ ! -f entrypoint.sh ]; then + echo "Creating entrypoint.sh" + cat < entrypoint.sh + #!/bin/sh + + dockerd & + sleep 10 + + # Set platform based on architecture + ARCH=\$(uname -m) + if [ "\$ARCH" = "aarch64" ]; then + PLATFORM=linux/arm64 + else + PLATFORM=linux/amd64 + fi + + docker buildx create --name multiplatformEnclave --driver docker-container --bootstrap + docker buildx use multiplatformEnclave + + # Build the inner enclave image + cd /app/mount/setup + docker buildx build --platform \$PLATFORM -t enclave:latest --load . + + # Prepare directories for Nitro Enclaves + mkdir -p /app/mount/enclave + mkdir -p /var/log/nitro_enclaves + touch /var/log/nitro_enclaves/nitro_enclaves.log + + # Build the enclave image file + nitro-cli build-enclave --docker-uri enclave:latest --output-file /app/mount/enclave/enclave.eif + EOF + fi + + - name: Build and Run Enclave + run: | + docker build -t enclave . + docker run --privileged -v "$(pwd)":/app/mount enclave diff --git a/setup/server/.gitignore b/server/.gitignore similarity index 100% rename from setup/server/.gitignore rename to server/.gitignore diff --git a/setup/server/keys/server.cert b/server/keys/server.cert similarity index 100% rename from setup/server/keys/server.cert rename to server/keys/server.cert diff --git a/setup/server/keys/server.key b/server/keys/server.key similarity index 100% rename from setup/server/keys/server.key rename to server/keys/server.key diff --git a/setup/server/package.json b/server/package.json similarity index 100% rename from setup/server/package.json rename to server/package.json diff --git a/setup/server/src/config.ts b/server/src/config.ts similarity index 100% rename from setup/server/src/config.ts rename to server/src/config.ts diff --git a/setup/server/src/controller.ts b/server/src/controller.ts similarity index 100% rename from setup/server/src/controller.ts rename to server/src/controller.ts diff --git a/setup/server/src/routes.ts b/server/src/routes.ts similarity index 100% rename from setup/server/src/routes.ts rename to server/src/routes.ts diff --git a/setup/server/src/server-app.ts b/server/src/server-app.ts similarity index 100% rename from setup/server/src/server-app.ts rename to server/src/server-app.ts diff --git a/setup/server/src/server.ts b/server/src/server.ts similarity index 100% rename from setup/server/src/server.ts rename to server/src/server.ts diff --git a/setup/server/tsconfig.json b/server/tsconfig.json similarity index 100% rename from setup/server/tsconfig.json rename to server/tsconfig.json diff --git a/setup/server/yarn.lock b/server/yarn.lock similarity index 100% rename from setup/server/yarn.lock rename to server/yarn.lock