2021-12-07 12:43:36 +03:00
|
|
|
FROM php:8.1.0-alpine3.15 as base
|
2019-08-16 19:38:26 +03:00
|
|
|
|
2021-03-01 23:17:32 +03:00
|
|
|
ARG SHLINK_VERSION=latest
|
2021-01-30 12:08:33 +03:00
|
|
|
ENV SHLINK_VERSION ${SHLINK_VERSION}
|
2021-12-05 12:08:10 +03:00
|
|
|
ENV OPENSWOOLE_VERSION 4.8.1
|
2021-12-02 22:55:50 +03:00
|
|
|
ENV PDO_SQLSRV_VERSION 5.10.0beta2
|
2021-09-26 11:03:07 +03:00
|
|
|
ENV MS_ODBC_SQL_VERSION 17.5.2.2
|
2020-02-14 21:44:11 +03:00
|
|
|
ENV LC_ALL "C"
|
2019-08-16 19:38:26 +03:00
|
|
|
|
|
|
|
WORKDIR /etc/shlink
|
|
|
|
|
2020-11-02 11:02:00 +03:00
|
|
|
# Install required PHP extensions
|
2019-08-16 19:38:26 +03:00
|
|
|
RUN \
|
2022-01-03 20:48:08 +03:00
|
|
|
# Temp install dev dependencies needed to compile the extensions
|
2022-01-03 21:10:58 +03:00
|
|
|
apk add --no-cache --virtual .dev-deps sqlite-dev postgresql-dev icu-dev libzip-dev zlib-dev libpng-dev && \
|
|
|
|
docker-php-ext-install -j"$(nproc)" pdo_mysql pdo_pgsql intl calendar sockets bcmath zip gd && \
|
2022-01-03 20:48:08 +03:00
|
|
|
apk add --no-cache sqlite-libs && \
|
2019-08-16 19:38:26 +03:00
|
|
|
docker-php-ext-install -j"$(nproc)" pdo_sqlite && \
|
2022-01-03 20:48:08 +03:00
|
|
|
# Remove temp dev extensions, and install prod equivalents that are required at runtime
|
|
|
|
apk del .dev-deps && \
|
2022-01-03 21:10:58 +03:00
|
|
|
apk add --no-cache postgresql icu libzip libpng
|
2019-08-16 19:38:26 +03:00
|
|
|
|
2022-01-03 21:34:36 +03:00
|
|
|
# Install openswoole and sqlsrv driver for x86_64 builds
|
|
|
|
RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} unixodbc-dev && \
|
|
|
|
pecl install openswoole-${OPENSWOOLE_VERSION} && \
|
|
|
|
docker-php-ext-enable openswoole && \
|
|
|
|
if [ $(uname -m) == "x86_64" ]; then \
|
2021-05-23 10:05:04 +03:00
|
|
|
wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_${MS_ODBC_SQL_VERSION}-1_amd64.apk && \
|
2022-01-03 21:34:36 +03:00
|
|
|
apk add --no-cache --allow-untrusted msodbcsql17_${MS_ODBC_SQL_VERSION}-1_amd64.apk && \
|
2021-01-30 11:45:47 +03:00
|
|
|
pecl install pdo_sqlsrv-${PDO_SQLSRV_VERSION} && \
|
2020-05-05 22:58:23 +03:00
|
|
|
docker-php-ext-enable pdo_sqlsrv && \
|
2021-05-23 10:05:04 +03:00
|
|
|
rm msodbcsql17_${MS_ODBC_SQL_VERSION}-1_amd64.apk ; \
|
2022-01-03 21:34:36 +03:00
|
|
|
fi; \
|
2020-05-05 22:58:23 +03:00
|
|
|
apk del .phpize-deps
|
2020-03-21 10:56:48 +03:00
|
|
|
|
2019-08-16 19:38:26 +03:00
|
|
|
# Install shlink
|
2020-03-21 10:56:48 +03:00
|
|
|
FROM base as builder
|
2019-08-16 19:38:26 +03:00
|
|
|
COPY . .
|
2020-10-25 19:59:37 +03:00
|
|
|
COPY --from=composer:2 /usr/bin/composer ./composer.phar
|
2020-03-22 12:01:34 +03:00
|
|
|
RUN apk add --no-cache git && \
|
|
|
|
php composer.phar install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction && \
|
2020-03-21 18:11:56 +03:00
|
|
|
php composer.phar clear-cache && \
|
2020-03-22 12:01:34 +03:00
|
|
|
rm -r docker composer.* && \
|
2020-03-21 10:56:48 +03: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 19:38:26 +03:00
|
|
|
|
2020-03-21 10:56:48 +03:00
|
|
|
COPY --from=builder /etc/shlink .
|
2019-08-16 19:38:26 +03:00
|
|
|
RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink
|
|
|
|
|
2021-12-05 12:08:10 +03:00
|
|
|
# Expose default openswoole port
|
2019-08-16 19:38:26 +03: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 16:54:48 +03:00
|
|
|
COPY docker/config/php.ini ${PHP_INI_DIR}/conf.d/
|
2019-08-16 19:38:26 +03:00
|
|
|
|
2021-06-14 01:51:16 +03:00
|
|
|
# Change the ownership of /etc/shlink/data to be writable, then change the user to non-root
|
2021-08-01 09:55:39 +03:00
|
|
|
# FIXME Disabled for now, as it conflicts with ENABLE_PERIODIC_VISIT_LOCATE, which is used to configure a cron as root.
|
|
|
|
# Ref: https://github.com/shlinkio/shlink/issues/1132
|
|
|
|
#RUN chown 1001 /etc/shlink/data
|
|
|
|
#RUN chown 1001 /etc/shlink/data/locks
|
|
|
|
#RUN chown 1001 /etc/shlink/data/proxies
|
|
|
|
#RUN chown 1001 /etc/shlink/data/cache
|
|
|
|
#RUN chown 1001 /etc/shlink/data/log
|
|
|
|
#USER 1001
|
2021-06-14 01:51:16 +03:00
|
|
|
|
2019-08-16 19:38:26 +03:00
|
|
|
ENTRYPOINT ["/bin/sh", "./docker-entrypoint.sh"]
|