Code Monkey home page Code Monkey logo

symfony-docker's Introduction

Symfony Docker

A Docker-based installer and runtime for the Symfony web framework, with FrankenPHP and Caddy inside!

CI

Getting Started

  1. If not already done, install Docker Compose (v2.10+)
  2. Run docker compose build --no-cache to build fresh images
  3. Run docker compose up --pull always -d --wait to start the project
  4. Open https://localhost in your favorite web browser and accept the auto-generated TLS certificate
  5. Run docker compose down --remove-orphans to stop the Docker containers.

Features

Enjoy!

Docs

  1. Options available
  2. Using Symfony Docker with an existing project
  3. Support for extra services
  4. Deploying in production
  5. Debugging with Xdebug
  6. TLS Certificates
  7. Using MySQL instead of PostgreSQL
  8. Using Alpine Linux instead of Debian
  9. Using a Makefile
  10. Updating the template
  11. Troubleshooting

License

Symfony Docker is available under the MIT License.

Credits

Created by Kévin Dunglas, co-maintained by Maxime Helias and sponsored by Les-Tilleuls.coop.

symfony-docker's People

Contributors

abdounikarim avatar antonkomarev avatar bkosun avatar chalasr avatar coil avatar curry684 avatar dunglas avatar emmanuel-tilleuls avatar fabpot avatar funkyoz avatar garypegeot avatar gponty avatar kajdemunter avatar ker0x avatar loicsapone avatar maks-rafalko avatar mano-lis avatar mateuszsip avatar matiboux avatar maxhelias avatar michaelkaefer avatar mickaelandrieu avatar mmenozzi avatar pyjac avatar qooplmao avatar relthyg avatar robinbrisa avatar thepanz avatar torbenbr avatar webmamba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony-docker's Issues

Help to understand the workflow

Hello,

First of all, sorry for this kind of question, it's not an issue but i'm trying to understand how the Dockerfile and Entry Point are working but, until now, without success... So if you think it's not convenient to do it here, please be free to tell me and delete my post.

From what i understand:

  1. install Flex => you say it's to speed up downloads, but i don't see why it's useful because just after you install Symfony Skeleton ?
  2. create the symfony project skeleton in "production mode" in any cases at the root directory (/srv/app) (row 87)
  3. In the Entry Point: install in /tmp (and move to the root after) the skeleton again but only if composer.json is missing ohterwise just install dependencies. (which makes sense)

i don't see the link between stage 2 and 3 and why there is 2 composer create project ? and why the first create is happening in every cases ? Sorry for these stupid questions...

And thank you so much for your incredible work, this repository works perfectly well but i would like to understand how it's going. I'm quite a beginner with Docker and i read carefully the dockerfile and the logs but it's still not clear for me.
Thank you for your help
Romain

No releases available for package "pecl.php.net/apcu"

fresh installation :

