mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-24 16:10:38 -06:00
Merge pull request #850 from acelaya-forks/feature/env-docker-port
Feature/env docker port
This commit is contained in:
commit
d426dbc684
@ -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 `<field>-<dir>` 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
|
||||
|
@ -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 <alejandro@alejandrocelaya.com>"
|
||||
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
|
||||
|
@ -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
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -159,6 +159,7 @@ return [
|
||||
|
||||
'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),
|
||||
|
@ -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' => [
|
||||
|
@ -67,6 +67,7 @@ class SimplifiedConfigParserTest extends TestCase
|
||||
'anonymize_remote_addr' => false,
|
||||
'redirect_status_code' => 301,
|
||||
'redirect_cache_lifetime' => 90,
|
||||
'port' => 8888,
|
||||
];
|
||||
$expected = [
|
||||
'app_options' => [
|
||||
@ -132,6 +133,7 @@ class SimplifiedConfigParserTest extends TestCase
|
||||
|
||||
'mezzio-swoole' => [
|
||||
'swoole-http-server' => [
|
||||
'port' => 8888,
|
||||
'options' => [
|
||||
'task_worker_num' => 50,
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user