Skip to content

Commit b37c292

Browse files
ZnarreZKenneth
andauthored
feat: move postgres-variables from compose to .env. (#41)
* feat: move postgres-variables from compose to .env. * fix: craete .env earlier in workflow --------- Co-authored-by: Kenneth <[email protected]>
1 parent a9ee40b commit b37c292

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

.env.ci.testing

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# php artisan key:generate
22
APP_KEY=base64:nfTdlWswyvfctT6YNgk92bZaKWs5HfhdcyIXWmJUcuk=
33

4-
# Must match compose.yml -> db -> environment
4+
# devcontainer
55
DB_USERNAME=laravel
66
DB_DATABASE=wannabe5
77
DB_PASSWORD=mydevelopmentexample
88

9+
10+
# db (loading variables from dev_container, so no need to change here)
11+
POSTGRES_USER=${DB_USERNAME}
12+
POSTGRES_DB=${DB_DATABASE}
13+
POSTGRES_PASSWORD=${DB_PASSWORD}
14+
915
TELESCOPE_ENABLED=true
1016
# Log to stdout/stderr
1117
LOG_LEVEL=debug

.env.example

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ APP_ENV=local
66
# Intended for use in docker containers, meaning `php artisan serve` will accept traffic from any source
77
SERVER_HOST=0.0.0.0
88

9-
# Must match compose.yml -> db -> environment
9+
# devcontainer
1010
DB_HOST=db
1111
DB_USERNAME=laravel
1212
DB_DATABASE=wannabe5
1313
DB_PASSWORD=mydevelopmentexample
1414

15+
# db (loading variables from dev_container, so no need to change here)
16+
POSTGRES_USER=${DB_USERNAME}
17+
POSTGRES_DB=${DB_DATABASE}
18+
POSTGRES_PASSWORD=${DB_PASSWORD}
19+
1520
TELESCOPE_ENABLED=true
1621
# Log to stdout/stderr
1722
LOG_LEVEL=debug

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
fetch-depth: 1
1515
- name: Setup database using docker
1616
run: |
17+
cp .env.ci.testing .env
1718
docker compose -f compose.yml up db -d
1819
- name: Setup PHP
1920
uses: shivammathur/setup-php@v2
@@ -25,7 +26,6 @@ jobs:
2526
run: composer install -n --prefer-dist
2627
- name: Prepare Laravel Application
2728
run: |
28-
cp .env.ci.testing .env
2929
php artisan key:generate
3030
php artisan migrate --force -n
3131
- name: Run tests
@@ -34,4 +34,4 @@ jobs:
3434
run: |
3535
php artisan scramble:analyze
3636
php artisan scramble:export --path=openapi-ci.json
37-
diff openapi.json openapi-ci.json
37+
diff openapi.json openapi-ci.json

compose.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ services:
1515
image: postgres
1616
ports:
1717
- 127.0.0.1:5432:5432
18-
environment:
19-
POSTGRES_USER: laravel
20-
POSTGRES_DB: wannabe5
21-
POSTGRES_PASSWORD: mydevelopmentexample
18+
env_file: .env
2219
volumes:
23-
- ./scripts/create-test-db.sh:/docker-entrypoint-initdb.d/create-test-db.sh
20+
- ./scripts/create-test-db.sh:/docker-entrypoint-initdb.d/create-test-db.sh

0 commit comments

Comments
 (0)