Websoft9 / docker-library

Docker Compose examples of selfhosted FOSS based on official image, just run it.
https://www.websoft9.com
Other
36 stars 25 forks source link

complete docker-compose.yml for [Laravel] #614

Open qiaofeng1227 opened 6 months ago

qiaofeng1227 commented 6 months ago

What type of your feature request?

qiaofeng1227 commented 6 months ago
  1. use php runtime
    composer create-project --prefer-dist laravel/laravel myapp
    cd myapp && php artisan serve --host=0.0.0.0 --port=8080
  2. refer to: https://hub.docker.com/r/bitnami/laravel
qiaofeng1227 commented 6 months ago

Laravel FrameWork project have not 【Laravel package】in source. It installed by two way:

1, example project: https://github.com/akaunting/akaunting

git clone https://github.com/akaunting/akaunting.git
composer install

2, example project: https://github.com/octobercms/october

composer create-project october/october myoctober

They are install 【Laravel package】by composer.json, it will make new folders "vendor"

chendelin1982 commented 6 months ago

image: https://github.com/laravel-fans/laravel-docker/blob/main/src/stubs/Dockerfile

qiaofeng1227 commented 6 months ago
version: '3.8'

services:
  laravel:
    image: laravelfans/laravel:latest
    container_name: laravel
    restart: unless-stopped
    ports:
      - '8000:80'
    environment:
      - APP_KEY=base64:L+3avOYCfuq8nnDpHs74+5Et3sx27TssucHQIyqfpDY=
      - APP_ENV=local
      - DB_CONNECTION=sqlite
    volumes:
      - 'data:/var/www/laravel'

networks:
  default:
    name: websoft9
    external: true

volumes:
  data:

image

qiaofeng1227 commented 6 months ago

进入laravel容器创建新项目:

root@ec2006a20b46:/var/www# composer create-project october/october myoctober
...
Generating autoload files
> System\Console\ComposerScript::postAutoloadDump
96 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> System\Console\ComposerScript::postUpdateCmd
No security vulnerability advisories found.
> @php artisan key:generate --ansi
Unable to set application key. No APP_KEY variable was found in the .env file.

myoctober 创建后并没有public文件夹

qiaofeng1227 commented 6 months ago

https://docs.octobercms.com/3.x/setup/installation.html

我申请的key:WG6ZO-YR5K1-EWY00-PUFKC

qiaofeng1227 commented 6 months ago

laravelfans/laravel容器本身有APP_KEY这个环境变量,如果把它设置在docker-compose.yml中,它优先级最高。对容器内的环境变量有影响,将APP_KEY这个环境变量注释掉就不会报错了。