Skip to content

Commit

Permalink
Merge branch 'release/v1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
andypanOwlting committed Sep 24, 2019
2 parents a913ec9 + cf31f83 commit 5787744
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
APP_NAME=web-php
APP_PORT=8080

REDIS_HOST=web-redis
REDIS_PORT=6379

DB_DATABASE=example

DB_HOST=web-mysql
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=secret
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor/
.env
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM 1and1internet/ubuntu-16-apache-php-7.2

MAINTAINER andy.pan

# install phpredis function
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-get install -y php7.2-redis

EXPOSE 8080

WORKDIR /var/www/html
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
# Docker-phpDevEnv
Example for PHP+Apache+Mysql+Redis run on docker
Example for Apache+Mysql+PHP+Redis run on docker

## How to use

1. Install docker on your system.

[docker docs](https://docs.docker.com/install/)

2. copy env file
```bash
$ cp .env.example .env
```

3. run on docker
```bash
$ make dev
```

4. enjoy!

## Command line

| command line | help |
| ------------ | ---------------------- |
| $ make dev | run container |
| $ make exec | go into APP container |
| $ make del | delete container |

## for Laravel example

1. go into container
```bash
$ make exec
```

2. init composer
```bash
$ make exec
```

3. request laravel
```bash
$ composer create-project --prefer-dist laravel/laravel blog
```

4. enjoy!<br>
your URL like: `http://127.0.0.1:8080/blog/public`
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: "3.5"
services:
web:
container_name: ${APP_NAME}
hostname: ${APP_NAME}
networks:
- LAN
build:
context: ./
dockerfile: Dockerfile
ports:
- ${APP_PORT}:8080
volumes:
- ./:/var/www/html/
environment:
DB_HOST: ${DB_HOST}
REDIS_HOST: ${REDIS_HOST}

mysql:
image: mysql:5.6
container_name: ${DB_HOST}
hostname: ${DB_HOST}
networks:
- LAN
ports:
- ${DB_PORT}:3306
volumes:
- ./database:/docker-entrypoint-initdb.d
command: [
--innodb-file-format=barracuda,
--innodb-file-per-table=1,
--innodb-large-prefix=1,
--character-set-server=utf8,
--collation-server=utf8_unicode_ci
]
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}

redis:
image: redis:alpine
container_name: ${REDIS_HOST}
hostname: ${REDIS_HOST}
networks:
- LAN
ports:
- ${REDIS_PORT}:6379
networks:
LAN:
driver: bridge
name: web_LAN
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo phpinfo();
14 changes: 14 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include .env

dev: .docker-up

.docker-up:
@docker-compose up -d

exec:
docker exec -it ${APP_NAME} bash

del: .docker-down

.docker-down:
docker-compose down

0 comments on commit 5787744

Please sign in to comment.