Skip to content

Commit dc9b7b7

Browse files
authored
Merge pull request #67 from connorabbas/develop
PostgreSQL as default database
2 parents c0b0deb + 06cda6f commit dc9b7b7

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ For this reason, Tailwind has been added into the project and is utilized with t
2727
---
2828

2929
## Usage with Docker
30-
This starter kit is configured to use Docker Compose for local development with a few extra configuration steps. With this setup, you do not need PHP, Composer, MySQL or Node.js installed on your machine to get up and running with this project.
30+
This starter kit is configured to use Docker Compose for local development with a few extra configuration steps. With this setup, you do not need PHP, Composer, PostgreSQL or Node.js installed on your machine to get up and running with this project.
3131

3232
### Setup
3333
1. In a new directory (outside of your Laravel project) create a `docker-compose.yml` file to create a reverse proxy container using [Traefik](https://doc.traefik.io/traefik/getting-started/quick-start/). You can reference this [example implementation](https://github.com/connorabbas/traefik-docker-compose/blob/master/docker-compose.yml).
@@ -42,20 +42,20 @@ This starter kit is configured to use Docker Compose for local development with
4242
# Match with value used in docker-compose.local.yml
4343
APP_URL=http://primevue-inertia.localhost
4444
45-
DB_CONNECTION=mysql
46-
DB_HOST=mysql
47-
DB_PORT=3306
45+
DB_CONNECTION=pgsql
46+
DB_HOST=pgsql # name of service
47+
DB_PORT=5432
4848
DB_DATABASE=laravel
4949
DB_USERNAME=sail
5050
DB_PASSWORD=password
5151
5252
# Update as needed for running multiple projects
5353
APP_PORT=8000
5454
VITE_PORT=5173
55-
FORWARD_DB_PORT=3306
55+
FORWARD_DB_PORT=5432
5656
```
5757
3. Build the Laravel app container:
5858
- Either build manually with docker compose (like above), use [Laravel Sail](https://laravel.com/docs/master/sail), or build as a [VS Code Dev Container](https://code.visualstudio.com/docs/devcontainers/tutorial) using the `Dev Containers: Reopen in Container` command.
5959
6060
### Additional configuration
61-
If you wish to add additional services, or swap out MySQL with an alternative database, you can reference the [Laravel Sail stubs](https://github.com/laravel/sail/tree/1.x/stubs) and update the `docker-compose.local.yml` file as needed.
61+
If you wish to add additional services, or swap out PostgreSQL with an alternative database, you can reference the [Laravel Sail stubs](https://github.com/laravel/sail/tree/1.x/stubs) and update the `docker-compose.local.yml` file as needed.

docker-compose.local.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,29 @@ services:
2727
- sail
2828
- proxy
2929
depends_on:
30-
- mysql
30+
- pgsql
3131

32-
mysql:
33-
image: 'mysql/mysql-server:8.0'
32+
pgsql:
33+
image: 'postgres:17'
3434
ports:
35-
- '${FORWARD_DB_PORT:-3306}:3306'
35+
- '${FORWARD_DB_PORT:-5432}:5432'
3636
environment:
37-
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
38-
MYSQL_ROOT_HOST: '%'
39-
MYSQL_DATABASE: '${DB_DATABASE}'
40-
MYSQL_USER: '${DB_USERNAME}'
41-
MYSQL_PASSWORD: '${DB_PASSWORD}'
42-
MYSQL_ALLOW_EMPTY_PASSWORD: 1
37+
PGPASSWORD: '${DB_PASSWORD:-secret}'
38+
POSTGRES_DB: '${DB_DATABASE}'
39+
POSTGRES_USER: '${DB_USERNAME}'
40+
POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
4341
volumes:
44-
- 'primevue-inertia-mysql:/var/lib/mysql'
45-
- './docker/local/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
42+
- 'primevue-inertia-pgsql:/var/lib/postgresql/data'
43+
- './docker/local/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql'
4644
networks:
4745
- sail
4846
healthcheck:
49-
test:
50-
- CMD
51-
- mysqladmin
52-
- ping
53-
- '-p${DB_PASSWORD}'
47+
test: [ "CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}" ]
5448
retries: 3
5549
timeout: 5s
5650

5751
volumes:
58-
primevue-inertia-mysql:
52+
primevue-inertia-pgsql:
5953
driver: local
6054

6155
networks:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SELECT 'CREATE DATABASE testing'
2+
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'testing')\gexec

0 commit comments

Comments
 (0)