Skip to content

Commit

Permalink
feat: add PHP application template
Browse files Browse the repository at this point in the history
  • Loading branch information
endersonmaia committed Sep 26, 2024
1 parent f50f90c commit aa2b80b
Show file tree
Hide file tree
Showing 6 changed files with 747 additions and 0 deletions.
2 changes: 2 additions & 0 deletions php/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.cartesi
vendor
3 changes: 3 additions & 0 deletions php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.bundle
.cartesi
vendor
70 changes: 70 additions & 0 deletions php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# syntax=docker.io/docker/dockerfile:1

# This enforces that the packages downloaded from the repositories are the same
# for the defined date, no matter when the image is built.
ARG UBUNTU_TAG=noble-20240827.1
ARG APT_UPDATE_SNAPSHOT=20240827T030400Z

################################################################################
# riscv64 base stage
FROM --platform=linux/riscv64 ubuntu:${UBUNTU_TAG} AS base

ARG APT_UPDATE_SNAPSHOT
ARG DEBIAN_FRONTEND=noninteractive
RUN <<EOF
set -eu
apt update
apt install -y --no-install-recommends ca-certificates
apt update --snapshot=${APT_UPDATE_SNAPSHOT}
EOF

FROM base AS builder

ARG DEBIAN_FRONTEND=noninteractive
RUN <<EOF
set -e
apt-get install -y --no-install-recommends \
php8.3-cli \
php8.3-curl \
composer \
git \
unzip
rm -rf /var/apt/lists/*
EOF

WORKDIR /usr/src/app

COPY composer.json composer.lock ./
RUN composer install

FROM base

ARG MACHINE_EMULATOR_TOOLS_VERSION=0.14.1
ADD https://github.com/cartesi/machine-emulator-tools/releases/download/v${MACHINE_EMULATOR_TOOLS_VERSION}/machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb /
RUN dpkg -i /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb \
&& rm /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb

LABEL io.cartesi.rollups.sdk_version=0.10.0
LABEL io.cartesi.rollups.ram_size=128Mi

ARG DEBIAN_FRONTEND=noninteractive
RUN <<EOF
set -e
apt-get update
apt-get install -y --no-install-recommends \
busybox-static \
php8.3-cli \
php8.3-curl
rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/*
useradd --create-home --user-group dapp
EOF

ENV PATH="/opt/cartesi/bin:${PATH}"

COPY --from=builder /usr/src/app/vendor /usr/src/app/vendor

WORKDIR /usr/src/app
COPY index.php .

ENTRYPOINT ["rollup-init"]
CMD ["php", "index.php"]
5 changes: 5 additions & 0 deletions php/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"guzzlehttp/guzzle": "^7.0"
}
}
Loading

0 comments on commit aa2b80b

Please sign in to comment.