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)
|
2022-02-10 05:25:49 +00:00
|
|
|
FROM debian:stable AS app
|
2019-12-10 01:13:24 +00:00
|
|
|
RUN apt update && apt install -y composer php7.4-gd php7.4-dom php7.4-sqlite3 php-xdebug imagemagick
|
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
|
2022-02-10 05:25:49 +00:00
|
|
|
FROM debian:stable AS tests
|
2019-12-10 01:13:24 +00:00
|
|
|
RUN apt update && apt install -y composer php7.4-gd php7.4-dom php7.4-sqlite3 php-xdebug imagemagick
|
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 && \
|
|
|
|
echo '=== Coverage ===' && ./vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text && \
|
|
|
|
echo '=== Cleaning ===' && rm -rf data)
|
|
|
|
|
|
|
|
# Build su-exec so that our final image can be nicer
|
2022-02-10 05:25:49 +00:00
|
|
|
FROM debian:stable AS suexec
|
2020-03-22 15:23:23 +00:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends gcc libc-dev curl
|
|
|
|
RUN curl -k -o /usr/local/bin/su-exec.c https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c; \
|
|
|
|
gcc -Wall /usr/local/bin/su-exec.c -o/usr/local/bin/su-exec; \
|
|
|
|
chown root:root /usr/local/bin/su-exec; \
|
|
|
|
chmod 0755 /usr/local/bin/su-exec;
|
|
|
|
|
|
|
|
# Actually run shimmie
|
2022-02-10 05:25:49 +00:00
|
|
|
FROM debian:stable
|
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 \
|
|
|
|
GID=1000
|
2020-03-19 14:52:54 +00:00
|
|
|
RUN apt update && apt install -y curl \
|
2019-12-10 01:13:24 +00:00
|
|
|
php7.4-cli php7.4-gd php7.4-pgsql php7.4-mysql php7.4-sqlite3 php7.4-zip php7.4-dom php7.4-mbstring \
|
2020-03-25 19:37:38 +00:00
|
|
|
imagemagick zip unzip && \
|
2020-03-22 15:23:23 +00:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
2020-03-25 19:36:41 +00:00
|
|
|
COPY --from=app /app /app
|
|
|
|
COPY --from=suexec /usr/local/bin/su-exec /usr/local/bin/su-exec
|
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"]
|