2023-01-10 19:03:30 +00:00
|
|
|
ARG PHP_VERSION=8.2
|
|
|
|
|
2023-06-27 10:27:11 +00:00
|
|
|
# Install base packages which all stages (build, test, run) need
|
|
|
|
FROM debian:bookworm AS base
|
|
|
|
RUN apt update && apt upgrade -y && apt install -y \
|
|
|
|
php${PHP_VERSION}-cli php${PHP_VERSION}-gd php${PHP_VERSION}-zip php${PHP_VERSION}-xml php${PHP_VERSION}-mbstring \
|
|
|
|
php${PHP_VERSION}-pgsql php${PHP_VERSION}-mysql php${PHP_VERSION}-sqlite3 \
|
|
|
|
gosu curl imagemagick ffmpeg zip unzip && \
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Composer has 100MB of dependencies, and we only need that during build and test
|
|
|
|
FROM base AS composer
|
|
|
|
RUN apt update && apt upgrade -y && apt install -y composer php${PHP_VERSION}-xdebug && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2020-03-22 15:23:23 +00:00
|
|
|
# "Build" shimmie (composer install - done in its own stage so that we don't
|
|
|
|
# need to include all the composer fluff in the final image)
|
2023-06-27 10:27:11 +00:00
|
|
|
FROM composer AS app
|
2020-03-22 15:23:23 +00:00
|
|
|
COPY composer.json composer.lock /app/
|
|
|
|
WORKDIR /app
|
2020-03-25 19:43:28 +00:00
|
|
|
RUN composer install --no-dev
|
|
|
|
COPY . /app/
|
|
|
|
|
|
|
|
# Tests in their own image. Really we should inherit from app and then
|
|
|
|
# `composer install` phpunit on top of that; but for some reason
|
|
|
|
# `composer install --no-dev && composer install` doesn't install dev
|
2023-06-27 10:27:11 +00:00
|
|
|
FROM composer AS tests
|
2020-03-25 19:43:28 +00:00
|
|
|
COPY composer.json composer.lock /app/
|
|
|
|
WORKDIR /app
|
2020-03-22 15:23:23 +00:00
|
|
|
RUN composer install
|
|
|
|
COPY . /app/
|
|
|
|
ARG RUN_TESTS=true
|
|
|
|
RUN [ $RUN_TESTS = false ] || (\
|
|
|
|
echo '=== Installing ===' && mkdir -p data/config && INSTALL_DSN="sqlite:data/shimmie.sqlite" php index.php && \
|
|
|
|
echo '=== Smoke Test ===' && php index.php get-page /post/list && \
|
|
|
|
echo '=== Unit Tests ===' && ./vendor/bin/phpunit --configuration tests/phpunit.xml && \
|
2023-06-27 10:27:11 +00:00
|
|
|
echo '=== Coverage ===' && XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text && \
|
2020-03-22 15:23:23 +00:00
|
|
|
echo '=== Cleaning ===' && rm -rf data)
|
|
|
|
|
|
|
|
# Actually run shimmie
|
2023-06-27 10:27:11 +00:00
|
|
|
FROM base
|
2018-11-07 00:43:01 +00:00
|
|
|
EXPOSE 8000
|
2021-07-24 18:28:18 +00:00
|
|
|
HEALTHCHECK --interval=1m --timeout=3s CMD curl --fail http://127.0.0.1:8000/ || exit 1
|
2020-03-22 15:23:23 +00:00
|
|
|
ENV UID=1000 \
|
2023-06-27 00:55:32 +00:00
|
|
|
GID=1000 \
|
|
|
|
UPLOAD_MAX_FILESIZE=50M
|
2020-03-25 19:36:41 +00:00
|
|
|
COPY --from=app /app /app
|
2018-11-07 00:43:01 +00:00
|
|
|
|
|
|
|
WORKDIR /app
|
2020-03-19 14:58:55 +00:00
|
|
|
CMD ["/bin/sh", "/app/tests/docker-init.sh"]
|