Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
taisukearase committed Sep 24, 2020
0 parents commit 65259db
Show file tree
Hide file tree
Showing 14 changed files with 482 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/laravel-create-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: laravel-create-project

on:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
docker-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Docker Compose Version
run: docker-compose --version

- name: Build Docker
run: docker-compose up -d --build

- name: PHP Version
run: docker-compose exec -T app php --version

- name: Composer Version
run: docker-compose exec -T app composer --version

- name: Create Laravel Project
run: docker-compose exec -T app composer create-project --prefer-dist laravel/laravel .

- name: Laravel Version
run: docker-compose exec -T app php artisan --version

- name: Laravel Migrate Testing
run: docker-compose exec -T app php artisan migrate

- name: Laravel Rollback Testing
run: docker-compose exec -T app php artisan migrate:refresh --seed

- name: Laravel Seeding Testing
run: docker-compose exec -T app php artisan db:seed

- name: Laravel PHPUnit Testing
run: docker-compose exec -T app php artisan test
52 changes: 52 additions & 0 deletions .github/workflows/laravel-git-clone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: laravel-git-clone

on:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
docker-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Git Clone Project
run: git clone https://github.com/laravel/laravel.git backend

- name: Docker Compose Version
run: docker-compose --version

- name: Build Docker
run: docker-compose up -d --build

- name: PHP Version
run: docker-compose exec -T app php --version

- name: Composer Version
run: docker-compose exec -T app composer --version

- name: Composer Install
run: docker-compose exec -T app composer install

- name: Laravel Version
run: docker-compose exec -T app php artisan --version

- name: Laravel Settings
run: |
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: Laravel Migrate Testing
run: docker-compose exec -T app php artisan migrate

- name: Laravel Rollback Testing
run: docker-compose exec -T app php artisan migrate:refresh --seed

- name: Laravel Seeding Testing
run: docker-compose exec -T app php artisan db:seed

- name: Laravel PHPUnit Testing
run: docker-compose exec -T app php artisan test
4 changes: 4 additions & 0 deletions .gitignore
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
21 changes: 21 additions & 0 deletions LICENSE
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.
106 changes: 106 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
up:
docker-compose up -d
build:
docker-compose build --no-cache --force-rm
laravel-install:
docker-compose exec app composer create-project --prefer-dist laravel/laravel .
create-project:
@make build
@make up
@make laravel-install
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:
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
npm:
@make npm-install
npm-install:
docker-compose exec web npm install
npm-dev:
docker-compose exec web npm run dev
npm-watch:
docker-compose exec web npm run watch
npm-watch-poll:
docker-compose exec web npm run watch-poll
npm-hot:
docker-compose exec web npm run hot
yarn:
docker-compose exec web yarn
yarn-install:
@make 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
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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 a simple laravel development environment with docker-compose.

## Usage

```bash
$ git clone [email protected]:ucan-lab/docker-laravel.git
$ cd docker-laravel
$ make create-project # Install the latest Laravel project
$ make install-recommend-packages # Not required
```

http://127.0.0.1

Read this [Makefile](https://github.com/ucan-lab/docker-laravel/blob/master/Makefile).

## Tips

Read this [Wiki](https://github.com/ucan-lab/docker-laravel/wiki).

## 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):1.10

### 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

#### Persistent MySQL Storage

By default, the [named volume](https://docs.docker.com/compose/compose-file/#volumes) is mounted, so MySQL data remains even if the container is destroyed.
If you want to delete MySQL data intentionally, execute the following command.

```bash
$ docker-compose down -v && docker-compose up
```
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3.8"
volumes:
php-fpm-socket:
db-store:
services:
app:
build: ./infra/docker/php
volumes:
- php-fpm-socket:/var/run/php-fpm
- ./backend:/work/backend

web:
build: ./infra/docker/nginx
ports:
- 80:80
volumes:
- php-fpm-socket:/var/run/php-fpm
- ./backend:/work/backend

db:
build: ./infra/docker/mysql
ports:
- 3306:3306
volumes:
- db-store:/var/lib/mysql
10 changes: 10 additions & 0 deletions infra/docker/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mysql:8.0
LABEL maintainer="ucan-lab <[email protected]>"

ENV TZ=UTC \
MYSQL_DATABASE=laravel_local \
MYSQL_USER=phper \
MYSQL_PASSWORD=secret \
MYSQL_ROOT_PASSWORD=secret

COPY ./my.cnf /etc/my.cnf
26 changes: 26 additions & 0 deletions infra/docker/mysql/my.cnf
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
20 changes: 20 additions & 0 deletions infra/docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:14.2-alpine as node
FROM nginx:1.18-alpine
LABEL maintainer="ucan-lab <[email protected]>"
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
Loading

0 comments on commit 65259db

Please sign in to comment.