Skip to content

Commit

Permalink
Add custom php.ini, Improve Docker (#71)
Browse files Browse the repository at this point in the history
This update includes adding a custom php.ini configuration file for
Docker and updating the JBZoo/Utils and several other dependencies.
Composer.lock and composer.json have been updated accordingly. Further
details include changing the Dockerfile to replace PHP's default
configuration file with a custom one and adjusting the composer
installation commands. Makefile's execution info is also updated in
verbosity mode for demo commands.
  • Loading branch information
SmetDenis committed Mar 23, 2024
1 parent ac2f1c0 commit 695ec55
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 142 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.idea
.github
build
/docker/preload.php
tests
vendor
.DS_Store
Expand All @@ -22,6 +23,7 @@ vendor
.gitignore
.phan.php
.phpunit.result.cache
.php-cs-fixer.cache
action.yml
box.json.dist
phpunit.xml.dist
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,26 +233,26 @@ jobs:
run: make build-docker

- name: Test help and logo
run: docker run --rm jbzoo/csv-blueprint --ansi
run: time docker run --rm jbzoo/csv-blueprint-local --ansi

- name: 👍 Valid CSV file
run: |
docker run --rm \
time docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint \
jbzoo/csv-blueprint-local \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_valid.yml \
--ansi
--ansi -vvv
- name: 👎 Invalid CSV file
run: |
! docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint \
jbzoo/csv-blueprint-local \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/invalid_schema.yml \
--schema=/parent-host/tests/schemas/demo_invalid.yml \
--schema=/parent-host/tests/schemas/demo_valid.yml \
--ansi
--ansi -vvv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
build
vendor
phpunit.xml
/docker/preload.php
*.cache
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@
#

FROM php:8.3-cli-alpine
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

# Install PHP extensions
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions opcache gd @composer
RUN install-php-extensions opcache @composer

# Install application
ENV COMPOSER_ALLOW_SUPERUSER=1
COPY . /app
RUN cd /app \
&& composer install --no-dev --optimize-autoloader --no-progress \
&& composer clear-cache
RUN chmod +x /app/csv-blueprint
RUN cd /app \
&& composer install --no-dev \
--no-progress \
&& composer clear-cache \
&& chmod +x /app/csv-blueprint

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY docker/php.ini /usr/local/etc/php/conf.d/docker-z99-php.ini

# Test and warmup opcache
RUN /app/csv-blueprint validate:csv -h

ENTRYPOINT ["/app/csv-blueprint"]
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test-all: ##@Project Run all project tests at once

build-docker:
$(call title,"Building Docker Image")
@docker build -t jbzoo/csv-blueprint .
@docker build -t jbzoo/csv-blueprint-local .


demo-valid: ##@Project Run demo valid CSV
Expand All @@ -64,15 +64,15 @@ demo-docker: ##@Project Run demo via Docker
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_valid.yml \
--ansi
--ansi -vvv
$(call title,"Demo - Invalid CSV \(via Docker\)")
@docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_invalid.yml \
--ansi
--ansi -vvv


demo-invalid: ##@Project Run demo invalid CSV
Expand All @@ -94,3 +94,9 @@ demo-github: ##@Project Run demo invalid CSV
demo: ##@Project Run all demo commands
@make demo-valid
@make demo-invalid


preload: ##@Project Preload all classes
@${PHP_BIN} ./vendor/bin/classpreloader compile \
--config=./docker/preload-config.php \
--output=./docker/preload.php
29 changes: 17 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,23 @@
"prefer-stable" : true,

"require" : {
"php" : "^8.1",
"ext-mbstring" : "*",
"league/csv" : "^9.15.0",
"jbzoo/data" : "^7.1.1",
"jbzoo/cli" : "^7.1.8",
"jbzoo/utils" : "^7.1.2",
"jbzoo/ci-report-converter" : "^7.2.1",
"symfony/yaml" : ">=6.4.3",
"symfony/filesystem" : ">=6.4.3",
"symfony/finder" : ">=6.4.0",
"markrogoyski/math-php" : "^2.9.0",
"respect/validation" : "^2.3.5"
"php" : "^8.1",
"ext-mbstring" : "*",

"league/csv" : "^9.15.0",
"jbzoo/data" : "^7.1.1",
"jbzoo/cli" : "^7.1.8",
"jbzoo/utils" : "^7.2.0",
"jbzoo/ci-report-converter" : "^7.2.1",

"symfony/yaml" : ">=6.4.3",
"symfony/filesystem" : ">=6.4.3",
"symfony/finder" : ">=6.4.0",
"markrogoyski/math-php" : "^2.9.0",
"respect/validation" : "^2.3.5",

"classpreloader/classpreloader" : "^4.2",
"classpreloader/console" : "^3.2"
},

"require-dev" : {
Expand Down

0 comments on commit 695ec55

Please sign in to comment.