shlink/Dockerfile

70 lines
2.6 KiB
Text
Raw Permalink Normal View History

2024-02-11 13:22:48 +03:00
FROM php:8.3-alpine3.19 as base
2019-08-16 19:38:26 +03:00
ARG SHLINK_VERSION=latest
2021-01-30 12:08:33 +03:00
ENV SHLINK_VERSION ${SHLINK_VERSION}
ARG SHLINK_RUNTIME=rr
ENV SHLINK_RUNTIME ${SHLINK_RUNTIME}
2024-02-13 10:55:22 +03:00
ENV USER_ID '1001'
2024-02-11 13:22:48 +03:00
ENV PDO_SQLSRV_VERSION 5.12.0
ENV MS_ODBC_DOWNLOAD 'b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486'
ENV MS_ODBC_SQL_VERSION 18_18.1.1.1
ENV LC_ALL 'C'
2019-08-16 19:38:26 +03:00
WORKDIR /etc/shlink
# Install required PHP extensions
2019-08-16 19:38:26 +03:00
RUN \
# Temp install dev dependencies needed to compile the extensions
2022-12-14 17:01:00 +03:00
apk add --no-cache --virtual .dev-deps sqlite-dev postgresql-dev icu-dev libzip-dev zlib-dev libpng-dev linux-headers && \
docker-php-ext-install -j"$(nproc)" pdo_mysql pdo_pgsql intl calendar sockets bcmath zip gd && \
apk add --no-cache sqlite-libs && \
2019-08-16 19:38:26 +03:00
docker-php-ext-install -j"$(nproc)" pdo_sqlite && \
# Remove temp dev extensions, and install prod equivalents that are required at runtime
apk del .dev-deps && \
apk add --no-cache postgresql icu libzip libpng
2019-08-16 19:38:26 +03:00
2024-02-12 22:29:40 +03:00
# Install sqlsrv driver for x86_64 builds
RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} unixodbc-dev && \
if [ $(uname -m) == "x86_64" ]; then \
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 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 && \
rm msodbcsql${MS_ODBC_SQL_VERSION}-1_amd64.apk ; \
fi; \
2020-05-05 22:58:23 +03:00
apk del .phpize-deps
2019-08-16 19:38:26 +03:00
# Install shlink
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 && \
2024-02-17 01:02:46 +03:00
php composer.phar install --no-dev --prefer-dist --optimize-autoloader --no-progress --no-interaction && \
php composer.phar clear-cache && \
2020-03-22 12:01:34 +03: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 19:38:26 +03:00
2024-02-13 10:55:22 +03:00
COPY --from=builder --chown=${USER_ID} /etc/shlink .
RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink && \
if [ "$SHLINK_RUNTIME" == 'rr' ]; then \
php ./vendor/bin/rr get --no-interaction --no-config --location bin/ && chmod +x bin/rr ; \
fi;
2019-08-16 19:38:26 +03:00
# Expose default 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
2024-02-13 10:55:22 +03:00
USER ${USER_ID}
2021-06-14 01:51:16 +03:00
2019-08-16 19:38:26 +03:00
ENTRYPOINT ["/bin/sh", "./docker-entrypoint.sh"]