Skip to content

Commit

Permalink
fix: make phar in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Mar 18, 2024
1 parent 39d0ac2 commit e65da55
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,37 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
- name: Extract metadata (tags, labels) for Drafter
id: meta-drafter
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/drafter

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}

- name: Build and push Docker image
- name: Build and push drafter Docker image
uses: docker/build-push-action@master
with:
context: .
push: true
tags: ${{ steps.meta-drafter.outputs.tags }}
labels: ${{ steps.meta-drafter.outputs.labels }}
target: drafter-build
no-cache-filters: drafter-build
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/drafter:latest

- name: Build and push Docker image
- name: Extract metadata (tags, labels) for PHPDraft
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}

- name: Build and push PHPDraft Docker image
uses: docker/build-push-action@master
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: phpdraft
target: phpdraft
no-cache-filters: phpdraft
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
PHPDRAFT_RELEASE_ID=2.0.0
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ RUN composer install --ignore-platform-req=ext-uopz

FROM php:8.3-cli-bullseye AS phpdraft-build

ARG PHPDRAFT_RELEASE_ID=1.0.0

RUN echo $PHPDRAFT_RELEASE_ID

COPY --from=composer /usr/src/phpdraft /usr/src/phpdraft
WORKDIR /usr/src/phpdraft

RUN ./vendor/bin/phing phar-nightly
COPY /usr/src/phpdraft/build/out/phpdraft-nightly.phar /usr/local/bin/phpdraft
RUN echo "phar.readonly=0" >> /usr/local/etc/php/php.ini-production
RUN php -i

RUN php ./vendor/bin/phing phar-nightly

COPY /usr/src/phpdraft/build/out/phpdraft-*.phar /usr/local/bin/phpdraft
RUN chmod +x /usr/local/bin/phpdraft

FROM php:8.3-cli-bullseye AS phpdraft
Expand Down
6 changes: 6 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@
<echo message="Building version: ${version}, type: ${type}, output: ${_version}"/>
<fail unless="_version" message="Could not construct version parameter!" />

<php function="ini_get" returnProperty="_pharReadonly">
<param value="phar.readonly"/>
</php>

<fail if="_pharReadonly" message="No PHAR creation allowed"/>

<exec executable="${project.basedir}/vendor/bin/phpab" taskname="phpab">
<arg value="--all"/>
<arg value="--static"/>
Expand Down
7 changes: 6 additions & 1 deletion src/PHPDraft/Out/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ public static function version(): void
*/
public static function release_id(): string
{
return (VERSION === '0') ? @exec('git describe --tags 2>&1') : VERSION;
$env_id = getenv('PHPDRAFT_RELEASE_ID');
if ($env_id !== FALSE) {
return $env_id;

Check warning on line 40 in src/PHPDraft/Out/Version.php

View check run for this annotation

Codecov / codecov/patch

src/PHPDraft/Out/Version.php#L40

Added line #L40 was not covered by tests
}

return VERSION !== '0' ? VERSION : @exec('git describe --tags 2>&1');
}

/**
Expand Down

0 comments on commit e65da55

Please sign in to comment.