PHP-Programmierer chatten hier
Anonymous
Die Laravel -API in Docker gibt HTML anstelle von JSON zurück
Post
by Anonymous » 06 Apr 2025, 21:05
lokal mit PHP Artisan serve oder Symfony serve Alles funktioniert gut und arbeitet seit Jahren. Ich bin kein Experte in Docker. Und die Rückgabe jeder API-Route ist wie diese Antwort ()-> json ($ data);
Dies ist meine Dockerfile und wird in einer Docker-Compos-Datei verwendet. Warum bin ich nicht erfolgreich? < /P>
Code: Select all
FROM php:8.3-fpm-alpine3.20
RUN apk update && apk upgrade
# Essentials
RUN echo "Europe/London" > /etc/timezone
RUN apk add git zip unzip curl sqlite supervisor
# Install Python
RUN apk add python3 py3-pip
RUN apk add nodejs npm
RUN apk add nano
RUN apk add php83-gd \
php83-imap \
php83-redis \
php83-cgi \
php83-bcmath \
php83-mysqli \
php83-zlib \
php83-curl \
php83-zip \
php83-mbstring \
php83-iconv \
gmp-dev
# dependencies required for running "phpize"
# these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed)
ENV PHPIZE_DEPS \
autoconf \
dpkg-dev \
dpkg \
file \
g++ \
gcc \
libc-dev \
make \
pkgconf \
re2c \
zlib \
wget
# Install packages
RUN set -eux; \
# Packages needed only for build
apk add --virtual .build-deps \
$PHPIZE_DEPS
RUN apk add --no-cache linux-headers
# Packages to install
RUN apk add curl \
gettext-dev \
libmcrypt-dev \
icu-dev \
libpng \
libpng-dev \
libressl-dev \
libtool \
libxml2-dev \
libzip-dev \
libjpeg-turbo-dev \
libwebp-dev \
freetype-dev \
oniguruma-dev \
unzip
# pecl PHP extensions
RUN pecl install \
# imagick-3.4.4 \
mongodb \
redis
# Configure PHP extensions
RUN docker-php-ext-configure \
# ref: https://github.com/docker-library/php/issues/920#issuecomment-562864296
gd --enable-gd --with-freetype --with-jpeg --with-webp
# Install PHP extensions
RUN docker-php-ext-install \
bcmath \
bz2 \
exif \
ftp \
gettext \
gd \
# iconv \
intl \
gmp \
mbstring \
opcache \
pdo \
pdo_mysql \
shmop \
sockets \
sysvmsg \
sysvsem \
sysvshm \
zip \
&& \
# Enable PHP extensions
docker-php-ext-enable \
# imagick \
mongodb \
redis \
&& \
# Remove the build deps
apk del .build-deps
RUN apk cache clean
# fix work iconv library with alphine for PHP 8.1 broken
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so
# # Installing bash
# RUN apk add bash
# RUN sed -i 's/bin\/ash/bin\/bash/g' /etc/passwd
# Installing composer
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php
RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN rm -rf composer-setup.php
# Configure supervisor
RUN mkdir -p /etc/supervisord/conf.d/
RUN touch /run/supervisord.sock
COPY ./docker-ops/backend/supervisord/laravel-worker.conf /etc/supervisord/conf.d/laravel-worker.conf
COPY ./docker-ops/backend/supervisord/supervisord.ini /etc/supervisord/supervisord.ini
# Cron Config
COPY ./docker-ops/backend/crontab /etc/crontabs/root
# Config PHP
COPY ./docker-ops/backend/php/local.ini /usr/local/etc/php/php.ini
# COPY ./ /var/www
COPY --chown=www-data:www-data ./my-app /var/www
COPY ./docker-ops/backend/scripts.env /var/www/resources/scripts/.env
COPY ./docker-ops/backend/.env.laravel /var/www/.env
# Install Python packages
ENV PIP_BREAK_SYSTEM_PACKAGES 1
RUN pip install -r /var/www/resources/scripts/requirements.txt
USER root
WORKDIR /var/www
EXPOSE 8000
CMD ["php", "artisan", "serve", "--host", "0.0.0.0", "--port=8000"]```
1743966320
Anonymous
lokal mit PHP Artisan serve oder Symfony serve Alles funktioniert gut und arbeitet seit Jahren. Ich bin kein Experte in Docker. Und die Rückgabe jeder API-Route ist wie diese Antwort ()-> json ($ data); Dies ist meine Dockerfile und wird in einer Docker-Compos-Datei verwendet. Warum bin ich nicht erfolgreich? < /P> [code]FROM php:8.3-fpm-alpine3.20 RUN apk update && apk upgrade # Essentials RUN echo "Europe/London" > /etc/timezone RUN apk add git zip unzip curl sqlite supervisor # Install Python RUN apk add python3 py3-pip RUN apk add nodejs npm RUN apk add nano RUN apk add php83-gd \ php83-imap \ php83-redis \ php83-cgi \ php83-bcmath \ php83-mysqli \ php83-zlib \ php83-curl \ php83-zip \ php83-mbstring \ php83-iconv \ gmp-dev # dependencies required for running "phpize" # these get automatically installed and removed by "docker-php-ext-*" (unless they're already installed) ENV PHPIZE_DEPS \ autoconf \ dpkg-dev \ dpkg \ file \ g++ \ gcc \ libc-dev \ make \ pkgconf \ re2c \ zlib \ wget # Install packages RUN set -eux; \ # Packages needed only for build apk add --virtual .build-deps \ $PHPIZE_DEPS RUN apk add --no-cache linux-headers # Packages to install RUN apk add curl \ gettext-dev \ libmcrypt-dev \ icu-dev \ libpng \ libpng-dev \ libressl-dev \ libtool \ libxml2-dev \ libzip-dev \ libjpeg-turbo-dev \ libwebp-dev \ freetype-dev \ oniguruma-dev \ unzip # pecl PHP extensions RUN pecl install \ # imagick-3.4.4 \ mongodb \ redis # Configure PHP extensions RUN docker-php-ext-configure \ # ref: https://github.com/docker-library/php/issues/920#issuecomment-562864296 gd --enable-gd --with-freetype --with-jpeg --with-webp # Install PHP extensions RUN docker-php-ext-install \ bcmath \ bz2 \ exif \ ftp \ gettext \ gd \ # iconv \ intl \ gmp \ mbstring \ opcache \ pdo \ pdo_mysql \ shmop \ sockets \ sysvmsg \ sysvsem \ sysvshm \ zip \ && \ # Enable PHP extensions docker-php-ext-enable \ # imagick \ mongodb \ redis \ && \ # Remove the build deps apk del .build-deps RUN apk cache clean # fix work iconv library with alphine for PHP 8.1 broken ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so # # Installing bash # RUN apk add bash # RUN sed -i 's/bin\/ash/bin\/bash/g' /etc/passwd # Installing composer RUN curl -sS https://getcomposer.org/installer -o composer-setup.php RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer RUN rm -rf composer-setup.php # Configure supervisor RUN mkdir -p /etc/supervisord/conf.d/ RUN touch /run/supervisord.sock COPY ./docker-ops/backend/supervisord/laravel-worker.conf /etc/supervisord/conf.d/laravel-worker.conf COPY ./docker-ops/backend/supervisord/supervisord.ini /etc/supervisord/supervisord.ini # Cron Config COPY ./docker-ops/backend/crontab /etc/crontabs/root # Config PHP COPY ./docker-ops/backend/php/local.ini /usr/local/etc/php/php.ini # COPY ./ /var/www COPY --chown=www-data:www-data ./my-app /var/www COPY ./docker-ops/backend/scripts.env /var/www/resources/scripts/.env COPY ./docker-ops/backend/.env.laravel /var/www/.env # Install Python packages ENV PIP_BREAK_SYSTEM_PACKAGES 1 RUN pip install -r /var/www/resources/scripts/requirements.txt USER root WORKDIR /var/www EXPOSE 8000 CMD ["php", "artisan", "serve", "--host", "0.0.0.0", "--port=8000"]``` [/code]
0 Replies
29 Views
Last post by Anonymous
29 Dec 2024, 10:51
0 Replies
14 Views
Last post by Anonymous
12 Feb 2025, 04:14
0 Replies
18 Views
Last post by Guest
12 Feb 2025, 07:46
0 Replies
35 Views
Last post by Anonymous
23 Feb 2025, 16:58
0 Replies
9 Views
Last post by Guest
24 Feb 2025, 04:37