Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aschmelyun/docker-compose-laravel
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: Assisted-Mindfulness/docker-compose-laravel
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 7 files changed
  • 1 contributor

Commits on Dec 28, 2023

  1. Changes for emot.io

    SadElephant committed Dec 28, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    tsubakiky tsubaki
    Copy the full SHA
    ae395fb View commit details
Showing with 26 additions and 44 deletions.
  1. +1 −1 .gitignore
  2. +7 −37 README.md
  3. +8 −5 docker-compose.yml
  4. +4 −1 dockerfiles/php.dockerfile
  5. +2 −0 mysql/.gitignore
  6. +1 −0 php/php.ini
  7. +3 −0 src/.gitignore
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mysql
.DS_Store
.idea
/src/*
44 changes: 7 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# docker-compose-laravel
A pretty simplified Docker Compose workflow that sets up a LEMP network of containers for local Laravel development. You can view the full article that inspired this repo [here](https://dev.to/aschmelyun/the-beauty-of-docker-for-local-laravel-development-13c0).
A pretty simplified Docker Compose workflow that sets up a LEMP network of containers for local Laravel development.

This is a fork of the repository
[aschmelyun/docker-compose-laravel](https://github.com/aschmelyun/docker-compose-laravel)

## Usage

To get started, make sure you have [Docker installed](https://docs.docker.com/docker-for-mac/install/) on your system, and then clone this repository.
To get started, make sure you have [Docker installed](https://docs.docker.com/engine/install/ubuntu/) on your system, and then clone this repository.

Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running `docker-compose up -d --build app`.

@@ -25,6 +28,8 @@ Three additional containers are included that handle Composer, NPM, and Artisan
- `docker-compose run --rm npm run dev`
- `docker-compose run --rm artisan migrate`

if your composer.json file uses git repositories, you will still have to install composer on your local computer and use it instead of the container!

## Permissions Issues

If you encounter any issues with filesystem permissions while visiting your application or running a container command, try completing one of the sets of steps below.
@@ -44,41 +49,6 @@ If you encounter any issues with filesystem permissions while visiting your appl

Then, either bring back up your container network or re-run the command you were trying before, and see if that fixes it.

## Persistent MySQL Storage

By default, whenever you bring down the Docker network, your MySQL data will be removed after the containers are destroyed. If you would like to have persistent data that remains after bringing containers down and back up, do the following:

1. Create a `mysql` folder in the project root, alongside the `nginx` and `src` folders.
2. Under the mysql service in your `docker-compose.yml` file, add the following lines:

```
volumes:
- ./mysql:/var/lib/mysql
```

## Usage in Production

While I originally created this template for local development, it's robust enough to be used in basic Laravel application deployments. The biggest recommendation would be to ensure that HTTPS is enabled by making additions to the `nginx/default.conf` file and utilizing something like [Let's Encrypt](https://hub.docker.com/r/linuxserver/letsencrypt) to produce an SSL certificate.

## Compiling Assets

This configuration should be able to compile assets with both [laravel mix](https://laravel-mix.com/) and [vite](https://vitejs.dev/). In order to get started, you first need to add ` --host 0.0.0.0` after the end of your relevant dev command in `package.json`. So for example, with a Laravel project using Vite, you should see:

```json
"scripts": {
"dev": "vite --host 0.0.0.0",
"build": "vite build"
},
```

Then, run the following commands to install your dependencies and start the dev server:

- `docker-compose run --rm npm install`
- `docker-compose run --rm --service-ports npm run dev`

After that, you should be able to use `@vite` directives to enable hot-module reloading on your local Laravel application.

Want to build for production? Simply run `docker-compose run --rm npm run build`.

## MailHog

13 changes: 8 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ services:
ports:
- "80:80"
volumes:
- ./src:/var/www/html:delegated
- ./src/Emotion-Tracker:/var/www/html:delegated
depends_on:
- php
- redis
@@ -30,6 +30,8 @@ services:
tty: true
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
@@ -50,7 +52,8 @@ services:
ports:
- "9000:9000"
volumes:
- ./src:/var/www/html:delegated
- ./src/Emotion-Tracker:/var/www/html:delegated
- ./php/php.ini:/usr/local/etc/php/conf.d/php.ini
networks:
- laravel

@@ -70,7 +73,7 @@ services:
- UID=${UID:-1000}
- GID=${GID:-1000}
volumes:
- ./src:/var/www/html
- ./src/Emotion-Tracker:/var/www/html
depends_on:
- php
entrypoint: [ 'composer', '--ignore-platform-reqs' ]
@@ -80,7 +83,7 @@ services:
npm:
image: node:current-alpine
volumes:
- ./src:/var/www/html
- ./src/Emotion-Tracker:/var/www/html
ports:
- "3000:3000"
- "3001:3001"
@@ -98,7 +101,7 @@ services:
- UID=${UID:-1000}
- GID=${GID:-1000}
volumes:
- ./src:/var/www/html:delegated
- ./src/Emotion-Tracker:/var/www/html:delegated
depends_on:
- mysql
entrypoint: [ 'php', '/var/www/html/artisan' ]
5 changes: 4 additions & 1 deletion dockerfiles/php.dockerfile
Original file line number Diff line number Diff line change
@@ -22,7 +22,10 @@ RUN sed -i "s/user = www-data/user = laravel/g" /usr/local/etc/php-fpm.d/www.con
RUN sed -i "s/group = www-data/group = laravel/g" /usr/local/etc/php-fpm.d/www.conf
RUN echo "php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf

RUN docker-php-ext-install pdo pdo_mysql
RUN apk add --update \
libzip-dev \
zip \
&& docker-php-ext-install zip pdo pdo_mysql

RUN mkdir -p /usr/src/php/ext/redis \
&& curl -L https://github.com/phpredis/phpredis/archive/5.3.4.tar.gz | tar xvz -C /usr/src/php/ext/redis --strip 1 \
2 changes: 2 additions & 0 deletions mysql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
1 change: 1 addition & 0 deletions php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output_buffering=4096
3 changes: 3 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!README.md