From 425f2544531c06b7fed7ba2d4574e136846fda98 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 5 Mar 2019 13:39:45 +0100 Subject: [PATCH 1/3] Added posgres container for development --- data/infra/database_pg/.gitignore | 2 ++ data/infra/db.Dockerfile | 6 ------ data/infra/nginx.Dockerfile | 5 ----- data/infra/php.Dockerfile | 3 +++ data/infra/swoole.Dockerfile | 3 +++ docker-compose.override.yml.dist | 14 +++++++++++++- docker-compose.yml | 27 +++++++++++++++++++-------- 7 files changed, 40 insertions(+), 20 deletions(-) create mode 100755 data/infra/database_pg/.gitignore delete mode 100644 data/infra/db.Dockerfile delete mode 100644 data/infra/nginx.Dockerfile diff --git a/data/infra/database_pg/.gitignore b/data/infra/database_pg/.gitignore new file mode 100755 index 00000000..d6b7ef32 --- /dev/null +++ b/data/infra/database_pg/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/data/infra/db.Dockerfile b/data/infra/db.Dockerfile deleted file mode 100644 index a17b488a..00000000 --- a/data/infra/db.Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM mysql:5.7 -MAINTAINER Alejandro Celaya - -# Enable remote access (default is localhost only, we change this -# otherwise our database would not be reachable from outside the container) -RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf diff --git a/data/infra/nginx.Dockerfile b/data/infra/nginx.Dockerfile deleted file mode 100644 index e3d90df9..00000000 --- a/data/infra/nginx.Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM nginx:1.11.6-alpine -MAINTAINER Alejandro Celaya - -# Delete default nginx vhost -RUN rm /etc/nginx/conf.d/default.conf diff --git a/data/infra/php.Dockerfile b/data/infra/php.Dockerfile index e0e2c104..19454a48 100644 --- a/data/infra/php.Dockerfile +++ b/data/infra/php.Dockerfile @@ -28,6 +28,9 @@ RUN docker-php-ext-install zip RUN apk add --no-cache --virtual libpng-dev RUN docker-php-ext-install gd +RUN apk add --no-cache postgresql-dev +RUN docker-php-ext-install pdo_pgsql + # Install redis extension ADD https://github.com/phpredis/phpredis/archive/$PREDIS_VERSION.tar.gz /tmp/phpredis.tar.gz RUN mkdir -p /usr/src/php/ext/redis\ diff --git a/data/infra/swoole.Dockerfile b/data/infra/swoole.Dockerfile index e77c2d56..1695e82c 100644 --- a/data/infra/swoole.Dockerfile +++ b/data/infra/swoole.Dockerfile @@ -27,6 +27,9 @@ RUN docker-php-ext-install zip RUN apk add --no-cache --virtual libpng-dev RUN docker-php-ext-install gd +RUN apk add --no-cache postgresql-dev +RUN docker-php-ext-install pdo_pgsql + # Install redis extension ADD https://github.com/phpredis/phpredis/archive/$PREDIS_VERSION.tar.gz /tmp/phpredis.tar.gz RUN mkdir -p /usr/src/php/ext/redis\ diff --git a/docker-compose.override.yml.dist b/docker-compose.override.yml.dist index 6e40c113..ec9d24da 100644 --- a/docker-compose.override.yml.dist +++ b/docker-compose.override.yml.dist @@ -1,4 +1,4 @@ -version: '2' +version: '3' services: shlink_php: @@ -12,3 +12,15 @@ services: volumes: - /etc/passwd:/etc/passwd:ro - /etc/group:/etc/group:ro + + shlink_db: + user: 1000:1000 + volumes: + - /etc/passwd:/etc/passwd:ro + - /etc/group:/etc/group:ro + + shlink_db_postgres: + user: 1000:1000 + volumes: + - /etc/passwd:/etc/passwd:ro + - /etc/group:/etc/group:ro diff --git a/docker-compose.yml b/docker-compose.yml index 3424d925..5d60a061 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,15 @@ -version: '2' +version: '3' services: shlink_nginx: container_name: shlink_nginx - build: - context: . - dockerfile: ./data/infra/nginx.Dockerfile + image: nginx:1.15.9-alpine ports: - "8000:80" volumes: - ./:/home/shlink/www - ./docs:/home/shlink/www/public/docs - - ./data/infra/vhost.conf:/etc/nginx/conf.d/shlink-vhost.conf + - ./data/infra/vhost.conf:/etc/nginx/conf.d/default.conf links: - shlink_php @@ -25,6 +23,7 @@ services: - ./data/infra/php.ini:/usr/local/etc/php/php.ini links: - shlink_db + - shlink_db_postgres shlink_swoole: container_name: shlink_swoole @@ -37,12 +36,11 @@ services: - ./:/home/shlink links: - shlink_db + - shlink_db_postgres shlink_db: container_name: shlink_db - build: - context: . - dockerfile: ./data/infra/db.Dockerfile + image: mysql:5.7 ports: - "3307:3306" volumes: @@ -51,3 +49,16 @@ services: environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: shlink + + shlink_db_postgres: + container_name: shlink_db_postgres + image: postgres:10.7-alpine + ports: + - "5433:5432" + volumes: + - ./:/home/shlink/www + - ./data/infra/database_pg:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: root + POSTGRES_DB: shlink + PGDATA: /var/lib/postgresql/data/pgdata From 0f81c3ab92ec72fae00618560f8d80ae4ef7ceaf Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 5 Mar 2019 13:50:44 +0100 Subject: [PATCH 2/3] Fixed error when using postgres in a SELECT count query where a ORDER BY was added by mistake --- module/Core/src/Repository/VisitRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/Core/src/Repository/VisitRepository.php b/module/Core/src/Repository/VisitRepository.php index 06c7f252..19d10c21 100644 --- a/module/Core/src/Repository/VisitRepository.php +++ b/module/Core/src/Repository/VisitRepository.php @@ -50,7 +50,8 @@ DQL; ?int $offset = null ): array { $qb = $this->createVisitsByShortCodeQueryBuilder($shortCode, $dateRange); - $qb->select('v'); + $qb->select('v') + ->orderBy('v.date', 'DESC'); if ($limit !== null) { $qb->setMaxResults($limit); @@ -76,8 +77,7 @@ DQL; $qb->from(Visit::class, 'v') ->join('v.shortUrl', 'su') ->where($qb->expr()->eq('su.shortCode', ':shortCode')) - ->setParameter('shortCode', $shortCode) - ->orderBy('v.date', 'DESC') ; + ->setParameter('shortCode', $shortCode); // Apply date range filtering if ($dateRange !== null && $dateRange->getStartDate() !== null) { From a63447b12b14d5d645e748319b53cdda0f636318 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 5 Mar 2019 14:17:47 +0100 Subject: [PATCH 3/3] Updated changelog --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd2b34ce..8b9560a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## 1.16.2 - 2019-03-05 + +#### Added + +* *Nothing* + +#### Changed + +* *Nothing* + +#### Deprecated + +* *Nothing* + +#### Removed + +* *Nothing* + +#### Fixed + +* [#368](https://github.com/shlinkio/shlink/issues/368) Fixed error produced when running a `SELECT COUNT(...)` with `ORDER BY` in PostgreSQL databases. + + ## 1.16.1 - 2019-02-26 #### Added