Skip to content

Commit 4d7cb0b

Browse files
committed
update container config to access mysql
- added DATABASE_URL in the php service environment Hopefully, it will help us with accessing MySQL in Codespaces - open 3306 mysql port in devcontainer.json
1 parent 210e6b2 commit 4d7cb0b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
}
4242
},
4343

44-
"forwardPorts": [80],
44+
"forwardPorts": [80,3306],
4545

4646
// execute our one-time repo init if /vendor/ does not exist
4747
"postCreateCommand": "sh init_repo.sh"

.devcontainer/docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ services:
4242
- ${PHP_WEBROOT_HOST_PATH}:${PHP_WEBROOT_CONTAINER_PATH}
4343
# we don't need to expose the port 9003 here for Xdebug because the
4444
# connection comes from inside the PHP container to the IDE via port 9003
45+
environment:
46+
- DATABASE_URL=mysql://root:rootpassword@mysql:3306/mydatabase
47+
depends_on:
48+
- mysql
4549

4650
# MySQL Service
4751
mysql:

0 commit comments

Comments
 (0)