Skip to content

Commit ec0f2d2

Browse files
committed
fix: make phar in docker
1 parent 39d0ac2 commit ec0f2d2

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

.github/workflows/docker.yml

+15-11
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,37 @@ jobs:
2828
username: ${{ github.actor }}
2929
password: ${{ secrets.GITHUB_TOKEN }}
3030

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

37-
- name: Extract metadata (tags, labels) for Docker
38-
id: meta
39-
uses: docker/metadata-action@master
40-
with:
41-
images: ${{ env.REGISTRY }}/${{ github.repository }}
42-
43-
- name: Build and push Docker image
37+
- name: Build and push drafter Docker image
4438
uses: docker/build-push-action@master
4539
with:
4640
context: .
4741
push: true
4842
tags: ${{ steps.meta-drafter.outputs.tags }}
4943
labels: ${{ steps.meta-drafter.outputs.labels }}
5044
target: drafter-build
45+
no-cache-filters: drafter-build
5146
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/drafter:latest
5247

53-
- name: Build and push Docker image
48+
- name: Extract metadata (tags, labels) for PHPDraft
49+
id: meta
50+
uses: docker/metadata-action@master
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ github.repository }}
53+
54+
- name: Build and push PHPDraft Docker image
5455
uses: docker/build-push-action@master
5556
with:
56-
context: .
5757
push: true
5858
tags: ${{ steps.meta.outputs.tags }}
5959
labels: ${{ steps.meta.outputs.labels }}
60-
target: phpdraft
60+
target: phpdraft
61+
no-cache-filters: phpdraft
62+
build-args: |
63+
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
64+
PHPDRAFT_RELEASE_ID=2.0.0

Dockerfile

+8-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ RUN composer install --ignore-platform-req=ext-uopz
2424

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

27+
ARG PHPDRAFT_RELEASE_ID=1.0.0
2728

29+
RUN echo $PHPDRAFT_RELEASE_ID
2830

2931
COPY --from=composer /usr/src/phpdraft /usr/src/phpdraft
3032
WORKDIR /usr/src/phpdraft
3133

32-
RUN ./vendor/bin/phing phar-nightly
33-
COPY /usr/src/phpdraft/build/out/phpdraft-nightly.phar /usr/local/bin/phpdraft
34+
RUN echo "phar.readonly=0" >> /usr/local/etc/php/conf.d/phar.ini
35+
RUN php -i
36+
37+
RUN php ./vendor/bin/phing phar-nightly
38+
39+
COPY /usr/src/phpdraft/build/out/phpdraft-*.phar /usr/local/bin/phpdraft
3440
RUN chmod +x /usr/local/bin/phpdraft
3541

3642
FROM php:8.3-cli-bullseye AS phpdraft

build.xml

+16
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@
130130
<echo message="Building version: ${version}, type: ${type}, output: ${_version}"/>
131131
<fail unless="_version" message="Could not construct version parameter!" />
132132

133+
<exec executable="php" outputProperty="_pharReadonly">
134+
<arg value="-r"/>
135+
<arg value="echo ini_get('phar.readonly');"/>
136+
</exec>
137+
138+
<echo message="Phar: ${_pharReadonly}"/>
139+
<fail message="No PHAR creation allowed">
140+
<condition>
141+
<or>
142+
<equals arg1="${_pharReadonly}" arg2="1"/>
143+
<equals arg1="${_pharReadonly}" arg2="true"/>
144+
<equals arg1="${_pharReadonly}" arg2="On"/>
145+
</or>
146+
</condition>
147+
</fail>
148+
133149
<exec executable="${project.basedir}/vendor/bin/phpab" taskname="phpab">
134150
<arg value="--all"/>
135151
<arg value="--static"/>

src/PHPDraft/Out/Version.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ public static function version(): void
3535
*/
3636
public static function release_id(): string
3737
{
38-
return (VERSION === '0') ? @exec('git describe --tags 2>&1') : VERSION;
38+
$env_id = getenv('PHPDRAFT_RELEASE_ID');
39+
if ($env_id !== FALSE) {
40+
return $env_id;
41+
}
42+
43+
return VERSION !== '0' ? VERSION : @exec('git describe --tags 2>&1');
3944
}
4045

4146
/**

0 commit comments

Comments
 (0)