2022-12-14 08:01:00 -06:00
|
|
|
FROM php:8.2-alpine3.17 as base
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2021-03-01 14:17:32 -06:00
|
|
|
ARG SHLINK_VERSION=latest
|
2021-01-30 03:08:33 -06:00
|
|
|
ENV SHLINK_VERSION ${SHLINK_VERSION}
|
2023-04-16 06:10:24 -05:00
|
|
|
ARG SHLINK_RUNTIME=rr
|
2022-08-27 06:01:38 -05:00
|
|
|
ENV SHLINK_RUNTIME ${SHLINK_RUNTIME}
|
2023-05-19 12:38:36 -05:00
|
|
|
ARG SHLINK_USER_ID='root'
|
|
|
|
ENV SHLINK_USER_ID ${SHLINK_USER_ID}
|
|
|
|
|
2023-04-14 01:58:54 -05:00
|
|
|
ENV OPENSWOOLE_VERSION 22.0.0
|
2022-08-05 09:31:15 -05:00
|
|
|
ENV PDO_SQLSRV_VERSION 5.10.1
|
2022-12-10 12:15:38 -06:00
|
|
|
ENV MS_ODBC_DOWNLOAD 'b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486'
|
|
|
|
ENV MS_ODBC_SQL_VERSION 18_18.1.1.1
|
2023-05-19 12:38:36 -05:00
|
|
|
ENV LC_ALL 'C'
|
2019-08-16 11:38:26 -05:00
|
|
|
|
|
|
|
WORKDIR /etc/shlink
|
|
|
|
|
2020-11-02 02:02:00 -06:00
|
|
|
# Install required PHP extensions
|
2019-08-16 11:38:26 -05:00
|
|
|
RUN \
|
2022-01-03 11:48:08 -06:00
|
|
|
# Temp install dev dependencies needed to compile the extensions
|
2022-12-14 08:01:00 -06:00
|
|
|
apk add --no-cache --virtual .dev-deps sqlite-dev postgresql-dev icu-dev libzip-dev zlib-dev libpng-dev linux-headers && \
|
2022-01-03 12:10:58 -06:00
|
|
|
docker-php-ext-install -j"$(nproc)" pdo_mysql pdo_pgsql intl calendar sockets bcmath zip gd && \
|
2022-01-03 11:48:08 -06:00
|
|
|
apk add --no-cache sqlite-libs && \
|
2019-08-16 11:38:26 -05:00
|
|
|
docker-php-ext-install -j"$(nproc)" pdo_sqlite && \
|
2022-01-03 11:48:08 -06:00
|
|
|
# Remove temp dev extensions, and install prod equivalents that are required at runtime
|
|
|
|
apk del .dev-deps && \
|
2022-01-03 12:10:58 -06:00
|
|
|
apk add --no-cache postgresql icu libzip libpng
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2022-01-03 12:34:36 -06:00
|
|
|
# Install openswoole and sqlsrv driver for x86_64 builds
|
|
|
|
RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} unixodbc-dev && \
|
2022-08-27 06:01:38 -05:00
|
|
|
if [ "$SHLINK_RUNTIME" == 'openswoole' ]; then \
|
|
|
|
pecl install openswoole-${OPENSWOOLE_VERSION} && \
|
|
|
|
docker-php-ext-enable openswoole ; \
|
|
|
|
fi; \
|
2022-01-03 12:34:36 -06:00
|
|
|
if [ $(uname -m) == "x86_64" ]; then \
|
2022-12-10 12:15:38 -06:00
|
|
|
wget https://download.microsoft.com/download/${MS_ODBC_DOWNLOAD}/msodbcsql${MS_ODBC_SQL_VERSION}-1_amd64.apk && \
|
|
|
|
apk add --allow-untrusted msodbcsql${MS_ODBC_SQL_VERSION}-1_amd64.apk && \
|
2021-01-30 02:45:47 -06:00
|
|
|
pecl install pdo_sqlsrv-${PDO_SQLSRV_VERSION} && \
|
2020-05-05 14:58:23 -05:00
|
|
|
docker-php-ext-enable pdo_sqlsrv && \
|
2022-12-10 12:15:38 -06:00
|
|
|
rm msodbcsql${MS_ODBC_SQL_VERSION}-1_amd64.apk ; \
|
2022-01-03 12:34:36 -06:00
|
|
|
fi; \
|
2020-05-05 14:58:23 -05:00
|
|
|
apk del .phpize-deps
|
2020-03-21 02:56:48 -05:00
|
|
|
|
2019-08-16 11:38:26 -05:00
|
|
|
# Install shlink
|
2020-03-21 02:56:48 -05:00
|
|
|
FROM base as builder
|
2019-08-16 11:38:26 -05:00
|
|
|
COPY . .
|
2020-10-25 11:59:37 -05:00
|
|
|
COPY --from=composer:2 /usr/bin/composer ./composer.phar
|
2020-03-22 04:01:34 -05:00
|
|
|
RUN apk add --no-cache git && \
|
2023-04-19 11:57:35 -05:00
|
|
|
# FIXME Ignoring ext-openswoole platform req, as it makes install fail with roadrunner, even though it's a dev dependency and we are passing --no-dev
|
|
|
|
php composer.phar install --no-dev --prefer-dist --optimize-autoloader --no-progress --no-interaction --ignore-platform-req=ext-openswoole && \
|
2022-08-27 06:01:38 -05:00
|
|
|
if [ "$SHLINK_RUNTIME" == 'openswoole' ]; then \
|
2023-04-19 11:57:35 -05:00
|
|
|
php composer.phar remove spiral/roadrunner spiral/roadrunner-jobs spiral/roadrunner-cli spiral/roadrunner-http --with-all-dependencies --update-no-dev --optimize-autoloader --no-progress --no-interaction ; \
|
|
|
|
elif [ "$SHLINK_RUNTIME" == 'rr' ]; then \
|
2023-05-19 12:38:36 -05:00
|
|
|
php composer.phar remove mezzio/mezzio-swoole --with-all-dependencies --update-no-dev --optimize-autoloader --no-progress --no-interaction --ignore-platform-req=ext-openswoole ; \
|
2022-08-27 06:01:38 -05:00
|
|
|
fi; \
|
2020-03-21 10:11:56 -05:00
|
|
|
php composer.phar clear-cache && \
|
2020-03-22 04:01:34 -05:00
|
|
|
rm -r docker composer.* && \
|
2020-03-21 02:56:48 -05:00
|
|
|
sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php
|
|
|
|
|
|
|
|
|
|
|
|
# Prepare final image
|
|
|
|
FROM base
|
|
|
|
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2023-05-19 12:38:36 -05:00
|
|
|
COPY --from=builder --chown=${SHLINK_USER_ID} /etc/shlink .
|
2022-08-27 06:01:38 -05:00
|
|
|
RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink && \
|
|
|
|
if [ "$SHLINK_RUNTIME" == 'rr' ]; then \
|
2023-05-02 01:43:14 -05:00
|
|
|
php ./vendor/bin/rr get --no-interaction --no-config --location bin/ && chmod +x bin/rr ; \
|
2022-08-27 06:01:38 -05:00
|
|
|
fi;
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2022-08-27 06:01:38 -05:00
|
|
|
# Expose default port
|
2019-08-16 11:38:26 -05:00
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
# 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
|
2019-12-18 07:54:48 -06:00
|
|
|
COPY docker/config/php.ini ${PHP_INI_DIR}/conf.d/
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2023-05-19 12:38:36 -05:00
|
|
|
USER ${SHLINK_USER_ID}
|
2021-06-13 17:51:16 -05:00
|
|
|
|
2019-08-16 11:38:26 -05:00
|
|
|
ENTRYPOINT ["/bin/sh", "./docker-entrypoint.sh"]
|