improved Dockerfile

- fixed cpu architecture
- Removed unnecessary build args
This commit is contained in:
pushrbx 2023-06-05 20:06:11 +01:00
parent 8561ddb043
commit 40812e814d
2 changed files with 16 additions and 19 deletions

View File

@ -2,7 +2,6 @@ FROM spiralscout/roadrunner:2.12.2 as roadrunner
FROM composer:2.5.1 as composer
FROM mlocati/php-extension-installer:1.5.52 as php-ext-installer
FROM php:8.1.16-bullseye
ARG GITHUB_PERSONAL_TOKEN
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=php-ext-installer /usr/bin/install-php-extensions /usr/local/bin/
ENV COMPOSER_HOME="/tmp/composer"
@ -14,8 +13,6 @@ RUN set -x \
# install roadrunner
COPY --from=roadrunner /usr/bin/rr /usr/bin/rr
LABEL org.opencontainers.image.source=https://github.com/jikan-me/jikan-rest
# used only for supercronic atm. Supported values are: amd64, arm64
ARG TARGET_ARCH="amd64"
RUN set -ex \
&& apt-get update && apt-get install -y --no-install-recommends \
openssl \
@ -24,7 +21,7 @@ RUN set -ex \
unzip \
wget \
# install supercronic (for laravel task scheduling), project page: <https://github.com/aptible/supercronic>
&& wget -q "https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-${TARGET_ARCH}" \
&& wget -q "https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-$(dpkg --print-architecture)" \
-O /usr/bin/supercronic \
&& chmod +x /usr/bin/supercronic \
&& mkdir /etc/supercronic \
@ -51,11 +48,6 @@ WORKDIR /app
# copy composer (json|lock) files for dependencies layer caching
COPY --chown=jikanapi:jikanapi ./composer.* /app/
# 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
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
# install composer dependencies (autoloader MUST be generated later!)
RUN composer install -n --no-dev --no-cache --no-ansi --no-autoloader --no-scripts --prefer-dist

View File

@ -25,14 +25,6 @@ docker build -t jikan-rest:nightly .
docker run -d --name=jikan-rest -p 8080:8080 -v ./.env:/app/.env jikan-rest:nightly
```
If you need a different CPU architecture, set the `TARGET_ARCH` build argument:
```bash
docker build -t jikan-rest:nightly --build-arg TARGET_ARCH=arm64 .
```
`TARGET_ARCH` is `amd64` by default.
### Docker compose usage
```
@ -42,10 +34,23 @@ docker-compose up
Docker compose will use the `.env` file from the folder where you execute it from to load configurations for the
services. If you don't have a `.env` file yet in the folder, copy the `.env.dist` file, and set the passwords.
Docker compose will start up a production ready setup with redis, typesense and mongodb.
Change the environment variables for the `jikan_rest` service in the `docker-compose.yml` file to customise the configuration of the Jikan API.
By default docker-compose sets it to:
- Not use [queuing](https://laravel.com/docs/9.x/scout#queueing) for search requests. (Not yet supported for typesense.)
- Use typesense search for more accurate search results
- Use redis for microcaching and caching.
- Add CORS headers to responses
Of course these defaults can be overridden through the `.env` file or through setting environment variables in the command-line before executing `docker-compose up`.
> **Please note**: The syntax rules of docker compose for `.env` applies
> here: https://docs.docker.com/compose/env-file/#syntax-rules
#### Note for Podman
> **Additional configuration**: You can change the mongodb memory usage via `MONGO_CACHE_SIZE_GB` environment variable.
> It sets how many gigabytes of memory is available for wired tiger. Default is `1`. This is useful for systems with low memory capacity.
### Note for Podman
If you build the container image yourself with podman, the resulting image format will be OCI by default.
To make the health checks work in that situation you need to run the container the following way:
@ -54,7 +59,7 @@ To make the health checks work in that situation you need to run the container t
podman run -d --name=jikan-rest -p 8080:8080 -v ./.env:/app/.env --health-start-period=5s --health-cmd="curl --fail http://localhost:2114/health?plugin=http || exit 1" jikan-rest:nightly
```
#### Configuration of the container
### Configuration of the container
You can change the settings of Jikan through setting environment variables via the `-e` command line argument option for
the `docker run` command.