Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP docker image building #541

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 17 additions & 0 deletions .github/workflows/all-docker-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
55 changes: 55 additions & 0 deletions dockerfiles/php.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Loading