Skip to content

docker, database updates #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"absszero.vscode-laravel-goto",
"codingyu.laravel-goto-view",
"onecentlin.laravel-blade",
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A basic starter kit using [Laravel](https://laravel.com/docs/master), [Intertia.
Need an admin panel? [There's a branch for that.](https://github.com/connorabbas/laravel-inertia-primevue/tree/feature/admin-panel)

## Usage with Docker
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/MariaDB, or Node.js installed on your machine to get up and running with this project.
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.

### Setup
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).
Expand All @@ -19,11 +19,11 @@ This starter kit is configured to use Docker Compose for local development with
# Match with value used in docker-compose.local.yml
APP_URL=http://primevue-inertia.localhost

DB_CONNECTION=mariadb
DB_HOST=mariadb # service name from container
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=docker_mariadb
DB_USERNAME=sail
DB_PASSWORD=password

# Update as needed for running multiple projects
Expand Down
28 changes: 17 additions & 11 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
services:
laravel:
container_name: primevue_inertia_laravel
build:
context: ./docker/local/php/8.3
dockerfile: Dockerfile
Expand Down Expand Up @@ -28,28 +27,35 @@ services:
- sail
- proxy
depends_on:
- mariadb
- mysql

mariadb:
container_name: primevue_inertia_mariadb
image: mariadb:11
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- "${FORWARD_DB_PORT:-3306}:3306"
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_ROOT_HOST: '%'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- primevue_inertia_mariadb_data:/var/lib/mysql
- ./docker/local/database/init.sql:/docker-entrypoint-initdb.d/init.sql
- 'primevue-inertia-mysql:/var/lib/mysql'
- './docker/local/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-p${DB_PASSWORD}'
retries: 3
timeout: 5s

volumes:
primevue_inertia_mariadb_data:
primevue-inertia-mysql:
driver: local

networks:
Expand Down
2 changes: 0 additions & 2 deletions docker/local/database/init.sql

This file was deleted.

6 changes: 6 additions & 0 deletions docker/local/database/mysql/create-testing-database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

mysql --user=root --password="$MYSQL_ROOT_PASSWORD" <<-EOSQL
CREATE DATABASE IF NOT EXISTS testing;
GRANT ALL PRIVILEGES ON \`testing%\`.* TO '$MYSQL_USER'@'%';
EOSQL