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

allow deleting #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e26872d
allow deleting
withinboredom Mar 31, 2024
22f0289
allow for deleting
withinboredom Apr 1, 2024
c8e351a
update docker file
withinboredom Apr 1, 2024
94b382b
attempt building php
withinboredom Apr 1, 2024
7463221
remove zlib
withinboredom Apr 1, 2024
0fabfd1
update deps
withinboredom Apr 4, 2024
0c101f0
update deps
withinboredom Apr 11, 2024
9c41f6b
build osx
withinboredom Apr 11, 2024
efa6f3f
sync from dockerfile
withinboredom Apr 11, 2024
e0ab4e5
add cache and stuff
withinboredom Apr 11, 2024
d14f3ae
add build cache
withinboredom Apr 11, 2024
5ab3de4
fix cache key
withinboredom Apr 11, 2024
6a7039e
move into cli dir
withinboredom Apr 11, 2024
241109d
remove uuid
withinboredom Apr 11, 2024
852ca4b
fix paths
withinboredom Apr 11, 2024
3fa9f38
build from correct dirs
withinboredom Apr 11, 2024
d0ff163
capture artifact
withinboredom Apr 11, 2024
cd1db00
setup correct version
withinboredom Apr 11, 2024
46933b5
build multiple versions
withinboredom Apr 11, 2024
bfa9aff
switch strategies
withinboredom Apr 11, 2024
c27ff7d
set up go
withinboredom Apr 11, 2024
fb586df
do not cache
withinboredom Apr 11, 2024
9f8ec2b
use matrix on linux side
withinboredom Apr 11, 2024
82f2fc5
use buildx
withinboredom Apr 11, 2024
5cb3916
do not hardcode type
withinboredom Apr 11, 2024
d2e9c1d
use platform in archive
withinboredom Apr 11, 2024
3cfa3ec
set platform
withinboredom Apr 12, 2024
2666292
might be slower...
withinboredom Apr 12, 2024
28f2251
docker cache
withinboredom Apr 12, 2024
d4b703a
remove makefile
withinboredom Apr 12, 2024
f76a7b4
just name it something simple
withinboredom Apr 12, 2024
41cb417
fix artifact name
withinboredom Apr 12, 2024
c0b8063
keep going
withinboredom Apr 12, 2024
301b2a5
build the docker image
withinboredom Apr 12, 2024
1bdbfac
set id
withinboredom Apr 12, 2024
3699769
build multiple platforms
withinboredom Apr 12, 2024
1582546
set docker cache scope
withinboredom Apr 12, 2024
20fd6cf
set a version
withinboredom Apr 12, 2024
f5a1816
fix typo
withinboredom Apr 12, 2024
0e0ebd9
use a cache
withinboredom Apr 12, 2024
79cdfc3
fix typo
withinboredom Apr 12, 2024
d7a4591
run doctor
withinboredom Apr 12, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/Test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Run Unit Tests
on:
pull_request:
branches:
- main
- v2
push:
branches:
- main
- v2
jobs:
unit-tests:
name: Unit Tests
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/build-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: build-cli
on:
push:
branches:
- v2
pull_request:
branches:
- v2
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
platform: [ 'amd64', 'arm64' ]
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Configure QEMU
uses: docker/setup-qemu-action@v3
- name: Configure docker
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ matrix.platform }}
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Build sources
run: |
docker buildx build --cache-to type=gha,mode=max,scope=${{ matrix.platform }} --cache-from type=gha,scope=${{ matrix.platform }} --pull --load --platform linux/${{ matrix.platform }} --target cli-base-alpine -t builder .
- name: Copy build
run: |
docker create --name builder builder
docker cp builder:/go/src/app/cli/dist/dphp bin/dphp
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: dphp-${{ runner.os }}-${{ matrix.platform }}
path: bin/dphp
build-docker:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Configure QEMU
uses: docker/setup-qemu-action@v3
- name: Configure docker
uses: docker/setup-buildx-action@v3
- name: Login to Docker
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Calculate version
run: |
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
export VERSION=${GITHUB_REF_NAME:1}
else
export VERSION=${GITHUB_SHA}
fi

echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/durable-php/runtime
tags: |
type=schedule,pattern=latest
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build
uses: docker/build-push-action@v3
with:
context: ./
file: Dockerfile
target: durable-php
build-args: |
VERSION=${{ env.VERSION }}
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=gha,scope=image
cache-to: type=gha,mode=max,scope=image
platforms: linux/amd64,linux/arm64
build-osx:
strategy:
fail-fast: true
matrix:
platform: [ 'arm64', 'x86_64' ]
runs-on: ${{ matrix.platform == 'arm64' && 'macos-14' || 'macos-13' }}
env:
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '>=1.22'
- name: Configure Version
run: |
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
export VERSION=${GITHUB_REF_NAME:1}
else
export VERSION=${GITHUB_SHA}
fi

echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
- name: Configure cache
uses: actions/cache@v4
with:
path: dist
key: ${{ matrix.platform }}-${{ hashFiles('cli/*.mod') }}
- name: Run doctor
run: BUILD=no cli/build-php.sh
- name: Build php
run: cli/build-php.sh
- name: Build cli
run: cd cli && ./build.sh
- run: ls -lah cli/dist/
- run: ls -lah dist/ || true
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: dphp-${{ runner.os }}-${{ matrix.platform }}
path: cli/dist/dphp
1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 34 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN apk update; \
ln -sf /usr/bin/php83 /usr/bin/php

ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PHP_EXTENSIONS="apcu,bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,gmp,gd,iconv,igbinary,mbregex,mbstring,opcache,openssl,pcntl,phar,posix,readline,simplexml,sockets,sodium,sysvsem,tokenizer,uuid,uv,xml,xmlreader,xmlwriter,zip,zlib"
ENV PHP_EXTENSIONS="apcu,bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,gmp,gd,iconv,igbinary,mbregex,mbstring,opcache,openssl,pcntl,phar,posix,readline,simplexml,sockets,sodium,sysvsem,tokenizer,uv,xml,xmlreader,xmlwriter,zip,zlib"
ENV PHP_EXTENSION_LIBS="bzip2,freetype,libavif,libjpeg,libwebp,libzip"

WORKDIR /go/src/app
Expand All @@ -66,31 +66,43 @@ COPY cli/ ./cli/
WORKDIR /go/src/app/cli
RUN ./build.sh

FROM php:8-zts AS base

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/

RUN install-php-extensions ev apcu pcntl parallel @composer && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
apt update && \
apt install -y procps && \
rm -rf /var/lib/apt/lists/*

COPY composer.json composer.lock /app/
FROM php:8-zts AS common

WORKDIR /app

RUN composer install --no-interaction --optimize-autoloader
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
ARG VERSION=dev

FROM common AS builder

COPY --from=golang:1.22 /usr/local/go /usr/local/go
ENV PATH /usr/local/go/bin:$PATH

RUN apt-get update && \
apt-get -y --no-install-recommends install \
libargon2-dev \
libbrotli-dev \
libcurl4-openssl-dev \
libonig-dev \
libreadline-dev \
libsodium-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
zlib1g-dev \
&& \
apt-get clean

COPY . /app

#RUN groupadd -g 1000 app && \
# useradd -d /app -s /bin/bash -g 1000 -u 1000 app && \
# chown -R app:app /app && \
# adduser app sudo
WORKDIR /go/src/app
COPY --link cli/go.mod cli/go.sum ./
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get

ENTRYPOINT [ "php", "-d", "opcache.enable_cli=1", "-d", "opcache.jit_buffer_size=50M", "-d", "opcache.jit=tracing", "src/Run.php" ]
COPY --link cli/ .

FROM base as dev
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS
ENV GOBIN=/usr/local/bin
RUN go get durable_php
RUN go install -ldflags "-w -s -X 'main.version=$VERSION'"

RUN install-php-extensions xdebug
FROM common AS durable-php
COPY --from=builder /usr/local/bin/durable_php /usr/local/bin/dphp
14 changes: 9 additions & 5 deletions cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
TARGET := dphp-linux-x86_64
TARGET := dphp-linux-*
BIN_PATH := ../bin
DOCKER_IMAGE := builder
DOCKER_TARGET := cli-base-alpine
BUILD_PATH := /go/src/app/cli/dist

${BIN_PATH}/${TARGET}: cli.go */* go.mod build.sh build-php.sh ../Dockerfile
mkdir -p ${BIN_PATH}
cd .. && docker build --pull --target ${DOCKER_TARGET} -t ${DOCKER_IMAGE} .
docker create --name builder builder || ( docker rm -f builder && false )
docker cp ${DOCKER_IMAGE}:${BUILD_PATH}/${TARGET} ${BIN_PATH}/${TARGET} || ( docker rm -f builder && false )
docker rm -f builder
cd .. && docker buildx build --cache-to type=gha --cache-from type=gha --pull --load --platform ${PLATFORM} --target ${DOCKER_TARGET} -t ${DOCKER_IMAGE} .
docker create --name ${DOCKER_IMAGE} ${DOCKER_IMAGE} || ( docker rm -f ${DOCKER_IMAGE} && false )
docker cp ${DOCKER_IMAGE}:${BUILD_PATH}/${TARGET} ${BIN_PATH}/ || ( docker rm -f ${DOCKER_IMAGE} && false )
docker rm -f ${DOCKER_IMAGE}
upx -9 --force-pie ../bin/dphp-*

../dist: ${BIN_PATH}/${TARGET}
docker create --name builder builder
docker cp ${DOCKER_IMAGE}:${BUILD_PATH} ../dist
2 changes: 1 addition & 1 deletion cli/auth/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (r *Resource) getOrCreatePermissions(id *glue.StateId, ctx context.Context,

glu := glue.NewGlue(ctx.Value("bootstrap").(string), glue.GetPermissions, make([]any, 0), result.Name())
env := map[string]string{"STATE_ID": id.String()}
_, headers, _ := glu.Execute(ctx, make(http.Header), logger, env, nil, id)
_, headers, _, _ := glu.Execute(ctx, make(http.Header), logger, env, nil, id)
data := headers.Get("Permissions")
if err = json.Unmarshal([]byte(data), &perms); err != nil {
return perms, err
Expand Down
Loading
Loading