Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions custom-dapps/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
!.gitignore
!template
!template-dockerfile
!create-dapp.sh
!README.md
20 changes: 15 additions & 5 deletions custom-dapps/create-dapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,31 @@
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

if [ $# -ne 1 ]
if [ $# -eq 0 ]
then
echo "No DAPP_NAME supplied"
echo "Usage: $0 DAPP_NAME"
echo "Usage: $0 DAPP_NAME [BUILD_SYSTEM]"
exit 1
fi

dapp_name=${1}
build_system=${2:-std-rootfs}

if [[ ! "$build_system" =~ ^(std-rootfs|docker-riscv)$ ]]; then
echo "BUILD_SYSTEM should either be std-rootfs or docker-riscv"
echo "Usage: $0 DAPP_NAME [BUILD_SYSTEM]"
exit 1
fi

echo "Creating DApp ${dapp_name}..."

echo "Copying files from template..."
cp -pr template ${dapp_name}
cp template-dockerfile/${build_system}.Dockerfile ${dapp_name}/Dockerfile

echo "Copying common files..."
cp -pr ../build/std-rootfs ${dapp_name}
mv ${dapp_name}/std-rootfs/base.hcl ${dapp_name}/docker-bake.hcl
cp -pr ../build/${build_system} ${dapp_name}
mv ${dapp_name}/${build_system}/base.hcl ${dapp_name}/docker-bake.hcl
cp ../deploy-testnet.yml ${dapp_name}
cp ../docker-compose.yml ${dapp_name}
cp ../docker-compose-testnet.yml ${dapp_name}
Expand All @@ -37,7 +46,7 @@ echo "Customizing DApp infrastructure..."
for i in \
${dapp_name}/docker-bake.hcl
do
sed -i'' -e "s/\.\.\/build\/std-rootfs/\.\/std-rootfs/g" $i
sed -i'' -e "s/\.\.\/build\/${build_system}/\.\/${build_system}/g" $i
done

# replace template placeholders by dapp name
Expand All @@ -46,6 +55,7 @@ for i in \
${dapp_name}/docker-bake.override.hcl \
${dapp_name}/docker-compose.override.yml \
${dapp_name}/entrypoint.sh \
${dapp_name}/Dockerfile \
${dapp_name}/README.md
do
sed -i'' -e "s/template/${dapp_name}/g" $i
Expand Down
19 changes: 19 additions & 0 deletions custom-dapps/template-dockerfile/docker-riscv.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# syntax=docker.io/docker/dockerfile:1.4
FROM --platform=linux/riscv64 cartesi/python:3.10-slim-jammy

# install required libs and remove cache
# RUN apt-get update \
# && apt-get install -y --no-install-recommends \
# <APT-PACKAGE> \
# && rm -rf /var/lib/apt/lists/* \
# && find /var/log \( -name '*.log' -o -name '*.log.*' \) -exec truncate -s 0 {} \; \
# && truncate -s 0 /var/cache/ldconfig/aux-cache

WORKDIR /opt/cartesi/dapp

COPY ./requirements.txt .
RUN pip install -r requirements.txt --no-cache \
&& find /usr/local/lib -type d -name __pycache__ -exec rm -r {} +

COPY ./entrypoint.sh .
COPY ./template.py .
5 changes: 5 additions & 0 deletions custom-dapps/template-dockerfile/std-rootfs.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# syntax=docker.io/docker/dockerfile:1.4
FROM cartesi/toolchain:0.14.0

WORKDIR /opt/cartesi/dapp
COPY . .