Build complete.
Don't forget to run 'make test'.

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
find . -name *.gcno -o -name *.gcda | xargs rm -f
find . -name *.lo -o -name *.o | xargs rm -f
find . -name *.la -o -name *.a | xargs rm -f
find . -name *.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la modules/* libs/*
WARNING: Ignoring APKINDEX.00740ba1.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.d8b2a6f4.tar.gz: No such file or directory
(1/1) Purging .phpize-deps (20191124.165709)
OK: 272 MiB in 67 packages
+ pecl install apcu-5.1.12
No releases available for package "pecl.php.net/apcu"
install failed
ERROR: Service 'app' failed to build: The command '/bin/sh -c set -eux && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev zlib-dev && docker-php-ext-install -j$(nproc) intl zip && pecl install apcu-${APCU_VERSION} && docker-php-ext-enable --ini-name 20-apcu.ini apcu && docker-php-ext-enable --ini-name 05-opcache.ini opcache && runDeps="$( scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions | tr ',' '\n' | sort -u | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' )" && apk add --no-cache --virtual .api-phpexts-rundeps $runDeps' returned a non-zero code: 1

Thank for this work :)

php "Still waiting for db to be ready"

I'm running Ubuntu 20. I added a mysql container to docker-compose.yml:

  mysql:
    image: mysql:8.0
    container_name: mysql
    restart: unless-stopped
    volumes:
      - my-db:/var/lib/mysql
    environment:
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DATABASE_USERNAME}
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    ports:
      - "3306"
    networks:
        - mysql

...but when running docker-compose up I got plenty of these errors from the php container, even though the mysql container was ready:

Still waiting for db to be ready.

The (bizarre) fix is to do chmod +x bin/console - see api-platform/api-platform#1656 (and yes, I have API Platform in my Symfony installation).

Trust root certificate locally

Great repository!

localhost

I was fiddling with a Symfony app and Caddyserver locally. One thing I haven't cracked is to have trusted SSL certificates. The link in the README to accept the auto-generated TLS certificate seems outdated and does not work very well on my Mac with Chrome :(

image

Any recent tricks or updates on how to make it work to self-sign the Caddy certificate? Maybe I would need to somehow extract the Caddy root certificate out of the docker container and trust it on my mac... Like caddy trust does... I'd still like to let Caddy create the certificate, so I don't have to mount certificates created via e.g. https://github.com/FiloSottile/mkcert

hostname

In addition, I'd like to use a hostname locally, e.g. SERVER_NAME=mywebsite.test docker-compose up. And I run dnsmasq to map *.test domains to my localhost. But the Caddy server will start reaching out to Letsencrypt (which won't work because the hostname is not externally available).

caddy_1  | {"level":"error","ts":1603895023.9278789,"logger":"tls.obtain","msg":"will retry","error":"[mywebsite.test] Obtain: [mywebsite.test] creating new order: request to https://acme-staging-v02.api.letsencrypt.org/acme/new-order failed after 1 attempts: HTTP 400 urn:ietf:params:acme:error:rejectedIdentifier - Error creating new order :: Cannot issue for \"mywebsite.test\": Domain name does not end with a valid public suffix (TLD) (ca=https://acme-staging-v02.api.letsencrypt.org/directory)","attempt":3,"retrying_in":120,"elapsed":183.5167383,"max_duration":2592000}

Probably this can be fixed by adding tls internal to the Caddyfile. But then I still have the self-signed issue from above again.

Adding DO App Platform instructions in the "Deploying in Production" section

Hey folks,

The documentation currently provides instructions on how to deploy to production using a Digital Ocean droplet.
However, there are no instructions on how to deploy using DO's App Platform.

Can projects built with this template be deployed on the App Platform, where docker-compose cannot be used?
If so, I believe it would be great to add some instructions on that subject to the documentation.

If it hasn't been done/attempted yet, I could give it a shot and submit a PR with the adequate documentation if I succeed. However, I am fairly new to Docker / Docker-compose, so I can't guarantee anything at the moment.

Cheers, and great job on the template!

How to change permissions to current user?

All Symfony folders belong to 'root' user, how to change that to the current user?
Is it enough to use chmod once for development, or I have to change some docker files?

localhost gives an error 502

Getting the Dockerfile and docker-compose in a project and starting up gives an error 502 when accessing the localhost page.
After research, it seems to be the Caddy file configuration in cause with that problem but i can't find a solution for the moment.

Defining the installation directory and dependencies

Is your feature request related to a problem? Please describe
It would be great to be able to specify the directory for installing Symfony and dependencies.

This will help you quickly create flexible architecture, for example:

docker
docs
web
- backend
-- src
-- public
-- ...
- frontend
-- src
-- public
-- ...
README.md

This may be needed if the user wants to add an independent SPA application that needs a separate server, for example.

Describe the solution you'd like
Add the ability to specify the directory for installing Symfony and all framework dependencies

Is it possible? What do you think about this?

Thanks!

[Question] When cache folder isn't shared with the host, how to use PhpStorm Symfony plugin?

Hi,
I'm trying to use this repository on MacOS and Windows.

PhpStorm Symfony plugin is handy during development, but it's relying on the cache folder content. With the default configuration, var/cache folder is excluded from sync.

When I remove the cache folder from volumes config to make it sync with the host - everything is slowing down by 2-5 times.
I already tried NFS volume and docker-sync, the performance still is not as good as with nonshared cache. At least for me, it is two times slower in the best scenario.

Maybe someone here is using this repository on MacOS or Windows with PhpStorm Symfony Plugin successfully and knows how to reduce performance degradation?

Symfony profiler pointing to nginx/_profiler/

When using the application from https://localhost and enabling the Symfony profiler-pack, the web-toolbar is pointing to nginx/_profiler/xxxxx

The issue happens only when using the https protocol, under http the link works correctly and points to localhost/_profiler/xxxx

Redirects and HTTPs

When configuring a route with a redirect like:

# routes/routes.yaml
legacy_homepage:
    path: /
    controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction
    defaults:
        path: '/home'

The redirect it always using the http schema, if the TRUSTED_PROXIES environment is not set. When setting it, the redirect works perfectly.

This behavior should be mentioned in the readme, wdty?

public/bundles missing in nginx 'symfony_nginx'

Hey after figured out how to solve acl issue from 'docker-entry-point' on my synology NAS, my app is almost OK.

** I'm new in docker and symfony, so apologizes if my wordings are incorrects **

After up and connecting to nginx container, I can see that public/bundles is missing, the public directory looks like my source file.
In the php no problem (I'm using FOSJsRoutingBundle without webpack).

I've done so many docker-composer build, so I've tried:
docker system prune and also docker-compose build --no-cache but problem still not solved.

What am I missing ? (sorry for my bad English)

Could we prevent our code from our app to mix with this one ?

Hello,

I'm not sure if it's appropriate to ask this here.
The structure offered by this repository seems to me strange againt some tutorial found in order to make a symfony-docker. For example this one : https://dev.to/martinpham/symfony-5-development-with-docker-4hj8

Thus there is my question why put the Symfony's code at the root and not inside a "public" folder (or "www", "web", "src") ?
We juste have to move the mount point, same for Caddy, and maybe in the entrypoint script (I didn't tried with this file).
It can help us to split our code in two repositories and not mix them.

If possible, maybe I can make a PR in this way ?

I propose to rename public/ folder into src and move the mount point of our app inside this folder.

Thank you, for your response.
(sorry for my english)

Symfony 4 connection on Mysql docker container

please i have problem to connect my project symfony to mysql container using docker.
i have the below errors when i try to create my database using doctrin cmd :

  • php bin/console doctrine:database:create

root@9b0782a498c3:/application# php bin/console doctrine:database:create
[error] Error thrown while running command "doctrine:database:create". Message: "An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known"

In AbstractMySQLDriver.php line 93:

An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

In PDOConnection.php line 31:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

In PDOConnection.php line 27:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

In PDOConnection.php line 27:

PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known

doctrine:database:create [-s|--shard SHARD] [-c|--connection [CONNECTION]] [--if-not-exists] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--]

This my DockerCompose.yml :

version: "3.1"
services:

memcached:
  image: memcached:alpine
  container_name: mystore-memcached

mysql:
  image: mysql:8.0
  container_name: mystore-mysql
  working_dir: /application
  volumes:
    - .:/application
  environment:
    - MYSQL_ROOT_PASSWORD=root
    - MYSQL_DATABASE=mystore
    - MYSQL_USER=
    - MYSQL_PASSWORD=
  ports:
    - "3308:3306"

mariadb:
  image: mariadb:10.4
  container_name: mystore-mariadb
  working_dir: /application
  volumes:
    - .:/application
  environment:
    - MYSQL_ROOT_PASSWORD=root
    - MYSQL_DATABASE=mystore
    - MYSQL_USER=
    - MYSQL_PASSWORD=
  ports:
    - "3309:3306"

webserver:
  image: nginx:alpine
  container_name: mystore-webserver
  working_dir: /application

  volumes:
      - .:/application
      - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
  ports:
   - "8080:80"

php-fpm:
  build: phpdocker/php-fpm
  container_name: mystore-php-fpm
  working_dir: /application
  volumes:
    - .:/application
    - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini

DockerFile :

FROM phpdockerio/php74-fpm:latest
WORKDIR "/application"

Fix debconf warnings upon build

ARG DEBIAN_FRONTEND=noninteractive

Install selected extensions and other stuff

RUN apt-get update
&& apt-get -y --no-install-recommends install php-memcached php7.4-mysql php-xdebug php7.4-xsl php-yaml
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

Install git

RUN apt-get update
&& apt-get -y install git
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

.env file :

DATABASE_URL=mysql://root:@mysql:3306/mystore?serverVersion=5.7

Can't run project on windows

I'm unable to run the project on a windows PC using docker(FYI i can run the @apiplatform one)
The php-fpm container exists right after starting
image

It looks like the project hasn't been created. The public folder is empty
image

I'm still digging into it tryin' to figure out what's wrong, if you have any idea ;(

Extra Services

According to https://github.com/dunglas/symfony-docker/blob/master/docs/extra-services.md, there are recipes for symfony/orm-packages and symfony/messenger.

However, I've changed the Dockerfile to install the full website project and not the skeleton, hence I cannot "install" symfony/orm-packages because the packages referenced in this meta-packages are already installed.

How can I look at the recipes for those package installs so that I can do what they do myself ?

Permissions issue on ubuntu

When running the project on ubuntu with docker-compose up -d, flex generates the directory tree as root user, with the exception of the var directory because of chown -R www-data var.
Below is the output of the ls command on the project root.

drwxr-xr-x 10 root    root     4096 nov  1 15:36 ./
drwxr-xr-x 16 alberto alberto  4096 ott 31 13:47 ../
drwxr-xr-x  2 root    root     4096 nov  1 15:36 bin/
-rw-r--r--  1 root    root     1179 nov  1 15:36 composer.json
-rw-r--r--  1 root    root    48139 nov  1 15:36 composer.lock
drwxr-xr-x  3 root    root     4096 nov  1 15:36 config/
drwxr-xr-x  5 alberto alberto  4096 ott 19 22:47 docker/
-rw-r--r--  1 alberto alberto   635 nov  1 11:46 docker-compose.yaml
-rw-r--r--  1 alberto alberto  1991 nov  1 14:47 Dockerfile
-rw-r--r--  1 alberto alberto   735 ott 19 22:47 Dockerfile.h2-proxy
-rw-r--r--  1 alberto alberto    97 ott 19 22:47 Dockerfile.nginx
-rw-r--r--  1 alberto alberto   119 ott 19 22:47 .dockerignore
-rw-r--r--  1 root    root      433 nov  1 15:36 .env
-rw-r--r--  1 root    root      433 nov  1 15:36 .env.dist
-rw-r--r--  1 root    root      106 nov  1 15:36 .gitignore
drwxrwxr-x  3 alberto alberto  4096 nov  1 15:32 .idea/
drwxr-xr-x  3 root    root     4096 nov  1 15:36 public/
drwxr-xr-x  3 root    root     4096 nov  1 15:36 src/
-rw-r--r--  1 root    root     2156 nov  1 15:36 symfony.lock
drwxrwxrwx  4      82 root     4096 nov  1 15:36 var/
drwxr-xr-x  5 root    root     4096 nov  1 15:36 vendor/

The project is runnable (I can browse it at localhost), but the files are not directly editable without manually changing the owner of the entire project.

I wonder if exists a way to automate this, or if I'm doing something wrong :)

[Question] Volumes explanation

Could you please explain what is the trick of configured volumes inside /src/app/var/ dir?

volumes:
# Comment out the next line in production
- ./:/srv/app:rw,cached
# If you develop on Linux, comment out the following volumes to just use bind-mounted project directory from host
- /srv/app/var/
- /srv/app/var/cache/
- /srv/app/var/logs/
- /srv/app/var/sessions/

Why volumes, defined on lines 14-17, give any performance boost on Docker for Mac?

Probably, it would be nice to add the explanation to README then (or to Dockerfile).

Thank you.

Enable to start

Hello,
I am a beginner in Docker, so...
I am trying to do the docker-composer up but go error

[Symfony\Component\Console\Exception\RuntimeException]
  The "--stability" option requires a value.

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]

ERROR: Service 'app' failed to build: The command '/bin/sh -c composer create-project "symfony/skeleton ${SYMFONY_VERSION}" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-scripts --no-plugins --no-interaction' returned a non-zero code: 1

stability is set to stable in the Docker file, so don't understand...
Please help

[Docs] Provide some examples how to run in production

Please describe in documentation sollution for the next cases:

  1. running some workers in parallel, for example for consuming messages by Messenger component from 4.1
  2. running multiple php application backends, for example api
  3. running periodical tasks by cron

Cannot Connect to mercure

Hello i follow over codes and documents and docker files but never find a solution to connect mercure in this structure

No releases available for package "pecl.php.net/apcu"

simply run docker-compose up

#6 34.27 Build complete.
#6 34.28 Don't forget to run 'make test'.
#6 34.28
#6 34.30 Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20200930/
#6 34.41 find . -name \*.gcno -o -name \*.gcda | xargs rm -f
#6 34.41 find . -name \*.lo -o -name \*.o | xargs rm -f
#6 34.42 find . -name \*.la -o -name \*.a | xargs rm -f
#6 34.42 find . -name \*.so | xargs rm -f
#6 34.42 find . -name .libs -a -type d|xargs rm -rf
#6 34.43 rm -f libphp.la      modules/* libs/*
#6 34.43 rm -f ext/opcache/jit/zend_jit_x86.c
#6 34.44 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: No such file or directory
#6 34.44 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/community: No such file or directory
#6 34.44 (1/1) Purging .phpize-deps-configure (20210421.170025)
#6 34.44 OK: 301 MiB in 79 packages
#6 35.03 + pecl install apcu
#6 35.09 No releases available for package "pecl.php.net/apcu"
#6 35.10 install failed
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c set -eux; 	apk add --no-cache --virtual .build-deps 		$PHPIZE_DEPS 		icu-dev 		libzip-dev 		zlib-dev 	; 		docker-php-ext-configure zip; 	docker-php-ext-install -j$(nproc) 		intl 		zip 	; 	pecl install 		apcu 	; 	pecl clear-cache; 	docker-php-ext-enable 		apcu 		opcache 	; 		runDeps="$( 		scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions 			| tr ',' '\n' 			| sort -u 			| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' 	)"; 	apk add --no-cache --virtual .phpexts-rundeps $runDeps; 		apk del .build-deps]: exit code: 1
ERROR: Service 'php' failed to build

[RFC] Switching to nginx unit

It's very new and should be properly tested, but it's add a new SAPI into PHP which provide a direct http endpoint who is aim to be suitable for production in the long term.

This will definitely reduce the complexity of this repo as there will no more need to have a docker compose (only docker will be enough) for a basic usage / demo

I don't think that should be done now as nginx unit is very new, but IMO it must be osberved and integrated when it's stable enough for production.

[XDebug] Linux and PHPStorm

Hi guys,

I'm trying to debugging my application on Linux and PHPStorm. But Xdebug doesn't work.

This is my configuration on PHPStorm:

image

image

But after put breakpoints and listen up the debutter with this icon:

image

I reloaded the page but nothing happend.

where did I go wrong?

Thanks a lot for your help.

Raffaele C.

How to do subsequent deploys?

Once everything is set up and running, how do I do subsequent deploys? Mostly a deploy involves new php code, so I imagine the php container needs to be rebuilt.

Like so?

SYMFONY_VERSION=4.4.* PHP_VERSION=7.4 SERVER_NAME="example.com" docker-compose --env-file=.env.local -f docker-compose.yml -f docker-compose.prod.yml build php

SYMFONY_VERSION=4.4.* PHP_VERSION=7.4 SERVER_NAME="example.com" docker-compose --env-file=.env.local -f docker-compose.yml -f docker-compose.prod.yml up -d php

I'd like to do zero downtime deploys. The above method takes the php container offline while the new one is built and deployed, which takes the site offline. The docs say that Docker Swarm can be used, but after running docker swarm init and docker stack deploy -c docker-compose.yml symfony I get this error:

Ignoring unsupported options: build, restart

Creating network symfony_mysql
Creating network symfony_php
Creating service symfony_mysql
Creating service symfony_php
failed to create service symfony_php: Error response from daemon: rpc error: code = InvalidArgument desc = ContainerSpec: image reference must be provided

Ignoring unsupported options: build, restart - but both options are needed! (Apologies, I'm a Docker Swarm newbie so unsure exactly how this all works).

Caddy Container GoLang Error Again

Hello,

we had an error 2 weeks ago like as #124 and after fixed by #125 but today we fall again with this error
image

caddy_1     |   google.golang.org/[email protected]/reflect/protoregistry/registry.go:127 +0xb72
caddy_1     | google.golang.org/protobuf/internal/filedesc.Builder.Build(0x0, 0x0, 0xc00032b200, 0x47a, 0x600, 0x8000000
03, 0x0, 0x1c490e0, 0xc000200240, 0x1c525e0, ...)
caddy_1     |   google.golang.org/[email protected]/internal/filedesc/build.go:113 +0x1aa
caddy_1     | github.com/golang/protobuf/proto.RegisterFile(0x197d9ca, 0x8, 0x26468e0, 0x2b3, 0x2b3)
caddy_1     |   github.com/golang/[email protected]/proto/registry.go:48 +0x147
caddy_1     | github.com/dgraph-io/badger/v2/pb.init.1()

How we can have stable one of caddy version ...

zend_mm_heap corrupted

Hi

I add this to the end of the root Dockerfile :

# Xdebug
FROM symfony_php as symfony_php_debug

ARG XDEBUG_VERSION=3.0.0
RUN set -eux; \
	apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
	pecl install xdebug-$XDEBUG_VERSION; \
	docker-php-ext-enable xdebug; \
	apk del .build-deps

And then run all with this :

SYMFONY_VERSION=5.1.*; SERVER_NAME=symfony.server; docker-compose -f docker-compose.yml -f docker-compose.debug.yml up --build

This results in an infinite loop with

php_1       | zend_mm_heap corrupted

As suggested here https://stackoverflow.com/questions/2247977/what-does-zend-mm-heap-corrupted-mean
It may be solved with USE_ZEND_ALLOC=0
But I can't find any php.ini in the source. Is it auto-generated ?

Here is my full log :

php_1       | Installing dependencies from lock file (including require-dev)
php_1       | Verifying lock file contents can be installed on current platform.
php_1       | Nothing to install, update or remove
php_1       | Generating optimized autoload files
php_1       | composer/package-versions-deprecated: Generating version class...
php_1       | composer/package-versions-deprecated: ...done generating version class
php_1       | 87 packages you are using are looking for funding.
php_1       | Use the `composer fund` command to find out more!
php_1       | 
php_1       | Run composer recipes at any time to see the status of your Symfony recipes.
php_1       | 
php_1       | Executing script cache:clear [OK]
php_1       | Executing script assets:install public [OK]
php_1       | 
php_1       | Waiting for db to be ready...
php_1       | The db is now ready and reachable
php_1       | 
php_1       |  [OK] Already at the latest version ("DoctrineMigrations\Version20201128123120")
php_1       | 
php_1       | zend_mm_heap corrupted
symfony-docker_php_1 exited with code 70
php_1       | Installing dependencies from lock file (including require-dev)
php_1       | Verifying lock file contents can be installed on current platform.
php_1       | Nothing to install, update or remove
php_1       | Generating optimized autoload files
php_1       | composer/package-versions-deprecated: Generating version class...
php_1       | composer/package-versions-deprecated: ...done generating version class
php_1       | 87 packages you are using are looking for funding.
php_1       | Use the `composer fund` command to find out more!
php_1       | 
php_1       | Run composer recipes at any time to see the status of your Symfony recipes.
php_1       | 
php_1       | Executing script cache:clear [OK]
php_1       | Executing script assets:install public [OK]
php_1       | 
php_1       | Waiting for db to be ready...
php_1       | The db is now ready and reachable
php_1       | 
php_1       |  [OK] Already at the latest version ("DoctrineMigrations\Version20201128123120")
php_1       | 
php_1       | zend_mm_heap corrupted

Impossible to change to mysql.

I add
RUN docker-php-ext-install pdo pdo_mysql

in Dockerfile and symfony tell me could not find driver. I don't understand what's wrong. Docker is a headache.

Cannot autowire argument $request of

hey friends i have a problem i cant fix it wishing your help plz.


namespace App\Controller;

use App\Entity\BlogPost;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

  /**
  * @Route("/blog")
  */

