Skip to content
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

feat: use mysql instead of pgsql #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
Expand Down
4 changes: 2 additions & 2 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ RUN addgroup -g 1000 -S user && adduser -u 1000 -D user -G user
RUN apk add --no-cache bash curl git vim
# Install composer for php deps.
RUN apk add --no-cache composer
# Install postgres pdo driver.
RUN apk add --no-cache postgresql-dev && docker-php-ext-install pdo_pgsql
# Install mysql pdo driver.
RUN apk add --no-cache mysql-dev && docker-php-ext-install pdo_mysql
# Install redis driver.
RUN mkdir -p /usr/src/php/ext/redis; \
curl -fsSL --ipv4 https://github.com/phpredis/phpredis/archive/5.3.4.tar.gz | tar xvz -C "/usr/src/php/ext/redis" --strip 1; \
Expand Down
9 changes: 4 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ services:
depends_on:
- fpm

postgres:
image: postgres:13-alpine
mysql:
image: mysql:8
environment:
POSTGRES_DB: laravel
POSTGRES_USER: root
POSTGRES_HOST_AUTH_METHOD: trust
MYSQL_DATABASE: laravel
MYSQL_ALLOW_EMPTY_PASSWORD: affirm

redis:
image: redis:6.2-alpine
Expand Down
4 changes: 2 additions & 2 deletions fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# From official php image.
FROM php:8.0-fpm-alpine
# Install postgres pdo driver.
RUN apk add --no-cache postgresql-dev && docker-php-ext-install pdo_pgsql
# Install mysql pdo driver.
RUN apk add --no-cache mysql-dev && docker-php-ext-install pdo_mysql
# Install redis driver.
RUN mkdir -p /usr/src/php/ext/redis; \
curl -fsSL --ipv4 https://github.com/phpredis/phpredis/archive/5.3.4.tar.gz | tar xvz -C "/usr/src/php/ext/redis" --strip 1; \
Expand Down
14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Visual Studio Code will actually run inside a Docker container with php-cli as w
Any Extensions will also run in the same container, meaning that intellisense will use the same php-cli configuration!

`laravel-devcontainer` currently ships with:
- `php:8.0-cli-alpine` workspace with composer, pgsql, redis, and nodejs.
- `php:8.0-fpm-alpine` container with pgsql and redis extensions.
- `php:8.0-cli-alpine` workspace with composer, mysql, redis, and nodejs.
- `php:8.0-fpm-alpine` container with mysql and redis extensions.
- `nginx:1.21-alpine` preconfigured for your Laravel application.
- `postgres:13-alpine` preconfigured with the default Laravel credentials.
- `mysql:8` preconfigured with the default Laravel credentials.
- `redis:6.2-alpine` for caching, queues, sessions, etc.

#### Easy Installation
Expand All @@ -38,12 +38,12 @@ git clone --recurse-submodules ...
#### Usage
Start Visual Studio Code (e.g. `code example-app`) and re-open in remote containers (`Remote-Containers: Reopen in Container`). This may take some time on the first use, as Docker initially downloads and builds the images. Eventually, Visual Studio Code will run inside the workspace container. Extensions and settings specified in `devcontainer.json` will be auto-configured!

Be sure to correctly configure your application `.env` to use the devcontainer postgres and redis. For example:
Be sure to correctly configure your application `.env` to use the devcontainer mysql and redis. For example:

```env
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
Expand Down