Salut,
la question pourrait concerner plus docker que symfony, mais je pense que l'expérience de la commu sur symfony pourrait être plus utile à mon problème actuel.
Objectif : Faire tourner une application symfony sous docker.
Point sur l'avancement :
Mon projet est organisé en 3 partie :
- docker-compose.yml
- docker/Dockerfile
- project-manager/...
project-manager contient l'application symfony neuve de toute modification tout juste installé par la commande.
- docker-compose.yml
Code yaml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 version: '3' services: symfony: build: context: . dockerfile: docker/Dockerfile image: project-manager ports: - 80:80 db: image: mysql ports: - 3306:3306 volumes: - "./.data/db:/var/lib/mysql" environment: MYSQL_ROOT_PASSWORD: root phpmyadmin: image: phpmyadmin/phpmyadmin ports: - "8080:80" links: - db
Le docker compose monte trois images, une pour le projet symfony, une pour la BDD et une pour avoir un phpmyadmin qui rend la BDD accessible.
Le dockerfile du projet symfony installe tout simplement php 7.4-apache ainsi que composer et git; puis il copie le contenu de mon répertoire du projet dans le container.
Code dockerfile : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 FROM php:7.4-apache #Install Git RUN apt-get update RUN apt-get -y install git # Install Composer COPY --from=composer /usr/bin/composer /usr/bin/composer COPY ./project-manager /var/www/html
J'ai également configurer un host
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 rock-Inspiron-7501 # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters #Project Manager 127.0.0.1 project-manager.local
Point positif :
Lorsque je me rends sur : http://project-manager.local:8080/
J'ai bien accès à mon phpmyadmin et j'arrive parfaitement à me connecter dessus.
Point négatif : Si maintenant je veux accéder au projet symfony en lui même (le page d'accueil du framework en fait) : http://project-manager.local/
Je récupère l'erreur suivante :
Forbidden
You don't have permission to access this resource.
Apache/2.4.38 (Debian) Server at project-manager.local Port 80
Cela semble être un problème de droit, plus qu'un problème lié à docker, d'où le fait que je vienne plutôt sur la section symfony pour poser la problématique.
Merci pour votre aide
PS : Je n'ai plus fait de symfony depuis symfony 3. Donc il est possible que quelque chose m'échappe sur les nouvelles feature.
PS 2 : Je tourne bien entendu sur un Linux Ubuntu.
EDIT : ls -al sur le dossier html du container
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 root@37a3d1516b6d:/var/www/html# ls -al total 364 drwxrwxrwx 1 www-data www-data 4096 Dec 25 15:19 . drwxr-xr-x 1 root root 4096 Dec 11 07:16 .. -rw-rw-r-- 1 root root 1529 Dec 25 15:16 .env -rw-rw-r-- 1 root root 162 Dec 25 15:16 .env.test -rw-rw-r-- 1 root root 298 Dec 25 15:16 .gitignore drwxrwxr-x 2 root root 4096 Dec 25 15:16 bin -rw-rw-r-- 1 root root 2884 Dec 25 15:16 composer.json -rw-rw-r-- 1 root root 282943 Dec 25 15:16 composer.lock drwxrwxr-x 4 root root 4096 Dec 25 15:16 config drwxrwxr-x 2 root root 4096 Dec 25 15:16 migrations -rw-rw-r-- 1 root root 1065 Dec 25 15:16 phpunit.xml.dist drwxrwxr-x 2 root root 4096 Dec 25 15:16 public drwxrwxr-x 5 root root 4096 Dec 25 15:16 src -rw-rw-r-- 1 root root 13258 Dec 25 15:16 symfony.lock drwxrwxr-x 2 root root 4096 Dec 25 15:16 templates drwxrwxr-x 2 root root 4096 Dec 25 15:16 tests drwxrwxr-x 2 root root 4096 Dec 25 15:16 translations drwxrwxrwx 4 root root 4096 Dec 25 15:16 var drwxrwxr-x 16 root root 4096 Dec 25 15:16 vendor
Partager