diff --git a/.github/workflows/all-docker-images.yaml b/.github/workflows/all-docker-images.yaml index 665eceae..2bd34804 100644 --- a/.github/workflows/all-docker-images.yaml +++ b/.github/workflows/all-docker-images.yaml @@ -13,6 +13,9 @@ on: py-ver: description: Python SDK ver to build. Skipped if not specified. Must start with v. type: string + php-ver: + description: PHP SDK ver to build. Skipped if not specified. + type: string ts-ver: description: TypeScript SDK ver to build. Skipped if not specified. Must start with v. type: string @@ -43,6 +46,9 @@ on: py-ver: description: Python SDK ver to build. Skipped if not specified. Must start with v. type: string + php-ver: + description: PHP SDK ver to build. Skipped if not specified. + type: string ts-ver: description: TypeScript SDK ver to build. Skipped if not specified. Must start with v. type: string @@ -107,6 +113,17 @@ jobs: do-push: ${{ inputs.do-push }} skip-cloud: ${{ inputs.skip-cloud }} + build-php-docker-images: + if: inputs.php-ver + uses: ./.github/workflows/docker-images.yaml + secrets: inherit + with: + lang: php + sdk-version: ${{ inputs.php-ver }} + semver-latest: major + do-push: ${{ inputs.do-push }} + skip-cloud: ${{ inputs.skip-cloud }} + build-dotnet-docker-images: if: inputs.cs-ver uses: ./.github/workflows/docker-images.yaml diff --git a/dockerfiles/php.Dockerfile b/dockerfiles/php.Dockerfile new file mode 100644 index 00000000..8f2c2abd --- /dev/null +++ b/dockerfiles/php.Dockerfile @@ -0,0 +1,55 @@ +# Build in a full featured container +FROM php:8.2 as build + +# Install protobuf compiler +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive \ + apt-get install --no-install-recommends --assume-yes \ + protobuf-compiler=3.* libprotobuf-dev=3.* wget=* + +# Get go compiler +ARG PLATFORM=amd64 +RUN wget -q https://go.dev/dl/go1.22.4.linux-${PLATFORM}.tar.gz \ + && tar -C /usr/local -xzf go1.22.4.linux-${PLATFORM}.tar.gz +# Install Rust for compiling the core bridge - only required for installation from a repo but is cheap enough to install +# in the "build" container (-y is for non-interactive install) +# hadolint ignore=DL4006 +RUN wget -q -O - https://sh.rustup.rs | sh -s -- -y + +# Install composer +COPY --from=composer:2.3 /usr/bin/composer /usr/bin/composer + +WORKDIR /app + +# Copy CLI build dependencies +COPY features ./features +COPY harness ./harness +COPY sdkbuild ./sdkbuild +COPY cmd ./cmd +COPY go.mod go.sum main.go ./ + +# Build the CLI +RUN CGO_ENABLED=0 /usr/local/go/bin/go build -o temporal-features + +ARG SDK_VERSION +ARG SDK_REPO_URL +ARG SDK_REPO_REF +# Could be a cloned lang SDK git repo or just an arbitrary file so the COPY command below doesn't fail. +# It was either this or turn the Dockerfile into a template, this seemed simpler although a bit awkward. +ARG REPO_DIR_OR_PLACEHOLDER +COPY ./${REPO_DIR_OR_PLACEHOLDER} ./${REPO_DIR_OR_PLACEHOLDER} + +# Prepare the feature for running. We need to use in-project venv so it is copied into smaller img. +RUN CGO_ENABLED=0 ./temporal-features prepare --lang php --dir prepared --version "$SDK_VERSION" + +# Copy the CLI and prepared feature to a smaller container for running +FROM spiralscout/php-grpc:8.2 + +COPY --from=build /app/temporal-features /app/temporal-features +COPY --from=build /app/features /app/features +COPY --from=build /app/prepared /app/prepared +COPY --from=build /app/harness/php /app/harness/php +COPY --from=build /app/${REPO_DIR_OR_PLACEHOLDER} /app/${REPO_DIR_OR_PLACEHOLDER} + +# Use entrypoint instead of command to "bake" the default command options +ENTRYPOINT ["/app/temporal-features", "run", "--lang", "php", "--prepared-dir", "prepared"]