Skip to content

Commit 71edb75

Browse files
authored
Extend env (#4)
* Update .env * Update compose.yaml * Create launch.json * Update launch.json * Update launch.json * Update README.md explain db connection add db/user creation
1 parent ad41e69 commit 71edb75

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
NETWORK_NAME=develop
1+
NETWORK_NAME=my-project
2+
PROJECT_NAME=my-project

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
* localhost:9080/ => ./htdocs as webroot folder
44
* localhost:9081/ => adminer
5+
* localhost:9306 => external db connection (only needed for external access
6+
7+
> **_NOTE:_** from inside the network the database connection is db:3306!!
58
69
## Setup docker containers
710

@@ -31,3 +34,13 @@ When you're ready, start your application by running:
3134
```
3235

3336
and save the file. This assumes you have your webroot in a folder htdocs as indicated above.
37+
38+
## Setup database
39+
40+
To create a database and a user open in Adminer oder a vscode MariaDB plugin
41+
42+
```sql
43+
create database my_database;
44+
create user 'my-user'@'%' identified by 'my-oassword';
45+
grant all privileges on my_database.* to 'my-user'@'%';
46+
```

compose.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,32 @@
77
# You can add other services your application may depend on here, such as a
88
# database or a cache. For examples, see the Awesome Compose repository:
99
# https://github.com/docker/awesome-compose
10-
name: project-name
10+
name: ${PROEJECT_NAME}
11+
networks:
12+
default:
13+
name: ${NETWORK_NAME}
14+
1115
services:
1216
server:
17+
container_name: ${PROJECT_NAME}
18+
1319
build:
1420
context: .
1521
ports: ["9080:80"]
1622
volumes: ["../htdocs/:/var/www/html"]
1723

1824
db:
25+
container_name: ${PROJECT_NAME}-db
26+
1927
image: mariadb
2028
restart: always
2129
ports: ["9306:3306"]
2230
environment:
2331
MARIADB_ROOT_PASSWORD: geheim
2432

2533
adminer:
34+
container_name: ${PROJECT_NAME}-adminer
35+
2636
image: adminer
2737
restart: always
2838
ports: ["9081:8080"]
29-
30-
networks:
31-
default:
32-
name: ${NETWORK_NAME}
33-
external: true

htdocs/.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Listen for Xdebug",
6+
"type": "php",
7+
"request": "launch",
8+
"port": 9003,
9+
"pathMappings": {
10+
"/var/www/html": "${workspaceFolder}"
11+
}
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)