Closed Moskito89 closed 4 months ago
Hello @Moskito89!
Can you show content of your's compose.yaml
, compose.override.yaml
and Dockerfile
files?
Hello @Moskito89!
Can you show content of your's
compose.yaml
,compose.override.yaml
andDockerfile
files?
Sure!
compose.yaml
services:
php:
image: ${IMAGES_PREFIX:-}app-php
restart: unless-stopped
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}
TRUSTED_HOSTS: ^${SERVER_NAME:-example\.com|localhost}|php$$
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: mysql://${MYSQL_USER:-app}:${MYSQL_PASSWORD:-!ChangeMe!}@database:3306/${MYSQL_DATABASE:-app}?serverVersion=${MYSQL_VERSION:-8}&charset=${MYSQL_CHARSET:-utf8mb4}
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure}
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
# The two next lines can be removed after initial installation
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
STABILITY: ${STABILITY:-stable}
RUN_MIGRATIONS: true
volumes:
- caddy_data:/data
- caddy_config:/config
- var_log:/app/var/log
ports:
# HTTP
- target: 80
published: ${HTTP_PORT:-80}
protocol: tcp
# HTTPS
- target: 443
published: ${HTTPS_PORT:-443}
protocol: tcp
# HTTP/3
- target: 443
published: ${HTTP3_PORT:-443}
protocol: udp
# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###
###> doctrine/doctrine-bundle ###
database:
image: mysql:${MYSQL_VERSION:-8}
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE:-app}
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-!ChangeMe!}
MYSQL_USER: ${MYSQL_USER:-app}
volumes:
- database_data:/var/lib/mysql:rw
# - ./docker/db/data:/var/lib/mysql:rw
###< doctrine/doctrine-bundle ###
php-worker:
build:
context: .
target: frankenphp_dev
image: ${IMAGES_PREFIX:-}app-php
restart: unless-stopped
command: php -d memory_limit=-1 bin/console messenger:consume async -vv
environment:
DATABASE_URL: mysql://${MYSQL_USER:-app}:${MYSQL_PASSWORD:-!ChangeMe!}@database:3306/${MYSQL_DATABASE:-app}?serverVersion=${MYSQL_VERSION:-8}&charset=${MYSQL_CHARSET:-utf8mb4}
RUN_MIGRATIONS: false
volumes:
- var_log:/app/var/log
depends_on:
- php
- database
volumes:
caddy_data:
caddy_config:
var_log:
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###
###> doctrine/doctrine-bundle ###
database_data:
###< doctrine/doctrine-bundle ###
compose.override.yaml
# Development environment override
services:
php:
build:
context: .
target: frankenphp_dev
volumes:
- ./:/app
- ./frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro
- ./frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro
# If you develop on Mac or Windows you can remove the vendor/ directory
# from the bind-mount for better performance by enabling the next line:
- /app/vendor
environment:
MERCURE_EXTRA_DIRECTIVES: demo
# See https://xdebug.org/docs/all_settings#mode
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
extra_hosts:
# Ensure that host.docker.internal is correctly defined on Linux
- host.docker.internal:host-gateway
tty: true
php-worker:
volumes:
- ./:/app
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###
###> doctrine/doctrine-bundle ###
database:
ports:
- "3306"
###< doctrine/doctrine-bundle ###
###> symfony/mailer ###
mailer:
image: axllent/mailpit
ports:
- "1025"
- "8025"
environment:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
###< symfony/mailer ###
Dockerfile
#syntax=docker/dockerfile:1.4
# Versions
FROM dunglas/frankenphp:1-php8.2 AS frankenphp_upstream
# The different stages of this Dockerfile are meant to be built into separate images
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
# https://docs.docker.com/compose/compose-file/#target
# Base FrankenPHP image
FROM frankenphp_upstream AS frankenphp_base
WORKDIR /app
# persistent / runtime deps
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
acl \
file \
gettext \
git \
ghostscript \
&& rm -rf /var/lib/apt/lists/*
RUN set -eux; \
install-php-extensions \
@composer \
apcu \
intl \
opcache \
zip \
imagick \
gd \
calendar \
ftp \
;
RUN sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1
###> recipes ###
###> doctrine/doctrine-bundle ###
RUN install-php-extensions pdo_mysql
###< doctrine/doctrine-bundle ###
###< recipes ###
COPY --link frankenphp/conf.d/app.ini $PHP_INI_DIR/conf.d/
COPY --link --chmod=755 frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY --link frankenphp/Caddyfile /etc/caddy/Caddyfile
ENTRYPOINT ["docker-entrypoint"]
HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]
# Dev FrankenPHP image
FROM frankenphp_base AS frankenphp_dev
ENV APP_ENV=dev XDEBUG_MODE=off
VOLUME /app/var/
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN set -eux; \
install-php-extensions \
xdebug \
;
COPY --link frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]
# Prod FrankenPHP image
FROM frankenphp_base AS frankenphp_prod
ENV APP_ENV=prod
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/
COPY --link frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile
# prevent the reinstallation of vendors at every changes in the source code
COPY --link composer.* symfony.* ./
RUN set -eux; \
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
# copy sources
COPY --link . ./
RUN rm -Rf frankenphp/
RUN set -eux; \
mkdir -p var/cache var/log; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; sync;
RUN apt-get update && apt-get install -y \
software-properties-common \
npm
RUN npm install npm@latest -g && \
npm install n -g && \
n 20.0
RUN npm install yarn -g
RUN yarn install
RUN yarn build
Compared to the "original" files, those have been modified slighly by adding other dependencies.
Thanks for having a look, @7-zete-7!
For the slowness on MacOS, this has been improved on the latest versions of docker for mac. If that's not enough, have a look at these lines (or in resolved issues) : https://github.com/dunglas/symfony-docker/blob/c7c788aca1080709613d1e3001ddabd7b7f4531d/compose.override.yaml#L13
For your Windows issue, I have no idea and no windows installation to try. The content of your file doesn't really help, it would be better to publish a reproducer
It seems that there are already a number of answers that should help you on Google
Thank you for your advice, @maxhelias. I have already tried to remove the vendor
folder, but could not notice any change.
I have already visited some of the sites you mentioned and, as described at the beginning, checked the issues discussed there. For example, the encoding of the file, line endings, the quotation marks, etc. None of this has helped — or rather, everything seems to be in order. I have not been able to find any errors.
I can try to set up a test repository tomorrow and will send it to you then. Thanks for your help in advance!
@Moskito89, can you show result of the commands below?
ls -lah /usr/local/bin/docker-entrypoint
ls -lah /usr/local/bin
I‘m sorry, @7-zete-7, but I can‘t. Docker tells me, that the container needs to be run, to execute a command. So it seems like it would fail even before.
I tried the basic example on the same system, and it ran correctly. So the problem has something to do with my configuration. Maybe I‘ll find some time do debug that step by step, but that’s currently not the case.
Maybe we should close the issue but mark it as unresolved.
@Moskito89 try the command below to start container.
docker compose run --entrypoint='' php sh
@Moskito89 try the command below to start container.
docker compose run --entrypoint='' php sh
I'm sorry, but nothing happens when I run this command...
Had the same problem, converting Windows line breaks to Unix ones fixed the issue for me.
I think that cloning the repo on Windows causes the issue as I have the correct line breaks when I download the file directly from GitHub. If that is the case, it might be a good idea to tell Windows users to run this command somewhere in the doc:
git config --global core.autocrlf true
@Moskito89 can you move your project to WSL and try to run it from there?
When I try to start the project with
docker compose up --pull always -d --wait
as described, it runs well (but slow) under macOS. Under Windows, an error appears sayingI read some information about that file and checked the encoding and some other things, but all of them seem to be fine. Has anyone got that error too? Has the
COPY
under Windows problems?