Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaven committed Oct 27, 2023
0 parents commit 5c43a7c
Show file tree
Hide file tree
Showing 11 changed files with 577 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build-geth-node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Publish Docker image


on:
release:
types: [published]
push:
branches:
- main
paths:
- GethNode/**
- .github/workflows/build-geth-node.yaml


jobs:
build_geth_node:
name: Build and publish Geth Node image
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate package repo name
id: ghcr_repo
run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-gethnode" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ steps.ghcr_repo.outputs.path }}
- name: Get current commit SHA short
id: commit_sha
run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT

- name: Manually generate sha tag
id: tag_sha
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT

- name: Manually generate ver tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: tag_ver
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Build and push Docker images for each commit
uses: docker/build-push-action@v5
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
context: ./GethNode
platforms: linux/amd64
push: true
tags: |
${{ steps.tag_sha.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}

- name: Create and push a manifest with ver referencing latest commit
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
docker buildx imagetools create \
-t ${{ steps.tag_ver.outputs.tag }} \
${{ steps.tag_sha.outputs.tag }}
146 changes: 146 additions & 0 deletions .github/workflows/build-sgx-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Build and Publish Docker image


on:
release:
types: [published]
push:
branches:
- main
paths:
- SGXDev/**
- SGXSolDev/**
- .github/workflows/build-sgx-dev.yaml


jobs:
build_sgx_dev:
name: Build and publish SGX Dev image
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate package repo name
id: ghcr_repo
run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-sgxdev" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ steps.ghcr_repo.outputs.path }}
- name: Get current commit SHA short
id: commit_sha
run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT

- name: Manually generate sha tag
id: tag_sha
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT

- name: Manually generate ver tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: tag_ver
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Build and push Docker images for each commit
uses: docker/build-push-action@v5
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
context: ./SGXDev
platforms: linux/amd64
push: true
tags: |
${{ steps.tag_sha.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}

- name: Create and push a manifest with ver referencing latest commit
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
docker buildx imagetools create \
-t ${{ steps.tag_ver.outputs.tag }} \
${{ steps.tag_sha.outputs.tag }}
build_sgx_sol_dev:
name: Build and publish SGX Solidity Dev image
needs: [ build_sgx_dev ]
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate package repo name
id: ghcr_repo
run: echo "path=ghcr.io/${{ github.repository_owner }}/decent-sgxsoldev" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ steps.ghcr_repo.outputs.path }}
- name: Get current commit SHA short
id: commit_sha
run: echo "short=$(git rev-parse --short HEAD)" | tr '[:upper:]' '[:lower:]' >> $GITHUB_OUTPUT

- name: Manually generate sha tag
id: tag_sha
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${{ steps.commit_sha.outputs.short }}" >> $GITHUB_OUTPUT

- name: Manually generate ver tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: tag_ver
run: echo "tag=${{ steps.ghcr_repo.outputs.path }}:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Build and push Docker images for each commit
uses: docker/build-push-action@v5
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
context: ./SGXSolDev
platforms: linux/amd64
build-args: |
BASE_IMG_TAG=${{ steps.commit_sha.outputs.short }}
push: true
tags: |
${{ steps.tag_sha.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}

- name: Create and push a manifest with ver referencing latest commit
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
docker buildx imagetools create \
-t ${{ steps.tag_ver.outputs.tag }} \
${{ steps.tag_sha.outputs.tag }}
53 changes: 53 additions & 0 deletions GethNode/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright (c) 2023 Haofan Zheng
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

############################### Install packages ###############################
RUN apt-get update -y && \
apt-get install -y \
apt-utils \
lsb-release

RUN apt-get update -y && \
apt-get upgrade -y

RUN apt-get update -y && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:ethereum/ethereum

RUN apt-get update -y && \
apt-get install -y \
ethereum \
openssl \
curl


# Prysm
RUN mkdir /opt/prysm
RUN curl https://github.com/prysmaticlabs/prysm/raw/master/prysm.sh \
--output /opt/prysm/prysm.sh
RUN chmod 755 /opt/prysm/prysm.sh
################################################################################

ENV DEBIAN_FRONTEND=

ENV LANG=C.UTF-8

# environment
RUN mkdir /geth
WORKDIR /geth

# test script
COPY test.sh /bin/test.sh
RUN chmod 755 /bin/test.sh

# entrypoint
COPY init-geth /bin/init-geth
RUN chmod 755 /bin/init-geth

ENTRYPOINT [ "/bin/init-geth" ]
10 changes: 10 additions & 0 deletions GethNode/init-geth
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

if [[ ! -f /geth/jwt.hex ]]; then
echo "JWT not found, generating..."
openssl rand -hex 32 | tr -d "\n" > "/geth/jwt.hex"
fi

/bin/test.sh --existing-arg1 --existing-arg2 ${GETH_OPTS}
6 changes: 6 additions & 0 deletions GethNode/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

for var in "$@"
do
echo "$var"
done
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Haofan Zheng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# DecentDevContainer

## SGXDev

- Build locally

```sh
docker build \
-t ghcr.io/lsd-ucsc/decent-sgxdev:local \
./SGXDev
```

## SGXSolDev

- Build locally

```sh
docker build \
--build-arg BASE_IMG_TAG=local \
-t ghcr.io/lsd-ucsc/decent-sgxsoldev:local \
./SGXSolDev
```

## GethNode

- Build locally

```sh
docker build \
-t ghcr.io/lsd-ucsc/decent-gethnode:local \
./GethNode
```
Loading

0 comments on commit 5c43a7c

Please sign in to comment.