-
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.
Merge branch 'feature/infra' into develop
- Loading branch information
Showing
7 changed files
with
140 additions
and
1 deletion.
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,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 |
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,2 @@ | ||
/vendor/ | ||
.env |
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,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 |
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 |
---|---|---|
@@ -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` |
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,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 |
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,2 @@ | ||
<?php | ||
echo phpinfo(); |
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,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 |