Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carlos E. Pereira #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,28 @@ Faça um ***Fork*** deste repositório e abra um ***Pull Request***, **com seu n
- Ter um desempenho elevado num conjunto de dados muito grande
- Utilizar o Docker

### Instruções
- Descompactar o arquivo [users.csv.gz](https://s3.amazonaws.com/careers-picpay/users.csv.gz) dentro do diretorio
<b>src/database/DataSeed</b> com o nome <b>users.csv</b>
- Execute o comando:
```
sudo docker-compose up -d
```
- Execute o comando para obter o ip do teste-picpay-mysql para colocar no arquivo .env do projeto
```
sudo docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(sudo docker ps -aq)
```
- Coloque o ip na variável DB_HOST no arquivo .env do projeto
- Execute o comando:
```
sudo docker exec -it teste-picpay-php-fpm /bin/bash
```
- Execute os comando abaixo para carregar os dados.
```
php artisan migrate:install
php artisan migrate
php artisan db:seed
```

Link da aplicação
http://localhost:8080/
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
###############################################################################
# Generated on phpdocker.io #
###############################################################################
version: "3.1"
services:

redis:
image: redis:alpine
container_name: teste-picpay-redis

mysql:
image: mysql:5.6
container_name: teste-picpay-mysql
working_dir: /application
volumes:
- .:/application
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=picpay
- MYSQL_USER=picpay
- MYSQL_PASSWORD=picpay
ports:
- "8082:3306"

webserver:
image: nginx:alpine
container_name: teste-picpay-webserver
working_dir: /application
volumes:
- ./src:/application
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
links:
- mysql
- mysql:database
ports:
- "8080:80"

php-fpm:
build: phpdocker/php-fpm
container_name: teste-picpay-php-fpm
working_dir: /application
volumes:
- ./src:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini

130 changes: 130 additions & 0 deletions phpdocker/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<html>
<head>
<title>PHPDocker.io Readme</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">

<style>
code {
background-color : #ddd;
padding : 2px 5px;
font-family : monospace;
font-size : 16px;
}
</style>
</head>
<body>

<div class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-22-24">
<h1>PHPDocker.io generated environment</h1>

<h1>Add to your project</h1>

<p>Simply, unzip the file into your project, this will create <code>docker-compose.yml</code> on the root of your project and a folder named <code>phpdocker</code> containing nginx and php-fpm config for it.</p>

<p>Ensure the webserver config on <code>docker\nginx.conf</code> is correct for your project. PHPDocker.io will have customised this file according to the application type you chose on the generator, for instance <code>web/app|app_dev.php</code> on a Symfony project, or <code>public/index.php</code> on generic apps.</p>

<p>Note: you may place the files elsewhere in your project. Make sure you modify the locations for the php-fpm dockerfile, the php.ini overrides and nginx config on <code>docker-compose.yml</code> if you do so.</p>

<h1>How to run</h1>

<p>Dependencies:</p>

<ul>
<li>Docker engine v1.13 or higher. Your OS provided package might be a little old, if you encounter problems, do upgrade. See <a href="https://docs.docker.com/engine/installation">https://docs.docker.com/engine/installation</a></li>
<li>Docker compose v1.12 or higher. See <a href="https://docs.docker.com/compose/install/">docs.docker.com/compose/install</a></li>
</ul>

<p>Once you're done, simply <code>cd</code> to your project and run <code>docker-compose up -d</code>. This will initialise and start all the containers, then leave them running in the background.</p>

<h2>Services exposed outside your environment</h2>

<p>You can access your application via <strong><code>localhost</code></strong>, if you're running the containers directly, or through <strong>``</strong> when run on a vm. nginx and mailhog both respond to any hostname, in case you want to add your own hostname on your <code>/etc/hosts</code></p>

<table>
<thead>
<tr>
<th>Service</th>
<th>Address outside containers</th>
</tr>
</thead>
<tbody>
<tr>
<td>Webserver</td>
<td><a href="http://localhost:8080">localhost:8080</a></td>
</tr>
<tr>
<td>MySQL</td>
<td><strong>host:</strong> <code>localhost</code>; <strong>port:</strong> <code>8082</code></td>
</tr>
</tbody>
</table>

<h2>Hosts within your environment</h2>

<p>You'll need to configure your application to use any services you enabled:</p>

<table>
<thead>
<tr>
<th>Service</th>
<th>Hostname</th>
<th>Port number</th>
</tr>
</thead>
<tbody>
<tr>
<td>php-fpm</td>
<td>php-fpm</td>
<td>9000</td>
</tr>
<tr>
<td>MySQL</td>
<td>mysql</td>
<td>3306 (default)</td>
</tr>
<tr>
<td>Redis</td>
<td>redis</td>
<td>6379 (default)</td>
</tr>
</tbody>
</table>

<h1>Docker compose cheatsheet</h1>

<p><strong>Note:</strong> you need to cd first to where your docker-compose.yml file lives.</p>

<ul>
<li>Start containers in the background: <code>docker-compose up -d</code></li>
<li>Start containers on the foreground: <code>docker-compose up</code>. You will see a stream of logs for every container running.</li>
<li>Stop containers: <code>docker-compose stop</code></li>
<li>Kill containers: <code>docker-compose kill</code></li>
<li>View container logs: <code>docker-compose logs</code></li>
<li>Execute command inside of container: <code>docker-compose exec SERVICE_NAME COMMAND</code> where <code>COMMAND</code> is whatever you want to run. Examples:
* Shell into the PHP container, <code>docker-compose exec php-fpm bash</code>
* Run symfony console, <code>docker-compose exec php-fpm bin/console</code>
* Open a mysql shell, <code>docker-compose exec mysql mysql -uroot -pCHOSEN_ROOT_PASSWORD</code></li>
</ul>

<h1>Recommendations</h1>

<p>It's hard to avoid file permission issues when fiddling about with containers due to the fact that, from your OS point of view, any files created within the container are owned by the process that runs the docker engine (this is usually root). Different OS will also have different problems, for instance you can run stuff in containers using <code>docker exec -it -u $(id -u):$(id -g) CONTAINER_NAME COMMAND</code> to force your current user ID into the process, but this will only work if your host OS is Linux, not mac. Follow a couple of simple rules and save yourself a world of hurt.</p>

<ul>
<li>Run composer outside of the php container, as doing so would install all your dependencies owned by <code>root</code> within your vendor folder.</li>
<li>Run commands (ie Symfony's console, or Laravel's artisan) straight inside of your container. You can easily open a shell as described above and do your thing from there.</li>
</ul>
</div>
<div class="pure-u-1-24"></div>
</div>

<script>
var tables = document.getElementsByTagName('table');
for (var i = 0; i < tables.length; i++) {
tables[i].className = "pure-table";
}
</script>
</body>
</html>
59 changes: 59 additions & 0 deletions phpdocker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
PHPDocker.io generated environment
==================================

# Add to your project #

Simply, unzip the file into your project, this will create `docker-compose.yml` on the root of your project and a folder named `phpdocker` containing nginx and php-fpm config for it.

Ensure the webserver config on `docker\nginx.conf` is correct for your project. PHPDocker.io will have customised this file according to the application type you chose on the generator, for instance `web/app|app_dev.php` on a Symfony project, or `public/index.php` on generic apps.

Note: you may place the files elsewhere in your project. Make sure you modify the locations for the php-fpm dockerfile, the php.ini overrides and nginx config on `docker-compose.yml` if you do so.

# How to run #

Dependencies:

* Docker engine v1.13 or higher. Your OS provided package might be a little old, if you encounter problems, do upgrade. See [https://docs.docker.com/engine/installation](https://docs.docker.com/engine/installation)
* Docker compose v1.12 or higher. See [docs.docker.com/compose/install](https://docs.docker.com/compose/install/)

Once you're done, simply `cd` to your project and run `docker-compose up -d`. This will initialise and start all the containers, then leave them running in the background.

## Services exposed outside your environment ##

You can access your application via **`localhost`**, if you're running the containers directly, or through **``** when run on a vm. nginx and mailhog both respond to any hostname, in case you want to add your own hostname on your `/etc/hosts`

Service|Address outside containers
------|---------|-----------
Webserver|[localhost:8080](http://localhost:8080)
MySQL|**host:** `localhost`; **port:** `8082`

## Hosts within your environment ##

You'll need to configure your application to use any services you enabled:

Service|Hostname|Port number
------|---------|-----------
php-fpm|php-fpm|9000
MySQL|mysql|3306 (default)
Redis|redis|6379 (default)

# Docker compose cheatsheet #

**Note:** you need to cd first to where your docker-compose.yml file lives.

* Start containers in the background: `docker-compose up -d`
* Start containers on the foreground: `docker-compose up`. You will see a stream of logs for every container running.
* Stop containers: `docker-compose stop`
* Kill containers: `docker-compose kill`
* View container logs: `docker-compose logs`
* Execute command inside of container: `docker-compose exec SERVICE_NAME COMMAND` where `COMMAND` is whatever you want to run. Examples:
* Shell into the PHP container, `docker-compose exec php-fpm bash`
* Run symfony console, `docker-compose exec php-fpm bin/console`
* Open a mysql shell, `docker-compose exec mysql mysql -uroot -pCHOSEN_ROOT_PASSWORD`

# Recommendations #

It's hard to avoid file permission issues when fiddling about with containers due to the fact that, from your OS point of view, any files created within the container are owned by the process that runs the docker engine (this is usually root). Different OS will also have different problems, for instance you can run stuff in containers using `docker exec -it -u $(id -u):$(id -g) CONTAINER_NAME COMMAND` to force your current user ID into the process, but this will only work if your host OS is Linux, not mac. Follow a couple of simple rules and save yourself a world of hurt.

* Run composer outside of the php container, as doing so would install all your dependencies owned by `root` within your vendor folder.
* Run commands (ie Symfony's console, or Laravel's artisan) straight inside of your container. You can easily open a shell as described above and do your thing from there.
26 changes: 26 additions & 0 deletions phpdocker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server {
listen 80 default;

client_max_body_size 1032M;

access_log /var/log/nginx/application.access.log;


root /application/public;
index index.php;

if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}

location ~ \.php$ {
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}

}
10 changes: 10 additions & 0 deletions phpdocker/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM phpdockerio/php72-fpm:latest
WORKDIR "/application"

# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive

# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.2-mysql php-redis \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
2 changes: 2 additions & 0 deletions phpdocker/php-fpm/php-ini-overrides.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
upload_max_filesize = 1024M
post_max_size = 1032M
15 changes: 15 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
40 changes: 40 additions & 0 deletions src/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
APP_NAME=PicPay
APP_ENV=local
APP_KEY=base64:SPatQSqSJSevZcPwtcBidVNdD9l28Vxrj0b7b5C5MhU=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=172.19.0.2
DB_PORT=3306
DB_DATABASE=picpay
DB_USERNAME=picpay
DB_PASSWORD=picpay
DB_SOCKET =

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Loading