class BlogController extends AbstractController
{
    /**
     * @Route("/add", name="Blog_Add",methods={"POST"})
     */
    public function add(Request $request)
    {
        //var_dump("here");die;
        $serializer = $this->get('serializer');
        $Post= $serializer->deserialize($request->getContent(),BlogPost::class,'json');
        $em=$this->getDoctrine()->getManager();
        $em->persist($Post);
        $em->flush();
        return  $this->json($Post);
    }
}

xdebug

Hello,
is it possible to have some preconfigured optional possibility to have xdebug here?

Problem when use .com instead of .localhost

When is use this following command

SERVER_NAME="monsite.com, caddy:80" docker-compose up --build

Application not display on "monsite.com", its make an SSL error => SSL_ERROR_INTERNAL_ERROR_ALERT
but when i use this

SERVER_NAME="monsite.localhost, caddy:80" docker-compose up --build

The application be display on "monsite.localhost"
I think its obvious issu, but I can't solve the problem

Someone else can help me ?

How to use this repo ?

Hello all,
Not sure it's the good place to ask, but I don't know where to ask help,
I'm a rookie symfony dev and I just begin using docker,
I wanted to know how to use this ? Where do I put those files ?
I have a dev/ folder with my several symfony projects into : dev/projectA/ dev/projectB/ ...
If I have to put this in every folder, how do I git it ? Or do I download this and unzip in each project folder ?

