Skip to content
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

[docker]Dockerized Resource Bundle #461

Merged
merged 9 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*

!/src
!/composer.json
!/ecs.php
!/phpspec.yml.dist
!/phpstan.neon
!/phpunit.xml.dist
!/psalm.xml
!/rector.php
55 changes: 55 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Docker Image

on:
push:
branches-ignore:
- 'dependabot/**'
paths-ignore:
- "*.md"
pull_request:
paths-ignore:
- "*.md"
schedule:
- cron: "0 1 * * 6" # Run at 1am every Saturday
workflow_dispatch: ~

jobs:
build-image:
name: Build Docker Image and Test Docker Compose
env:
DOCKER_BUILDKIT: 1 # Requires Latest Buildx in docker CLI
COMPOSE_DOCKER_CLI_BUILD: 1 # Requires Latest Buildx in docker compose CLI
strategy:
fail-fast: false
matrix:
platform: [linux/amd64,linux/arm64]

runs-on: ubuntu-latest
steps:
-
name: Set Up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build Image
uses: docker/build-push-action@v3
with:
push: false
platforms: ${{ matrix.platform }}
cache-from: type=gha
cache-to: type=gha
load: true
-
name: Shutdown Default MySQL
run: sudo service mysql stop
-
name: Checkout Code
uses: actions/checkout@v3
-
name: Analyse Package
run: make analyse
-
name: Run Tests
run: make test
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ARG COMPOSER_VERSION=2.3
ARG PHP_VERSION=8.0

FROM composer:${COMPOSER_VERSION} AS composer
FROM mlocati/php-extension-installer AS php_extension_installer

FROM php:${PHP_VERSION}-cli-alpine AS php

COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=php_extension_installer /usr/bin/install-php-extensions /usr/bin/install-php-extensions

RUN install-php-extensions pdo_sqlite

COPY . /app

WORKDIR /app

RUN composer update --with-all-dependencies --no-interaction --no-progress

WORKDIR /app/src/Bundle/test

RUN php bin/console doctrine:database:create && php bin/console doctrine:schema:update --force

WORKDIR /app
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PACKAGE := @docker compose run --rm package

.PHONY:
test:
$(PACKAGE) composer test

.PHONY:
analyse:
$(PACKAGE) composer analyse
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/workflow": "^5.4 || ^6.0",
"symplify/easy-coding-standard": "^10.2",
"twig/twig": "^2.12 || ^3.0",
"vimeo/psalm": "^4.22",
"rector/rector": "^0.13.6"
"rector/rector": "^0.12.20"
},
"suggest": {
"doctrine/orm": "^2.5",
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
package:
build:
context: .
target: php
args:
COMPOSER_VERSION: "2.3"
PHP_VERSION: "8.0"
command: ["composer", "test"]
volumes:
- ./:/package:delegate
2 changes: 0 additions & 2 deletions src/Bundle/Form/Type/ResourceTranslationsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
/** @var TranslatableInterface $translatable */
$translatable = $parentForm->getData();

Assert::nullOrIsInstanceOf($translatable, TranslatableInterface::class);

foreach ($translations as $localeCode => $translation) {
if (null === $translation) {
unset($translations[$localeCode]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public function validate(mixed $value, Constraint $constraint): void
$propertyAccessor = PropertyAccess::createPropertyAccessor();
$collectionOfEntitiesCodes = [];

Assert::isIterable($value);

foreach ($value as $key => $entity) {
/** @var int|string|null $checkingAttribute */
$checkingAttribute = $propertyAccessor->getValue($entity, $constraint->attributePath);
Expand All @@ -39,15 +37,6 @@ public function validate(mixed $value, Constraint $constraint): void
continue;
}

if (!is_string($checkingAttribute) && !is_int($checkingAttribute)) {
throw new \InvalidArgumentException(
\sprintf(
'Expected a string or integer. Got: %s',
\is_object($checkingAttribute) ? \get_class($checkingAttribute) : \gettype($checkingAttribute),
),
);
}

if (!array_key_exists($checkingAttribute, $collectionOfEntitiesCodes)) {
$collectionOfEntitiesCodes[$checkingAttribute] = $key;

Expand Down