shlink/Dockerfile

87 lines
3.1 KiB
Docker
Raw Normal View History

2021-12-07 03:43:36 -06:00
FROM php:8.1.0-alpine3.15 as base
2019-08-16 11:38:26 -05:00
ARG SHLINK_VERSION=latest
2021-01-30 03:08:33 -06:00
ENV SHLINK_VERSION ${SHLINK_VERSION}
ENV OPENSWOOLE_VERSION 4.8.1
2021-12-02 13:55:50 -06:00
ENV PDO_SQLSRV_VERSION 5.10.0beta2
2021-09-26 03:03:07 -05:00
ENV MS_ODBC_SQL_VERSION 17.5.2.2
ENV LC_ALL "C"
2019-08-16 11:38:26 -05:00
WORKDIR /etc/shlink
# Install required PHP extensions
2019-08-16 11:38:26 -05:00
RUN \
# Install mysql and calendar
2019-08-16 11:38:26 -05:00
docker-php-ext-install -j"$(nproc)" pdo_mysql calendar && \
# Install sqlite
apk add --no-cache sqlite-libs sqlite-dev && \
docker-php-ext-install -j"$(nproc)" pdo_sqlite && \
# Install postgres
apk add --no-cache postgresql-dev && \
docker-php-ext-install -j"$(nproc)" pdo_pgsql && \
# Install intl
2019-08-16 11:38:26 -05:00
apk add --no-cache icu-dev && \
docker-php-ext-install -j"$(nproc)" intl && \
2019-08-16 11:38:26 -05:00
# Install zip and gd
apk add --no-cache libzip-dev zlib-dev libpng-dev && \
docker-php-ext-install -j"$(nproc)" zip gd && \
# Install gmp
apk add --no-cache gmp-dev && \
docker-php-ext-install -j"$(nproc)" gmp
2019-08-16 11:38:26 -05:00
2020-05-05 14:58:23 -05:00
# Install sqlsrv driver
RUN if [ $(uname -m) == "x86_64" ]; then \
2021-05-23 02:05:04 -05:00
wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_${MS_ODBC_SQL_VERSION}-1_amd64.apk && \
apk add --allow-untrusted msodbcsql17_${MS_ODBC_SQL_VERSION}-1_amd64.apk && \
apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} unixodbc-dev && \
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 && \
apk del .phpize-deps && \
2021-05-23 02:05:04 -05:00
rm msodbcsql17_${MS_ODBC_SQL_VERSION}-1_amd64.apk ; \
2020-05-05 14:58:23 -05:00
fi
2019-08-16 11:38:26 -05:00
# Install openswoole
RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} && \
pecl install openswoole-${OPENSWOOLE_VERSION} && \
docker-php-ext-enable openswoole && \
2020-05-05 14:58:23 -05:00
apk del .phpize-deps
2019-08-16 11:38:26 -05:00
# Install shlink
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 && \
php composer.phar install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction && \
php composer.phar clear-cache && \
2020-03-22 04:01:34 -05:00
rm -r docker composer.* && \
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
COPY --from=builder /etc/shlink .
2019-08-16 11:38:26 -05:00
RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink
# Expose default openswoole 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
2021-06-13 17:51:16 -05:00
# Change the ownership of /etc/shlink/data to be writable, then change the user to non-root
# 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-13 17:51:16 -05:00
2019-08-16 11:38:26 -05:00
ENTRYPOINT ["/bin/sh", "./docker-entrypoint.sh"]