Skip to content

Commit 533b83e

Browse files
committed
Updated to PHP 8.4, moved to Docker on CloudRun
1 parent fb4964e commit 533b83e

File tree

13 files changed

+163
-89
lines changed

13 files changed

+163
-89
lines changed

.github/workflows/gcr-deploy.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
workflow_dispatch:
9+
10+
# Environment variables available to all jobs and steps in this workflow
11+
# NOTE: these aren't really secret, but there aren't non-secret settings
12+
env:
13+
RUN_PROJECT: ${{ secrets.RUN_PROJECT }}
14+
RUN_REGION: ${{ secrets.RUN_REGION }}
15+
RUN_SERVICE: ${{ secrets.RUN_SERVICE }}
16+
17+
jobs:
18+
deploy:
19+
name: Deploy to CloudRun
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: gcloud auth
27+
id: 'auth'
28+
uses: 'google-github-actions/auth@v2'
29+
with:
30+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
31+
32+
# Setup gcloud CLI
33+
- name: gcloud setup
34+
uses: google-github-actions/setup-gcloud@v2
35+
36+
- name: gcloud docker-auth
37+
run: gcloud auth configure-docker
38+
39+
# Build and push image to Google Container Registry
40+
- name: Build
41+
run: |
42+
docker build \
43+
--build-arg COMMIT=${GITHUB_SHA:0:7} \
44+
--build-arg LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
45+
--tag gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
46+
.
47+
48+
- name: GCloud auth to docker
49+
run: |
50+
gcloud auth configure-docker
51+
52+
- name: Push to registry
53+
run: |
54+
docker push gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA
55+
56+
# Deploy image to Cloud Run
57+
- name: Deploy
58+
run: |
59+
gcloud run deploy ${RUN_SERVICE} \
60+
--allow-unauthenticated \
61+
--image gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
62+
--platform managed \
63+
--project ${RUN_PROJECT} \
64+
--region ${RUN_REGION}

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# https://github.com/s6n-labs/distroless-php/blob/main/Dockerfile
2+
3+
ARG TAG=8.4
4+
FROM php:${TAG} AS php
5+
6+
RUN mkdir -p /tmp/lib && cd /lib && \
7+
ldd /usr/local/bin/php | grep '=> /lib/' | cut -d' ' -f3 | sed 's#/lib/##g' | xargs -I % cp --parents "%" /tmp/lib/
8+
9+
RUN mkdir -p /tmp/usr/lib && cd /usr/lib && \
10+
ldd /usr/local/bin/php | grep '=> /usr/lib/' | cut -d' ' -f3 | sed 's#/usr/lib/##g' | xargs -I % cp --parents "%" /tmp/usr/lib/
11+
12+
FROM gcr.io/distroless/cc-debian12 AS runner
13+
14+
ARG COMMIT=(local)
15+
ENV COMMIT=$COMMIT
16+
ARG LASTMOD=(local)
17+
ENV LASTMOD=$LASTMOD
18+
19+
ENV PORT=5000
20+
21+
COPY --from=php /bin/sh /bin/
22+
COPY --from=php /tmp/lib/ /lib/
23+
COPY --from=php /tmp/usr/lib/ /usr/lib/
24+
COPY --from=php /usr/local/lib/libphp.* /usr/local/lib/
25+
COPY --from=php /usr/local/bin/docker-php-* /usr/local/bin/php /usr/local/bin/
26+
COPY www /var/www
27+
28+
#CMD [ "/usr/local/bin/php", "-S", "0.0.0.0:$PORT", "-t", "/var/www" ]
29+
CMD exec /usr/local/bin/php -S 0.0.0.0:$PORT -t /var/www

LICENSE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ to attach them to the start of each source file to most effectively
629629
state the exclusion of warranty; and each file should have at least
630630
the "copyright" line and a pointer to where the full notice is found.
631631

632-
<one line to give the program's name and a brief idea of what it does.>
633-
Copyright (C) <year> <name of author>
632+
regexplanet-php - backend server for testing regular expressions in PHP
633+
Copyright (C) 2024 Andrew Marcuse
634634

635635
This program is free software: you can redistribute it and/or modify
636636
it under the terms of the GNU Affero General Public License as published by

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ This is the PHP backend for RegexPlanet, a tool for online regular expression te
55
See [API docs](http://www.regexplanet.com/support/api.html) for what it is supposed to do.
66

77
See [PHP online regex test page](http://www.regexplanet.com/advanced/php/index.html) to use it to test your PHP regular expressions.
8+
9+
## Credits
10+
11+
[![Docker](https://www.vectorlogo.zone/logos/docker/docker-ar21.svg)](https://www.docker.com/ "Deployment")
12+
[![Git](https://www.vectorlogo.zone/logos/git-scm/git-scm-ar21.svg)](https://git-scm.com/ "Version control")
13+
[![Github](https://www.vectorlogo.zone/logos/github/github-ar21.svg)](https://github.com/ "Code hosting")
14+
[![Google Cloud Run](https://www.vectorlogo.zone/logos/google_cloud_run/google_cloud_run-ar21.svg)](https://cloud.google.com/run/ "Hosting")
15+
[![PHP](https://www.vectorlogo.zone/logos/php/php-ar21.svg)](https://www.php.net/ "Code")
16+

app.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

deploy-gae.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

deploy.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

docker-run.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
#
3+
# run locally but in docker
4+
5+
set -o errexit
6+
set -o pipefail
7+
set -o nounset
8+
9+
docker build -t regexplanet-php .
10+
docker run \
11+
--publish 5000:5000 \
12+
--env PORT='5000' \
13+
--env COMMIT=$(git rev-parse --short HEAD) \
14+
--env LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
15+
regexplanet-php

php.ini

Lines changed: 0 additions & 1 deletion
This file was deleted.

run-gae.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)