Issue : The getting started part is for already advanced docker user :)

Thank you in advance !

"slice bounds out of range" on kompose conversion

Every time I'm trying to convert my docker-compose.yml to a container orchestrator through Kompose, I'm getting this error.

WARN Restart policy 'unless-stopped' in service caddy is not supported, convert it to 'always'
panic: runtime error: slice bounds out of range [1:0]

goroutine 1 [running]:
github.com/kubernetes/kompose/pkg/loader/compose.parseHealthCheck(0x0, 0x0, 0x0, 0xc000267970, 0xc000267980, 0xc000267990, 0xc000267998, 0x0, 0x0, 0x0, ...)
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/pkg/loader/compose/v3.go:270 +0x46f
github.com/kubernetes/kompose/pkg/loader/compose.dockerComposeToKomposeMapping(0xc00050a300, 0x0, 0x0, 0x0, 0xc00039f980, 0x1, 0x1)
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/pkg/loader/compose/v3.go:334 +0xbe4
github.com/kubernetes/kompose/pkg/loader/compose.parseV3(0xc000410980, 0x1, 0x1, 0x3, 0xffffffffffffffff, 0x1, 0x1, 0x2fb4f40, 0x1013601)
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/pkg/loader/compose/v3.go:129 +0x1ac
github.com/kubernetes/kompose/pkg/loader/compose.(*Compose).LoadFile(0x280e678, 0xc000410980, 0x1, 0x1, 0x0, 0x0, 0x200000003, 0xc000000180, 0x0, 0xc0002dfa38)
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/pkg/loader/compose/compose.go:180 +0x37f
github.com/kubernetes/kompose/pkg/app.Convert(0x100000100, 0x0, 0x0, 0x0, 0x0, 0x1ddb660, 0x4, 0x1, 0x1debc77, 0x15, ...)
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/pkg/app/app.go:224 +0x11e
github.com/kubernetes/kompose/cmd.glob..func3(0x27dcc40, 0x280e678, 0x0, 0x0)
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/cmd/convert.go:106 +0x4d
github.com/spf13/cobra.(*Command).execute(0x27dcc40, 0x280e678, 0x0, 0x0, 0x27dcc40, 0x280e678)
	/home/wikus/syncthing/files/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0x27dcee0, 0x103b11a, 0x2792260, 0xc000060750)
	/home/wikus/syncthing/files/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
	/home/wikus/syncthing/files/dev/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/kubernetes/kompose/cmd.Execute()
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/cmd/root.go:92 +0x31
main.main()
	/home/wikus/syncthing/files/dev/go/src/github.com/kubernetes/kompose/main.go:22 +0x20

