Merge pull request #581 from acelaya-forks/feature/improve-dockers

Feature/improve dockers
This commit is contained in:
Alejandro Celaya 2019-12-18 15:38:03 +01:00 committed by GitHub
commit 9222dcbc2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 48 additions and 58 deletions

View file

@ -1,10 +0,0 @@
# Application
APP_ENV=
SECRET_KEY=
SHORTENED_URL_SCHEMA=
SHORTENED_URL_HOSTNAME=
# Database
DB_USER=
DB_PASSWORD=
DB_NAME=

1
.gitattributes vendored
View file

@ -9,7 +9,6 @@
/module/PreviewGenerator/test-db export-ignore
/module/Rest/test export-ignore
/module/Rest/test-api export-ignore
.env.dist export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.phpstorm.meta.php export-ignore

1
.gitignore vendored
View file

@ -4,7 +4,6 @@ build
composer.lock
composer.phar
vendor/
.env
data/database.sqlite
data/shlink-tests.db
data/GeoLite2-City.mmdb

View file

@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* [#492](https://github.com/shlinkio/shlink/issues/492) Updated to monolog 2, together with other dependencies, like Symfony 5 and infection-php.
* [#527](https://github.com/shlinkio/shlink/issues/527) Increased minimum required mutation score for unit tests to 80%.
* [#557](https://github.com/shlinkio/shlink/issues/557) Added a few php.ini configs for development and production docker images.
#### Deprecated

View file

@ -1,7 +1,7 @@
FROM php:7.3.11-alpine3.10
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
ARG SHLINK_VERSION=1.20.0
ARG SHLINK_VERSION=1.20.2
ENV SHLINK_VERSION ${SHLINK_VERSION}
ENV SWOOLE_VERSION 4.4.12
ENV COMPOSER_VERSION 1.9.1
@ -52,5 +52,6 @@ VOLUME /etc/shlink/config/params
# Copy config specific for the image
COPY docker/docker-entrypoint.sh docker-entrypoint.sh
COPY docker/config/shlink_in_docker.local.php config/autoload/shlink_in_docker.local.php
COPY docker/config/php.ini ${PHP_INI_DIR}/conf.d/
ENTRYPOINT ["/bin/sh", "./docker-entrypoint.sh"]

View file

@ -65,7 +65,6 @@
"roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.0.0",
"shlinkio/shlink-test-utils": "^1.2",
"symfony/dotenv": "^5.0",
"symfony/var-dumper": "^5.0"
},
"autoload": {

View file

@ -11,9 +11,9 @@ return [
'proxies_dir' => 'data/proxies',
],
'connection' => [
'user' => env('DB_USER'),
'password' => env('DB_PASSWORD'),
'dbname' => env('DB_NAME', 'shlink'),
'user' => '',
'password' => '',
'dbname' => 'shlink',
'charset' => 'utf8',
],
],

View file

@ -1,8 +1,13 @@
<?php
declare(strict_types=1);
return [
'entity_manager' => [
'connection' => [
'user' => 'root',
'password' => 'root',
'driver' => 'pdo_mysql',
'host' => 'shlink_db',
'driverOptions' => [

View file

@ -2,14 +2,12 @@
declare(strict_types=1);
use function Shlinkio\Shlink\Common\env;
return [
'url_shortener' => [
'domain' => [
'schema' => env('SHORTENED_URL_SCHEMA', 'http'),
'hostname' => env('SHORTENED_URL_HOSTNAME'),
'schema' => 'https',
'hostname' => '',
],
'validate_url' => true,
],

View file

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
return [
'url_shortener' => [
'domain' => [
'schema' => 'http',
'hostname' => 'localhost:8080',
],
],
];

View file

@ -2,21 +2,12 @@
declare(strict_types=1);
use Symfony\Component\Dotenv\Dotenv;
use Zend\ServiceManager\ServiceManager;
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
// If the Dotenv class exists, load env vars and enable errors
if (class_exists(Dotenv::class)) {
error_reporting(E_ALL);
ini_set('display_errors', '1');
$dotenv = new Dotenv(true);
$dotenv->load(__DIR__ . '/../.env');
}
// Build container
$config = require __DIR__ . '/config.php';
$container = new ServiceManager($config['dependencies']);

View file

@ -7,14 +7,6 @@ namespace Shlinkio\Shlink\TestUtils;
use Doctrine\ORM\EntityManager;
use Psr\Container\ContainerInterface;
use function file_exists;
use function touch;
// Create an empty .env file
if (! file_exists('.env')) {
touch('.env');
}
/** @var ContainerInterface $container */
$container = require __DIR__ . '/../container.php';
$testHelper = $container->get(Helper\TestHelper::class);

View file

@ -6,14 +6,6 @@ namespace Shlinkio\Shlink\TestUtils;
use Psr\Container\ContainerInterface;
use function file_exists;
use function touch;
// Create an empty .env file
if (! file_exists('.env')) {
touch('.env');
}
/** @var ContainerInterface $container */
$container = require __DIR__ . '/../container.php';
$container->get(Helper\TestHelper::class)->createTestDb();

View file

@ -1 +1,6 @@
date.timezone = Europe/Madrid
display_errors=On
error_reporting=-1
memory_limit=-1
log_errors_max_len=0
zend.assertions=1
assert.exception=1

View file

@ -3,7 +3,7 @@ version: '3'
services:
shlink_nginx:
container_name: shlink_nginx
image: nginx:1.15.9-alpine
image: nginx:1.17.6-alpine
ports:
- "8000:80"
volumes:
@ -37,6 +37,7 @@ services:
- "9001:9001"
volumes:
- ./:/home/shlink
- ./data/infra/php.ini:/usr/local/etc/php/php.ini
links:
- shlink_db
- shlink_db_postgres

3
docker/config/php.ini Normal file
View file

@ -0,0 +1,3 @@
log_errors_max_len=0
zend.assertions=1
assert.exception=1

View file

@ -46,7 +46,7 @@ class ListShortUrlsTest extends ApiTestCase
'longUrl' =>
'https://blog.alejandrocelaya.com/2017/12/09'
. '/acmailer-7-0-the-most-important-release-in-a-long-time/',
'dateCreated' => '2019-01-01T00:00:00+00:00',
'dateCreated' => '2019-01-01T00:00:10+00:00',
'visitsCount' => 2,
'tags' => ['bar', 'foo'],
'meta' => [
@ -62,7 +62,7 @@ class ListShortUrlsTest extends ApiTestCase
'shortCode' => 'custom',
'shortUrl' => 'http://doma.in/custom',
'longUrl' => 'https://shlink.io',
'dateCreated' => '2019-01-01T00:00:00+00:00',
'dateCreated' => '2019-01-01T00:00:20+00:00',
'visitsCount' => 0,
'tags' => [],
'meta' => [
@ -78,7 +78,7 @@ class ListShortUrlsTest extends ApiTestCase
'longUrl' =>
'https://blog.alejandrocelaya.com/2019/04/27'
. '/considerations-to-properly-use-open-source-software-projects/',
'dateCreated' => '2019-01-01T00:00:00+00:00',
'dateCreated' => '2019-01-01T00:00:30+00:00',
'visitsCount' => 0,
'tags' => [],
'meta' => [

View file

@ -22,32 +22,32 @@ class ShortUrlsFixture extends AbstractFixture
{
$abcShortUrl = $this->setShortUrlDate(
new ShortUrl('https://shlink.io', ShortUrlMeta::createFromRawData(['customSlug' => 'abc123'])),
Chronos::parse('2018-05-01')
'2018-05-01'
);
$manager->persist($abcShortUrl);
$defShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://blog.alejandrocelaya.com/2017/12/09/acmailer-7-0-the-most-important-release-in-a-long-time/',
ShortUrlMeta::createFromParams(Chronos::parse('2020-05-01'), null, 'def456')
));
), '2019-01-01 00:00:10');
$manager->persist($defShortUrl);
$customShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://shlink.io',
ShortUrlMeta::createFromParams(null, null, 'custom', 2)
));
), '2019-01-01 00:00:20');
$manager->persist($customShortUrl);
$withDomainShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://blog.alejandrocelaya.com/2019/04/27/considerations-to-properly-use-open-source-software-projects/',
ShortUrlMeta::createFromRawData(['domain' => 'example.com', 'customSlug' => 'ghi789'])
));
), '2019-01-01 00:00:30');
$manager->persist($withDomainShortUrl);
$withDomainAndSlugShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://google.com',
ShortUrlMeta::createFromRawData(['domain' => 'some-domain.com', 'customSlug' => 'custom-with-domain'])
), Chronos::parse('2018-10-20'));
), '2018-10-20');
$manager->persist($withDomainAndSlugShortUrl);
$manager->flush();
@ -56,12 +56,12 @@ class ShortUrlsFixture extends AbstractFixture
$this->addReference('def456_short_url', $defShortUrl);
}
private function setShortUrlDate(ShortUrl $shortUrl, ?Chronos $date = null): ShortUrl
private function setShortUrlDate(ShortUrl $shortUrl, string $date): ShortUrl
{
$ref = new ReflectionObject($shortUrl);
$dateProp = $ref->getProperty('dateCreated');
$dateProp->setAccessible(true);
$dateProp->setValue($shortUrl, $date ?? Chronos::parse('2019-01-01'));
$dateProp->setValue($shortUrl, Chronos::parse($date));
return $shortUrl;
}