generated from ucan-lab/docker-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 820659b
Showing
18 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: laravel-create-project | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Docker Compose Version | ||
run: docker-compose --version | ||
- name: Build Docker | ||
run: | | ||
cd infrastructure | ||
docker-compose build | ||
docker-compose up -d | ||
docker-compose ps | ||
- name: Create Laravel Project | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php --version | ||
docker-compose exec -T app composer --version | ||
docker-compose exec -T app composer create-project --prefer-dist laravel/laravel . | ||
- name: PHP and Laravel Version | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php artisan --version | ||
- name: Laravel Migrate, Rollback, Seeding Testing | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php artisan migrate | ||
docker-compose exec -T app php artisan migrate:refresh --seed | ||
- name: Laravel Testing | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php artisan test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: laravel-git-clone | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Laravel Project Git Clone | ||
run: git clone https://github.com/laravel/laravel.git backend | ||
- name: Docker Compose Version | ||
run: docker-compose --version | ||
- name: Build Docker | ||
run: | | ||
cd infrastructure | ||
docker-compose build | ||
docker-compose up -d | ||
- name: Composer Install | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php --version | ||
docker-compose exec -T app composer --version | ||
docker-compose exec -T app composer install | ||
- name: Laravel Settings | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app cp .env.example .env | ||
docker-compose exec -T app php artisan key:generate | ||
docker-compose exec -T app php artisan storage:link | ||
- name: PHP and Laravel Version | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php artisan --version | ||
- name: Laravel Migrate, Rollback, Seeding Testing | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php artisan migrate | ||
docker-compose exec -T app php artisan migrate:refresh --seed | ||
- name: Laravel Testing | ||
run: | | ||
cd infrastructure | ||
docker-compose exec -T app php artisan test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# PhpStorm file | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2020 ucan-lab/docker-laravel | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# docker-laravel | ||
|
||
![License](https://img.shields.io/github/license/ucan-lab/docker-laravel?color=f05340) | ||
![Stars](https://img.shields.io/github/stars/ucan-lab/docker-laravel?color=f05340) | ||
![Issues](https://img.shields.io/github/issues/ucan-lab/docker-laravel?color=f05340) | ||
![Forks](https://img.shields.io/github/forks/ucan-lab/docker-laravel?color=f05340) | ||
|
||
## Introduction | ||
|
||
Build laravel development environment with docker-compose. | ||
|
||
## Usage | ||
|
||
- [Build for Mac](https://github.com/ucan-lab/docker-laravel/wiki/Build-for-Mac) | ||
- [Build for Windows](https://github.com/ucan-lab/docker-laravel/wiki/Build-for-Windows) | ||
|
||
## Container structure | ||
|
||
```bash | ||
├── app | ||
├── web | ||
└── db | ||
``` | ||
|
||
### app container | ||
|
||
- Base image | ||
- [php](https://hub.docker.com/_/php):7.4-fpm-buster | ||
- [composer](https://hub.docker.com/_/composer):latest | ||
|
||
### web container | ||
|
||
- Base image | ||
- [nginx](https://hub.docker.com/_/nginx):1.18-alpine | ||
- [node](https://hub.docker.com/_/node):14.2-alpine | ||
|
||
### db container | ||
|
||
- Base image | ||
- [mysql](https://hub.docker.com/_/mysql):8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
COMPOSE_PROJECT_NAME=docker-laravel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# docker file | ||
/docker/logs | ||
/docker/php/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
up: | ||
docker-compose up -d | ||
build: | ||
docker-compose build --no-cache --force-rm | ||
create-project: | ||
mkdir -p ./docker/php/bash/psysh | ||
touch ./docker/php/bash/.bash_history | ||
@make build | ||
@make up | ||
docker-compose exec app composer create-project --prefer-dist laravel/laravel . | ||
docker-compose exec app chmod -R 777 storage/ bootstrap/cache/ | ||
install-recommend-packages: | ||
docker-compose exec app composer require doctrine/dbal | ||
docker-compose exec app composer require --dev barryvdh/laravel-ide-helper | ||
docker-compose exec app composer require --dev beyondcode/laravel-dump-server | ||
docker-compose exec app composer require --dev barryvdh/laravel-debugbar | ||
docker-compose exec app composer require --dev roave/security-advisories:dev-master | ||
docker-compose exec app php artisan vendor:publish --provider="BeyondCode\DumpServer\DumpServerServiceProvider" | ||
docker-compose exec app php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider" | ||
init: | ||
mkdir -p ./docker/php/bash/psysh | ||
touch ./docker/php/bash/.bash_history | ||
docker-compose up -d --build | ||
docker-compose exec app composer install | ||
docker-compose exec app cp .env.example .env | ||
docker-compose exec app php artisan key:generate | ||
docker-compose exec app php artisan storage:link | ||
docker-compose exec app php artisan migrate:fresh --seed | ||
remake: | ||
@make destroy | ||
@make init | ||
stop: | ||
docker-compose stop | ||
down: | ||
docker-compose down | ||
restart: | ||
@make down | ||
@make up | ||
destroy: | ||
docker-compose down --rmi all --volumes | ||
destroy-volumes: | ||
docker-compose down --volumes | ||
ps: | ||
docker-compose ps | ||
logs: | ||
docker-compose logs | ||
logs-watch: | ||
docker-compose logs --follow | ||
web: | ||
docker-compose exec web ash | ||
app: | ||
docker-compose exec app bash | ||
migrate: | ||
docker-compose exec app php artisan migrate | ||
fresh: | ||
docker-compose exec app php artisan migrate:fresh --seed | ||
seed: | ||
docker-compose exec app php artisan db:seed | ||
rollback-test: | ||
docker-compose exec app php artisan migrate:fresh | ||
docker-compose exec app php artisan migrate:refresh | ||
tinker: | ||
docker-compose exec app php artisan tinker | ||
test: | ||
docker-compose exec app php artisan test | ||
optimize: | ||
docker-compose exec app php artisan optimize | ||
optimize-clear: | ||
docker-compose exec app php artisan optimize:clear | ||
cache: | ||
docker-compose exec app composer dump-autoload -o | ||
@make optimize | ||
cache-clear: | ||
@make optimize-clear | ||
yarn: | ||
docker-compose exec web yarn | ||
yarn-dev: | ||
docker-compose exec web yarn dev | ||
yarn-watch: | ||
docker-compose exec web yarn watch | ||
yarn-watch-poll: | ||
docker-compose exec web yarn watch-poll | ||
yarn-hot: | ||
docker-compose exec web yarn hot | ||
db: | ||
docker-compose exec db bash | ||
sql: | ||
docker-compose exec db bash -c 'mysql -u $$MYSQL_USER -p$$MYSQL_PASSWORD $$MYSQL_DATABASE' | ||
redis: | ||
docker-compose exec redis redis-cli | ||
ide-helper: | ||
docker-compose exec app php artisan clear-compiled | ||
docker-compose exec app php artisan ide-helper:generate | ||
docker-compose exec app php artisan ide-helper:meta | ||
docker-compose exec app php artisan ide-helper:models --nowrite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: "3.8" | ||
volumes: | ||
db-store: | ||
php-fpm-socket: | ||
services: | ||
app: | ||
build: ./docker/php | ||
volumes: | ||
- php-fpm-socket:/var/run/php-fpm | ||
- ../backend:/work/backend | ||
- ./docker/php/bash/.bash_history:/root/.bash_history | ||
- ./docker/php/bash/psysh:/root/.config/psysh | ||
|
||
web: | ||
build: ./docker/nginx | ||
ports: | ||
- 80:80 | ||
volumes: | ||
- php-fpm-socket:/var/run/php-fpm | ||
- ../backend:/work/backend | ||
|
||
db: | ||
build: ./docker/mysql | ||
volumes: | ||
- db-store:/var/lib/mysql | ||
ports: | ||
- 3306:3306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM mysql:8.0 | ||
|
||
ENV TZ=UTC \ | ||
MYSQL_DATABASE=laravel_local \ | ||
MYSQL_USER=phper \ | ||
MYSQL_PASSWORD=secret \ | ||
MYSQL_ROOT_PASSWORD=secret | ||
|
||
COPY ./my.cnf /etc/my.cnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[mysqld] | ||
character_set_server = utf8mb4 | ||
collation_server = utf8mb4_0900_ai_ci | ||
|
||
# timezone | ||
default-time-zone = SYSTEM | ||
log_timestamps = SYSTEM | ||
|
||
# Error Log | ||
log-error = mysql-error.log | ||
|
||
# Slow Query Log | ||
slow_query_log = 1 | ||
slow_query_log_file = mysql-slow.log | ||
long_query_time = 1.0 | ||
log_queries_not_using_indexes = 0 | ||
|
||
# General Log | ||
general_log = 1 | ||
general_log_file = mysql-general.log | ||
|
||
[mysql] | ||
default-character-set = utf8mb4 | ||
|
||
[client] | ||
default-character-set = utf8mb4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:14.2-alpine as node | ||
FROM nginx:1.18-alpine | ||
SHELL ["/bin/ash", "-oeux", "pipefail", "-c"] | ||
|
||
ENV TZ=UTC | ||
|
||
RUN apk update && \ | ||
apk add --update --no-cache --virtual=.build-dependencies g++ | ||
|
||
# node command | ||
COPY --from=node /usr/local/bin /usr/local/bin | ||
# npm command | ||
COPY --from=node /usr/local/lib /usr/local/lib | ||
# yarn command | ||
COPY --from=node /opt /opt | ||
# nginx config file | ||
COPY ./default.conf /etc/nginx/conf.d/default.conf | ||
|
||
WORKDIR /work/backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
access_log /dev/stdout main; | ||
error_log /dev/stderr warn; | ||
|
||
server { | ||
listen 80; | ||
root /work/backend/public; | ||
|
||
add_header X-Frame-Options "SAMEORIGIN"; | ||
add_header X-XSS-Protection "1; mode=block"; | ||
add_header X-Content-Type-Options "nosniff"; | ||
|
||
index index.html index.htm index.php; | ||
|
||
charset utf-8; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
location = /favicon.ico { access_log off; log_not_found off; } | ||
location = /robots.txt { access_log off; log_not_found off; } | ||
|
||
error_page 404 /index.php; | ||
|
||
location ~ \.php$ { | ||
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
|
||
location ~ /\.(?!well-known).* { | ||
deny all; | ||
} | ||
} |
Oops, something went wrong.