It seems like it's related to Symfony https://github.com/symfony/cli/issues/124.

Happened to anyone?

Unable to start containers

I just wanted to try this docker setup, and cloned it to my local system. Once done, I used docker-compose up to start containers but failed.

PHP Fatal error:  Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in phar:///usr/bin/composer/src/Composer/DependencyResolver/DefaultPolicy.php:84
Stack trace:
#0 [internal function]: array_merge()
#1 phar:///usr/bin/composer/src/Composer/DependencyResolver/DefaultPolicy.php(84): call_user_func_array()
#2 phar:///usr/bin/composer/src/Composer/DependencyResolver/Solver.php(387): Composer\DependencyResolver\DefaultPolicy->selectPreferredPackages()
#3 phar:///usr/bin/composer/src/Composer/DependencyResolver/Solver.php(740): Composer\DependencyResolver\Solver->selectAndInstall()
#4 phar:///usr/bin/composer/src/Composer/DependencyResolver/Solver.php(231): Composer\DependencyResolver\Solver->runSat()
#5 phar:///usr/bin/composer/src/Composer/Installer.php(489): Composer\DependencyResolver\Solver->solve()
#6 phar:///usr/bin/composer/src/Composer/Installer.php(232): Composer\Installer->doInstall()
#7 phar:///usr/bin/composer/src/Composer/Command/InstallCommand.php(122): Composer\Installer->run()
#8 phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php(245): Composer\Command\InstallCommand->execute()
#9 phar:///usr/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#10 phar:///usr/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#11 phar:///usr/bin/composer/src/Composer/Console/Application.php(281): Symfony\Component\Console\Application->doRun()
#12 phar:///usr/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#13 phar:///usr/bin/composer/src/Composer/Console/Application.php(113): Symfony\Component\Console\Application->run()
#14 phar:///usr/bin/composer/bin/composer(61): Composer\Console\Application->run()
#15 /usr/bin/composer(24): require('...')
#16 {main}
  thrown in phar:///usr/bin/composer/src/Composer/DependencyResolver/DefaultPolicy.php on line 84
