-
Notifications
You must be signed in to change notification settings - Fork 69
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
Support APK with FPM #92
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a85d9a7
Support APK with FPM
v1v ff317e2
Merge remote-tracking branch 'upstream/master' into feature/support-apk
v1v 234fd5c
enable installation tests for alpine
v1v 3a9e258
Merge remote-tracking branch 'upstream/master' into feature/support-apk
v1v 84cb92e
customise the fpm version
v1v 6faa4c3
fix typo with the double quotes
v1v 44d1194
Merge remote-tracking branch 'upstream/master' into feature/support-apk
v1v 737c032
No more hardcoded image name but using the makefile target name
v1v 89f79e2
Merge remote-tracking branch 'upstream/master' into feature/support-apk
v1v 3beafb7
Support building extension for alpine
v1v 3cc45df
Use fixed composer version
v1v 2c5c0d0
Fix busybox mktemp
v1v 0f4e801
Support SO alpine generation
v1v 1d79513
Disable backtrace on non-glibc platforms (Alpine is one of those)
SergeyKleyman 2e5e1f6
Support alpine packaging and installation
v1v 58b0cce
Create package for each distribution
v1v 75452f7
As suggested in the code review
v1v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ phpunit.xml | |
html_docs | ||
|
||
# Packaging artifacts | ||
build/packages | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
ARG PHP_VERSION=7.2 | ||
FROM php:${PHP_VERSION}-fpm-alpine | ||
|
||
RUN apk update \ | ||
&& apk add \ | ||
autoconf \ | ||
bash \ | ||
build-base \ | ||
curl \ | ||
curl-dev \ | ||
git \ | ||
procps \ | ||
unzip | ||
|
||
RUN php -r "copy('https://raw.githubusercontent.com/composer/getcomposer.org/baecae060ee7602a9908f2259f7460b737839972/web/installer', 'composer-setup.php');" \ | ||
&& php -r "if (hash_file('sha384', 'composer-setup.php') === '572cb359b56ad9ae52f9c23d29d4b19a040af10d6635642e646a7caa7b96de717ce683bd797a92ce99e5929cc51e7d5f') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ | ||
&& php composer-setup.php --install-dir=/usr/bin --filename=composer --version=1.10.10 \ | ||
&& php -r "unlink('composer-setup.php');" | ||
|
||
WORKDIR /app/src/ext | ||
|
||
ENV REPORT_EXIT_STATUS=1 | ||
ENV TEST_PHP_DETAILED=1 | ||
ENV NO_INTERACTION=1 | ||
ENV TEST_PHP_JUNIT=/app/junit.xml | ||
|
||
CMD phpize \ | ||
&& ./configure --enable-elastic_apm \ | ||
&& make clean \ | ||
&& make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
FROM ruby:2.7.1-alpine3.12 | ||
|
||
ENV FPM_VERSION 1.11.0 | ||
RUN apk add --no-cache \ | ||
alpine-sdk make cpio curl libarchive-tools make php-pear \ | ||
python3 py3-virtualenv py3-setuptools py3-pip \ | ||
rpm unzip xz git tar dpkg \ | ||
&& ln -sf python3 /usr/bin/python \ | ||
&& gem install --no-document fpm | ||
&& gem install --no-document fpm -v ${FPM_VERSION} | ||
|
||
ENTRYPOINT ["fpm"] | ||
WORKDIR /src | ||
## Fix fpm issue, see https://github.com/jordansissel/fpm/issues/1227 | ||
ADD fpm_apm.patch /tmp | ||
RUN (cd /usr/local/bundle/gems/fpm-${FPM_VERSION}/ ; patch -p 1 < /tmp/fpm_apm.patch ) \ | ||
&& rm -f /tmp/fpm_apk.patch | ||
|
||
COPY create-package.sh /bin | ||
WORKDIR /src | ||
ENTRYPOINT ["/bin/create-package.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ VERSION?=$(shell grep 'VERSION' ../src/ElasticApm/ElasticApm.php | cut -d= -f2 | | |
OUTPUT:=build/packages | ||
PHP_AGENT_DIR:=/opt/elastic/apm-agent-php | ||
PHP_VERSION?=7.2 | ||
GIT_SHA ?= $(shell git rev-parse HEAD || echo "unknown") | ||
GIT_SHA?=$(shell git rev-parse HEAD || echo "unknown") | ||
|
||
export FPM_FLAGS= | ||
|
||
.PHONY: help | ||
.DEFAULT_GOAL := help | ||
|
@@ -20,41 +22,29 @@ prepare: ## Build docker image for the packaging | |
@docker build -t $(IMAGE) . | ||
|
||
create-%: prepare ## Create the specific package | ||
@echo 'Creating package ...' | ||
@echo "Creating package $* ..." | ||
@mkdir -p $(PWD)/$(OUTPUT) | ||
@docker run --rm \ | ||
-v $(PWD):/app \ | ||
-w /app $(IMAGE) \ | ||
--input-type dir \ | ||
--output-type $* \ | ||
--name $(NAME) \ | ||
--version $(VERSION) \ | ||
--architecture all \ | ||
--url 'https://github.com/elastic/apm-agent-php' \ | ||
--maintainer 'APM Team <[email protected]>' \ | ||
--license 'ASL 2.0' \ | ||
--vendor 'Elasticsearch, Inc.' \ | ||
--description "PHP agent for Elastic APM\nGit Commit: ${GIT_SHA}" \ | ||
--package $(OUTPUT) \ | ||
--chdir /app \ | ||
--after-install=packaging/post-install.sh \ | ||
packaging/post-install.sh=$(PHP_AGENT_DIR)/bin/post-install.sh \ | ||
src/ext/modules/=$(PHP_AGENT_DIR)/extensions \ | ||
README.md=$(PHP_AGENT_DIR)/docs/README.md \ | ||
src/ElasticApm=$(PHP_AGENT_DIR)/src \ | ||
src/bootstrap_php_part.php=$(PHP_AGENT_DIR)/src/bootstrap_php_part.php | ||
@echo 'Creating sha512sum ...' | ||
@BINARY=$$(ls -1 $(PWD)/$(OUTPUT)/*.$*) ;\ | ||
sha512sum $$BINARY > $$BINARY.sha512 ;\ | ||
sed -i.bck "s#$(PWD)/$(OUTPUT)/##g" $$BINARY.sha512 ;\ | ||
rm $(PWD)/$(OUTPUT)/*.bck | ||
|
||
.PHONY: rpm | ||
rpm: create-rpm ## Create the rpm installer | ||
-e TYPE=$* \ | ||
-e NAME=$(NAME) \ | ||
-e VERSION=$(VERSION) \ | ||
-e OUTPUT=$(OUTPUT) \ | ||
-e FPM_FLAGS=${FPM_FLAGS} \ | ||
-e PHP_AGENT_DIR=${PHP_AGENT_DIR} \ | ||
-w /app $(IMAGE) | ||
|
||
.PHONY: apk | ||
apk: FPM_FLAGS="--depends=bash" | ||
apk: create-apk ## Create the apk installer | ||
|
||
.PHONY: deb | ||
deb: create-deb ## Create the deb installer | ||
|
||
.PHONY: rpm | ||
rpm: create-rpm ## Create the rpm installer | ||
## TODO: fpm replaces - with _ in the version | ||
|
||
.PHONY: tar | ||
tar: create-tar ## Create the tar.gz | ||
|
||
|
@@ -63,17 +53,16 @@ version: ## Show the fpm version | |
@docker run --rm $(IMAGE) --version | ||
|
||
.PHONY: package | ||
package: rpm deb tar ## Create all the installers | ||
package: apk deb rpm tar ## Create all the installers | ||
|
||
.PHONY: info | ||
info: rpm-info deb-info tar-info ## Show the package metadata for all the installers | ||
info: apk-info deb-info rpm-info tar-info ## Show the package metadata for all the installers | ||
|
||
.PHONY: rpm-info | ||
rpm-info: ## Show the rpm package metadata | ||
.PHONY: apk-info | ||
apk-info: ## Show the apk package metadata | ||
@cd $(PWD) ;\ | ||
BINARY=$$(ls -1 $(OUTPUT)/*.rpm) ;\ | ||
docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/rpm $(IMAGE) -qip $$BINARY ;\ | ||
docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/rpm $(IMAGE) -qlp $$BINARY | ||
BINARY=$$(ls -1 $(OUTPUT)/*.apk) ;\ | ||
docker run --rm -v $(PWD):/app -w /app --entrypoint /sbin/apk $(IMAGE) manifest $$BINARY | ||
|
||
.PHONY: deb-info | ||
deb-info: ## Show the deb package metadata | ||
|
@@ -82,32 +71,46 @@ deb-info: ## Show the deb package metadata | |
docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/dpkg $(IMAGE) --info $$BINARY ;\ | ||
docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/dpkg $(IMAGE) -c $$BINARY | ||
|
||
.PHONY: rpm-info | ||
rpm-info: ## Show the rpm package metadata | ||
@cd $(PWD) ;\ | ||
BINARY=$$(ls -1 $(OUTPUT)/*.rpm) ;\ | ||
docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/rpm $(IMAGE) -qip $$BINARY ;\ | ||
docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/rpm $(IMAGE) -qlp $$BINARY | ||
|
||
.PHONY: tar-info | ||
tar-info: ## Show the tar package metadata | ||
@cd $(PWD) ;\ | ||
BINARY=$$(ls -1 $(OUTPUT)/*.tar) ;\ | ||
docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/tar $(IMAGE) -tvf $$BINARY | ||
|
||
.PHONY: rpm-install | ||
rpm-install: ## Install the rpm installer to run some smoke tests | ||
@cd $(PWD)/packaging/test/centos ;\ | ||
docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t rpm-install . ;\ | ||
.PHONY: apk-install | ||
apk-install: ## Install the apk installer to run some smoke tests | ||
@cd $(PWD)/packaging/test/alpine ;\ | ||
docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t $@ . ;\ | ||
cd - | ||
docker run --rm -v $(PWD):/src -w /src -e TYPE=rpm rpm-install | ||
docker run --rm -v $(PWD):/src -w /src $@ | ||
|
||
.PHONY: deb-install | ||
deb-install: ## Install the deb installer to run some smoke tests | ||
@cd $(PWD)/packaging/test/ubuntu ;\ | ||
docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t deb-install . ;\ | ||
docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t $@ . ;\ | ||
cd - | ||
@docker run --rm -v $(PWD):/src -w /src -e TYPE=deb deb-install | ||
@docker run --rm -v $(PWD):/src -w /src -e TYPE=deb $@ | ||
|
||
.PHONY: tar-install | ||
tar-install: ## Install the tar installer to run some smoke tests | ||
@cd $(PWD)/packaging/test/ubuntu ;\ | ||
docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t tar-install . ;\ | ||
docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t $@ . ;\ | ||
cd - | ||
@docker run --rm -v $(PWD):/src -w /src -e TYPE=tar $@ | ||
|
||
.PHONY: rpm-install | ||
rpm-install: ## Install the rpm installer to run some smoke tests | ||
@cd $(PWD)/packaging/test/centos ;\ | ||
docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t $@ . ;\ | ||
cd - | ||
docker run --rm -v $(PWD):/src -w /src -e TYPE=tar tar-install | ||
@docker run --rm -v $(PWD):/src -w /src -e TYPE=rpm $@ | ||
|
||
.PHONY: install | ||
install: deb-install rpm-install tar-install ## Install all the distributions | ||
install: apk-install deb-install rpm-install tar-install ## Install all the distributions |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the smartest approach but it's native to the CI. So we might need to find a better way in some follow ups