diff --git a/CHANGELOG.md b/CHANGELOG.md index ba16ae5e6..df10baf77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * REST endpoint: `GET /rest/v2/domains` * CLI Command: `domain:list` +* [#832](https://github.com/shlinkio/shlink/issues/832) Added support to customize the port in which the docker image listens by using the `PORT` env var or the `port` config option. + #### Changed * [#836](https://github.com/shlinkio/shlink/issues/836) Added support for the `-` notation while determining how to order the short URLs list, as in `?orderBy=shortCode-DESC`. This effectively deprecates the array notation (`?orderBy[shortCode]=DESC`), that will be removed in Shlink 3.0.0 diff --git a/Dockerfile b/Dockerfile index 1cd764e08..0c5411e2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM php:7.4.9-alpine3.12 as base -ARG SHLINK_VERSION=2.2.2 +ARG SHLINK_VERSION=2.3.0 ENV SHLINK_VERSION ${SHLINK_VERSION} ENV SWOOLE_VERSION 4.5.2 ENV LC_ALL "C" @@ -44,7 +44,7 @@ RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS && \ # Install shlink FROM base as builder COPY . . -COPY --from=composer:1.10.1 /usr/bin/composer ./composer.phar +COPY --from=composer:1.10.13 /usr/bin/composer ./composer.phar RUN apk add --no-cache git && \ php composer.phar install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction && \ php composer.phar clear-cache && \ @@ -59,7 +59,7 @@ LABEL maintainer="Alejandro Celaya " COPY --from=builder /etc/shlink . RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink -# Expose swoole port +# Expose default swoole port EXPOSE 8080 # Expose params config dir, since the user is expected to provide custom config from there diff --git a/docker/README.md b/docker/README.md index 89c9565bd..2cc0b5b98 100644 --- a/docker/README.md +++ b/docker/README.md @@ -176,15 +176,17 @@ This is the complete list of supported env vars: * `ANONYMIZE_REMOTE_ADDR`: Tells if IP addresses from visitors should be obfuscated before storing them in the database. Default value is `true`. **Careful!** Setting this to `false` will make your Shlink instance no longer be in compliance with the GDPR and other similar data protection regulations. * `REDIRECT_STATUS_CODE`: Either **301** or **302**. Used to determine if redirects from short to long URLs should be done with a 301 or 302 status. Defaults to 302. * `REDIRECT_CACHE_LIFETIME`: Allows to set the amount of seconds that redirects should be cached when redirect status is 301. Default values is 30. +* `PORT`: Can be used to set the port in which shlink listens. Defaults to 8080 (Some cloud providers, like Google cloud or Heroku, expect to be able to customize exposed port by providing this env var). An example using all env vars could look like this: ```bash docker run \ --name shlink \ - -p 8080:8080 \ + -p 8080:8888 \ -e SHORT_DOMAIN_HOST=doma.in \ -e SHORT_DOMAIN_SCHEMA=https \ + -e PORT=8888 \ -e DB_DRIVER=mysql \ -e DB_NAME=shlink \ -e DB_USER=root \ @@ -257,7 +259,8 @@ The whole configuration should have this format, but it can be split into multip "mercure_jwt_secret": "super_secret_key", "anonymize_remote_addr": false, "redirect_status_code": 301, - "redirect_cache_lifetime": 90 + "redirect_cache_lifetime": 90, + "port": 8888 } ``` diff --git a/docker/config/shlink_in_docker.local.php b/docker/config/shlink_in_docker.local.php index 8d3c55fa4..8efee8a47 100644 --- a/docker/config/shlink_in_docker.local.php +++ b/docker/config/shlink_in_docker.local.php @@ -159,6 +159,7 @@ public function getMercureConfig(): array 'mezzio-swoole' => [ 'swoole-http-server' => [ + 'port' => (int) env('PORT', 8080), 'options' => [ 'worker_num' => (int) env('WEB_WORKER_NUM', 16), 'task_worker_num' => (int) env('TASK_WORKER_NUM', 16), diff --git a/module/Core/src/Config/SimplifiedConfigParser.php b/module/Core/src/Config/SimplifiedConfigParser.php index 38fbdea35..aebeb2c3d 100644 --- a/module/Core/src/Config/SimplifiedConfigParser.php +++ b/module/Core/src/Config/SimplifiedConfigParser.php @@ -40,6 +40,7 @@ class SimplifiedConfigParser 'anonymize_remote_addr' => ['url_shortener', 'anonymize_remote_addr'], 'redirect_status_code' => ['url_shortener', 'redirect_status_code'], 'redirect_cache_lifetime' => ['url_shortener', 'redirect_cache_lifetime'], + 'port' => ['mezzio-swoole', 'swoole-http-server', 'port'], ]; private const SIMPLIFIED_CONFIG_SIDE_EFFECTS = [ 'delete_short_url_threshold' => [ diff --git a/module/Core/test/Config/SimplifiedConfigParserTest.php b/module/Core/test/Config/SimplifiedConfigParserTest.php index 9d4bca696..dc85196ab 100644 --- a/module/Core/test/Config/SimplifiedConfigParserTest.php +++ b/module/Core/test/Config/SimplifiedConfigParserTest.php @@ -67,6 +67,7 @@ public function properlyMapsSimplifiedConfig(): void 'anonymize_remote_addr' => false, 'redirect_status_code' => 301, 'redirect_cache_lifetime' => 90, + 'port' => 8888, ]; $expected = [ 'app_options' => [ @@ -132,6 +133,7 @@ public function properlyMapsSimplifiedConfig(): void 'mezzio-swoole' => [ 'swoole-http-server' => [ + 'port' => 8888, 'options' => [ 'task_worker_num' => 50, ],