ERROR: Service 'php' failed to build : The command '/bin/sh -c set -eux; 	mkdir -p var/cache var/log; 	composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction; 	composer dump-autoload --classmap-authoritative --no-dev; 	composer symfony:dump-env prod; 	composer run-script --no-dev post-install-cmd; 	chmod +x bin/console; sync' returned a non-zero code: 255

My system docker-compose version: docker-compose version 1.27.4, build 40524192 and docker Docker version 19.03.13, build 4484c46d9d

Anyone know's what could be the issue?

Error cache in production

Hello,
I have an error on the project.
I can't access the API platform

command : SERVER_NAME=domain.tld docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
in /api -> The server returned a "500 Internal Server Error".

in log :
Uncaught PHP Exception ArgumentCountError: "Too few arguments to function Symfony\Component\Cache\Adapter\AbstractAdapter::doGet(), 1 passed in /srv/app/vendor/symfony/cache/Traits/AbstractAdapterTrait.php on line 212 and at least 4 expected" at /srv/app/vendor/symfony/cache-contracts/CacheTrait.php line 44

Need help for production build

Hello everybody

I'm trying to understand how can I use this project in production and I would like to have a single Dockerfile for dev and prod.

I see that there is a possibility:

volumes:
    # Comment out the next line in production
    - ./:/srv/app:rw,cached

