Skip to content

Commit

Permalink
Improve Docker build workflow and update Composer setup (#72)
Browse files Browse the repository at this point in the history
Enhanced the Docker environment by configuring additional tagging
options for different events and semantic versions in the Github Actions
workflow. Debug information has also been included. Updated Composer
setup in Dockerfile, by enabling the authoritative class map for better
performance. The "classpreloader/classpreloader" and
"classpreloader/console" dependencies were removed from Composer.
  • Loading branch information
SmetDenis committed Mar 23, 2024
1 parent 695ec55 commit fdeb7b1
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 257 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ jobs:
run: make build-docker

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

- name: 👍 Valid CSV file
run: |
time docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint-local \
jbzoo/csv-blueprint:local \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_valid.yml \
Expand All @@ -249,7 +249,7 @@ jobs:
run: |
! docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint-local \
jbzoo/csv-blueprint:local \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/invalid_schema.yml \
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
name: Publish Docker

on:
push:
branches:
- 'master'
release:
types: [ created ]

jobs:
docker:
name: Docker
name: Publish Docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -39,6 +39,11 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: jbzoo/csv-blueprint:latest
context: .
file: ./docker/Dockerfile
tags: jbzoo/csv-blueprint:${{ github.event.release.tag_name }}
platforms: linux/amd64,linux/arm64/v8,linux/386,

- name: Verify the Docker image
run: docker run --rm jbzoo/csv-blueprint:${{ github.event.release.tag_name }}
75 changes: 36 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.PHONY: build

REPORT ?= table
COLUMNS ?= 150
COLUMNS ?= 300

ifneq (, $(wildcard ./vendor/jbzoo/codestyle/src/init.Makefile))
include ./vendor/jbzoo/codestyle/src/init.Makefile
Expand All @@ -27,26 +27,23 @@ build: ##@Project Install all 3rd party dependencies
@rm -f `pwd`/ci-report-converter


build-install: ##@Project Install all 3rd party dependencies as prod
$(call title,"Install/Update all 3rd party dependencies as prod")
@composer install --no-dev --no-progress --no-interaction --no-suggest --optimize-autoloader
@rm -f `pwd`/ci-report-converter


update: ##@Project Install/Update all 3rd party dependencies
@echo "Composer flags: $(JBZOO_COMPOSER_UPDATE_FLAGS)"
@composer update $(JBZOO_COMPOSER_UPDATE_FLAGS)
@make build-phar


test-all: ##@Project Run all project tests at once
@make test
@make codestyle
build-install: ##@Project Install all 3rd party dependencies as prod
$(call title,"Install/Update all 3rd party dependencies as prod")
@composer install --no-dev --classmap-authoritative
@rm -f `pwd`/ci-report-converter


# Demo #################################################################################################################

build-docker:
$(call title,"Building Docker Image")
@docker build -t jbzoo/csv-blueprint-local .
demo: ##@Project Run all demo commands
@make demo-valid
@make demo-invalid


demo-valid: ##@Project Run demo valid CSV
Expand All @@ -56,25 +53,6 @@ demo-valid: ##@Project Run demo valid CSV
--schema=./tests/schemas/demo_valid.yml \
--skip-schema -v

demo-docker: ##@Project Run demo via Docker
$(call title,"Demo - Valid 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_valid.yml \
--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 -vvv


demo-invalid: ##@Project Run demo invalid CSV
$(call title,"Demo - Invalid CSV")
@${PHP_BIN} ./csv-blueprint validate:csv \
Expand All @@ -91,12 +69,31 @@ demo-github: ##@Project Run demo invalid CSV
--ansi


demo: ##@Project Run all demo commands
@make demo-valid
@make demo-invalid
# Docker ###############################################################################################################

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


docker-in:
@docker run -it --entrypoint /bin/sh jbzoo/csv-blueprint:local

preload: ##@Project Preload all classes
@${PHP_BIN} ./vendor/bin/classpreloader compile \
--config=./docker/preload-config.php \
--output=./docker/preload.php

demo-docker: ##@Project Run demo via Docker
$(call title,"Demo - Valid CSV \(via Docker\)")
@docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint:local \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_valid.yml \
--ansi -vvv
$(call title,"Demo - Invalid CSV \(via Docker\)")
@docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint:local \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_invalid.yml \
--ansi -vvv
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
"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"
"respect/validation" : "^2.3.5"
},

"require-dev" : {
Expand All @@ -62,7 +59,7 @@
},

"config" : {
"optimize-autoloader" : false,
"optimize-autoloader" : true,
"allow-plugins" : {"composer/package-versions-deprecated" : true},
"platform-check" : true
},
Expand Down

0 comments on commit fdeb7b1

Please sign in to comment.