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

Rewrite the app to stick to the compose spec #64

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
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
42 changes: 25 additions & 17 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,36 @@ name: Deploy
on:
push:
branches:
- master
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-node-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Extract metadata for Docker
id: metadata
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker images
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: pmsipilot/docker-compose-viz
tag_with_ref: true
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
vendor/
docker.lock
bin/
coverage/
vendor/

!bin/dcv
!bin/entrypoint.sh
.cache/
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
docker.lock
16 changes: 16 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
;

$rules = [
'@PSR12' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
];

return (new PhpCsFixer\Config())->setRules($rules)
->setFinder($finder)
;
18 changes: 0 additions & 18 deletions .php_cs

This file was deleted.

8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-alpine as builder
FROM php:8.1-alpine as builder

COPY composer.json /dcv/composer.json
COPY composer.lock /dcv/composer.lock
Expand All @@ -10,16 +10,16 @@ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&
php -r "unlink('composer-setup.php');" && \
php composer.phar install --prefer-dist

FROM php:7.4-alpine
FROM php:8.1-alpine

RUN apk update && \
apk add graphviz ttf-dejavu && \
rm -rf \
/var/cache/apk/* \
/tmp/*

COPY bin/ /dcv/bin
COPY src/ /dcv/src
COPY bin/ /dcv/bin/
COPY src/ /dcv/src/
COPY --from=builder /dcv/vendor /dcv/vendor

RUN chmod +x /dcv/bin/dcv
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ docker: docker.lock

test: vendor unit cs

vendor: vendor/composer/installed.json

unit: vendor
$(COMPOSER) run ut

Expand All @@ -24,10 +26,10 @@ clean:
rm -rf vendor/

docker.lock: Dockerfile bin/entrypoint.sh vendor src/application.php src/functions.php
$(DOCKER) build -t $(DCV_IMAGE_NAME) .
$(DOCKER) build -t $(DCV_IMAGE_NAME) --no-cache .
touch docker.lock

vendor: composer.lock
vendor/composer/installed.json: composer.lock
$(COMPOSER) install --prefer-dist

composer.lock: composer.json
Expand Down
4 changes: 3 additions & 1 deletion bin/dcv
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ require_once resolve(
]
);

require_once resolve(
$application = require_once resolve(
[
__DIR__,
'..',
'src',
'application.php',
]
);

$application->run();
?>
32 changes: 23 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "pmsipilot/docker-compose-viz",
"description": "Docker compose graph visualization",
"require": {
"php": "^7.2",
"symfony/yaml": "^3.1 || ^4",
"symfony/console": "^3.1",
"php": "^8.1",
"symfony/yaml": "^5.4",
"symfony/console": "^5.4",
"clue/graph": "^0.9",
"graphp/graphviz": "^0.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2",
"kahlan/kahlan": "^4.7"
"friendsofphp/php-cs-fixer": "^v3.12.0",
"kahlan/kahlan": "*",
"phpunit/phpunit": "^9.5"
},
"license": "MIT",
"authors": [
Expand All @@ -20,14 +21,27 @@
}
],
"autoload": {
"files": ["src/functions.php"],
"files": [
"src/config.php",
"src/functions.php",
"src/network.php",
"src/port.php",
"src/secret.php",
"src/service.php",
"src/volume.php"
],
"psr-4": {
"PMSIpilot\\DockerComposeViz\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"PMSIpilot\\DockerComposeViz\\Tests\\": "tests/"
}
},
"scripts": {
"cs": "php-cs-fixer fix",
"cst": "php-cs-fixer fix --dry-run",
"ut": "kahlan --grep='*.php' --reporter=verbose --persistent=false"
"cs": "php-cs-fixer fix --allow-risky=yes",
"cst": "php-cs-fixer fix --dry-run --allow-risky=yes",
"ut": "phpunit tests --testdox --color"
}
}
Loading