So if I comment this line, I understand that all my app is copied in the image during the build :

COPY . .

composer install for dev is run in php/docker-entrypoint.sh when php container is up :

if [ "$APP_ENV" != 'prod' ]; then
    composer install --prefer-dist --no-progress --no-suggest --no-interaction
fi

In .dockerignore there is .env*, all environment files are ignored in copy.
I have create a docker-compose.prod.yml based on the original docker-compose.yml :

version: "3.4"

services:
    mariadb:
        build:
            context: .
            target: symfony_mariadb
        volumes:
            - mariadb:/var/lib/mysql

    php:
        build:
            context: .
            target: symfony_php
            args:
                SYMFONY_VERSION: ${SYMFONY_VERSION:-4.4.*}
                STABILITY: ${STABILITY:-stable}
        healthcheck:
            interval: 10s
            timeout: 3s
            retries: 3
            start_period: 30s
        environment:
            - APP_ENV=prod
            - SYMFONY_VERSION

    nginx:
        build:
            context: .
            target: symfony_nginx
        ports:
            - "80:8080"
        depends_on:
            - php

volumes:
    mariadb:
        driver: local

I have putted:

environment:
    - APP_ENV=prod

Is this the right way do to this or I'm doing it wrong ?

Where do I put the composer install for production ?
During the build after COPY . . ? But cache:clear from the composer.json failed, there are no environment vars.
How do I declare environment vars ?

