2022-10-25 23:54:52 +01:00
|
|
|
ARG BASE_IMAGE_VERSION="latest"
|
2022-10-23 15:55:03 +01:00
|
|
|
FROM jikanme/jikan-rest-php:${BASE_IMAGE_VERSION}
|
2022-09-10 16:58:13 +01:00
|
|
|
ARG GITHUB_PERSONAL_TOKEN
|
2022-10-23 15:55:03 +01:00
|
|
|
LABEL org.opencontainers.image.source=https://github.com/jikan-me/jikan-rest
|
2022-07-14 16:44:45 +01:00
|
|
|
RUN set -ex \
|
|
|
|
&& apt-get update && apt-get install -y --no-install-recommends \
|
|
|
|
openssl \
|
|
|
|
git \
|
|
|
|
dos2unix \
|
2022-08-15 10:05:25 +01:00
|
|
|
unzip \
|
|
|
|
wget \
|
|
|
|
# install supercronic (for laravel task scheduling), project page: <https://github.com/aptible/supercronic>
|
2022-07-14 16:44:45 +01:00
|
|
|
&& wget -q "https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64" \
|
|
|
|
-O /usr/bin/supercronic \
|
|
|
|
&& chmod +x /usr/bin/supercronic \
|
|
|
|
&& mkdir /etc/supercronic \
|
|
|
|
&& echo '*/1 * * * * php /app/artisan schedule:run' > /etc/supercronic/laravel \
|
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
|
|
# enable opcache for CLI and JIT, docs: <https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit>
|
|
|
|
&& echo -e "\nopcache.enable=1\nopcache.enable_cli=1\nopcache.jit_buffer_size=32M\nopcache.jit=1235\n" >> \
|
|
|
|
${PHP_INI_DIR}/conf.d/docker-php-ext-opcache.ini \
|
|
|
|
# show installed modules
|
|
|
|
&& php -m \
|
|
|
|
# create unpriviliged user
|
|
|
|
&& adduser --disabled-password --shell "/sbin/nologin" --home "/nonexistent" --no-create-home --uid "10001" --gecos "" "jikanapi" \
|
|
|
|
&& mkdir /app /var/run/rr \
|
2022-09-10 16:58:13 +01:00
|
|
|
&& chown -R jikanapi:jikanapi /app /var/run/rr /etc/supercronic/laravel \
|
2022-07-14 16:44:45 +01:00
|
|
|
&& chmod -R 777 /var/run/rr
|
|
|
|
|
|
|
|
USER jikanapi:jikanapi
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# copy composer (json|lock) files for dependencies layer caching
|
|
|
|
COPY --chown=jikanapi:jikanapi ./composer.* /app/
|
|
|
|
|
2022-09-04 16:20:44 +01:00
|
|
|
# check if GITHUB_PERSONAL_TOKEN is set and configure it for composer
|
|
|
|
# it is recommended to set this for the build, otherwise the build might fail because of github's rate limits
|
2022-09-10 16:58:13 +01:00
|
|
|
RUN if [ -z "$GITHUB_PERSONAL_TOKEN" ]; then echo "** GITHUB_PERSONAL_TOKEN is not set. This build may fail due to github rate limits."; \
|
|
|
|
else composer config github-oauth.github.com "$GITHUB_PERSONAL_TOKEN"; fi
|
2022-09-04 16:20:44 +01:00
|
|
|
|
2022-07-14 16:44:45 +01:00
|
|
|
# install composer dependencies (autoloader MUST be generated later!)
|
|
|
|
RUN composer install -n --no-dev --no-cache --no-ansi --no-autoloader --no-scripts --prefer-dist
|
|
|
|
|
|
|
|
# copy application sources into image (completely)
|
|
|
|
COPY --chown=jikanapi:jikanapi . /app/
|
|
|
|
|
|
|
|
RUN set -ex \
|
|
|
|
&& composer update jikan-me/jikan \
|
|
|
|
&& composer dump-autoload -n --optimize \
|
|
|
|
&& chmod -R 777 ${COMPOSER_HOME}/cache \
|
|
|
|
&& chmod -R a+w storage/ \
|
2022-08-17 20:39:43 +01:00
|
|
|
&& chown -R jikanapi:jikanapi /app \
|
|
|
|
&& chmod +x docker-entrypoint.php \
|
|
|
|
&& chmod +x docker-entrypoint.sh
|
2022-07-14 16:44:45 +01:00
|
|
|
|
2022-08-17 15:51:21 +01:00
|
|
|
EXPOSE 8080
|
|
|
|
EXPOSE 2114
|
|
|
|
|
|
|
|
HEALTHCHECK CMD curl --fail http://localhost:2114/health?plugin=http || exit 1
|
|
|
|
|
2022-08-15 13:16:40 +01:00
|
|
|
# unset default image entrypoint.
|
2022-08-17 15:51:21 +01:00
|
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|