Thanks.

Unable to start Caddy container

Hello

I'm facing this error when running docker-compose up.

It occurs on both Ubuntu and Windows (through WSL2)

caddy_1  | goroutine 1 [running]:
caddy_1  | google.golang.org/protobuf/reflect/protoregistry.glob..func1(0x1c5a1a0, 0xc0001b3a40, 0x1c26000, 0xc0002b0d00, 0xc0001b3a40)
caddy_1  | 	google.golang.org/[email protected]/reflect/protoregistry/registry.go:54 +0x25f
caddy_1  | google.golang.org/protobuf/reflect/protoregistry.(*Files).RegisterFile(0xc000096ff0, 0x1c631e0, 0xc0001b3a40, 0x0, 0x0)
caddy_1  | 	google.golang.org/[email protected]/reflect/protoregistry/registry.go:127 +0xb72
caddy_1  | google.golang.org/protobuf/internal/filedesc.Builder.Build(0x0, 0x0, 0xc00030e600, 0x47a, 0x600, 0x800000003, 0x0, 0x1c39740, 0xc000099950, 0x1c42bc0, ...)
caddy_1  | 	google.golang.org/[email protected]/internal/filedesc/build.go:113 +0x1aa
caddy_1  | github.com/golang/protobuf/proto.RegisterFile(0x196f943, 0x8, 0x262f920, 0x2b3, 0x2b3)
caddy_1  | 	github.com/golang/[email protected]/proto/registry.go:48 +0x147
caddy_1  | github.com/dgraph-io/badger/v2/pb.init.1()
caddy_1  | 	github.com/dgraph-io/badger/[email protected]/pb/pb.pb.go:650 +0x5a
caddy_1  | panic: proto: file "pb.proto" is already registered
caddy_1  | See https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

pdo_mysql extension not installed/enabled

Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-pdo_mysql * is missing from your system. Install or enable PHP's pdo_mysql extension.

ERROR: Service 'app' failed to build: The command '/bin/sh -c mkdir -p var/cache var/logs var/sessions     && composer install --prefer-dist --no-dev --no-progress --no-suggest --classmap-authoritative --no-interaction 	&& composer clear-cache 	&& chown -R www-data var' returned a non-zero code: 2

Ubuntu 18.04 LTS
Docker version 17.12.1-ce, build 7390fc6
docker-compose version 1.17.1, build unknown

CURL certificate

Hey guys !

I'm trying to use guzzlehttp to communicate with an external api but I keep getting

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

I tried to manually add the certificate in the symfony.ini as well as in the /usr/local/etc/php/php.ini, but it doesn't seem to help in any ways

curl.cainfo="/srv/app/docker/php/conf.d/cacert.pem"
openssl.cafile="/srv/app/docker/php/conf.d/cacert.pem"

Thx for your help 😄

Add yarn/npm

everything is in the title
can you add yarn to the php container?

Docker-compose up gives me error

I have just installed to test this environment following the documentation but it brings me an error.
I did :

docker system prune -a

git clone [email protected]:dunglas/symfony-docker.git

cd symfony-docker

docker-compose up

2021/01/05 15:29:43 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/dunglas/mercure/caddy@main go: downloading github.com/dunglas/mercure/caddy v0.0.0-20210105003949-86b584892268 go: github.com/dunglas/mercure/caddy main => v0.0.0-20210105003949-86b584892268 go get: github.com/dunglas/mercure/[email protected] requires github.com/dunglas/[email protected]: reading github.com/dunglas/mercure/go.mod at revision v0.11.0: unknown revision v0.11.0 2021/01/05 15:29:45 [FATAL] exit status 1 ERROR: Service 'caddy' failed to build: The command '/bin/sh -c xcaddy build --with github.com/dunglas/mercure@main --with github.com/dunglas/mercure/caddy@main --with github.com/dunglas/vulcain/caddy' returned a non-zero code: 1

XDebug in CLI not working ?

Hello,

I have setup xdebug according to the documentation, but I can't make it working in CLI using:
docker-compose exec php php bin/console make:command
I have check the option "Break at the first line of code"

It's working for the web, so I think the setup is correct, but not in CLI.
I don't understand what I'm missing.

Can anyone help me please ?
I'm using Ubuntu & PHPStorm, if it worth mentionning.

Thank you !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.