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

Desafio Hiago Klapowsko. #37

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0731947
iniciado estrutura do projeto
May 4, 2021
8983c27
adicionado admin lte e inserido includes
May 4, 2021
c3887a3
refatorado pagina de home
May 4, 2021
6bd98a2
ajustado banco
May 4, 2021
0056268
adicionado autoload
May 5, 2021
0d50c65
conectando ao banco de dados
May 5, 2021
1f1511b
adicionado pagina de usuarios
May 5, 2021
d7c45d5
ajustado pagina de exercicio usuario
May 5, 2021
6842e51
ajustado layout pagina de usuarios
May 5, 2021
c8f8e34
finalizado lista de usuarios
May 5, 2021
d3a64cc
iniciado ajustes pagina de editar aluno
May 5, 2021
e25f5ac
ajustes na pagina de editar aluno
May 5, 2021
30daabb
edit aluno finalizado
May 5, 2021
ed9a6e2
deletar usuario finalizado
May 5, 2021
7f60037
ajustado pagina de usuario
May 8, 2021
2234825
inserido opção de finalizar treino
May 8, 2021
b7cdef8
pagina de usuario finalizada
May 8, 2021
bef0f40
adicionado pagina de treinos e exercicios
May 8, 2021
2e589d5
refatorado estrutura
May 8, 2021
c76c4e5
inserido opção de adicionar usuario
May 8, 2021
ab4eaa7
inserido logo da tecnofit
May 8, 2021
1ffd34f
ajustado pagina index de exercicios
May 8, 2021
9d06f92
finalizado pagina de editar treino
May 8, 2021
9cf2ece
opção de adicionar exercicio finalizado
May 8, 2021
4c337cc
finalizado opção de checkar se o exercicio está ativo em um treino
May 8, 2021
ed2da27
refactoring exercicio ativo
May 8, 2021
c17a0a1
ajustes na pagina de editar treino
May 8, 2021
7476609
adicionado pagina de editar exercicio
May 8, 2021
ffab26b
ajustado lista de exercicios
May 8, 2021
3ec4538
ajuste no metodo de adicionar exercicio
May 8, 2021
ba5404c
ajustado remover exercicios
May 8, 2021
70c416f
ajustado remover exercicios treinos
May 8, 2021
529dfc1
finalizado editar treino
May 8, 2021
ab129a1
Finalizado adicionar Treino
May 8, 2021
2e63fee
finalizado home
May 8, 2021
1194932
adicionado o dump do sql e ajustado o details
May 10, 2021
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
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/desafio-tecnofit.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"autoload": {
"psr-4": {"Tecnofit\\": "src/"}
}
}
18 changes: 18 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions details.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# Candidato

**Nome**: Ronaldo Matos Rodrigues
**Nome**: Hiago Alves Klapowsko

**Email**: ronaldo.rodrigues@tecnofit.com.br
**Email**: hiagoklapowsko@gmail.com

# Instalação
[...]
1. Para rodar este projeto é necessário primeiro estar com o **docker** e o **docker-compose** instalado em sua maquina.
2. Dentro da pasta do projeto executar o seguinte comando :
`docker-compose up` .
Com isso será iniciado os containers do sistema.
3. Com os containers rodando é necessário importar o banco :
`docker exec -it tecnofit-mysql bash`
e após isso:
`mysql -u professor -p academia_tecnofit < tecnofitsql.sql`
4. Já podemos acessar o sistema: http://localhost:8080.

## Acessos ao banco:
- MYSQL_ROOT_PASSWORD= root
- MYSQL_DATABASE= academia_tecnofit
- MYSQL_USER= professor
- MYSQL_PASSWORD= tecnofit

# Observações
[...]
Para este projeto utilizei as seguintes tecnologias: **Docker**, **PHP** e para montar o front-end utilizei o **Admin LTE** como dashboard do sistema. Enfim espero que gostem, qualquer dúvida estou a disposição :fa-smile-o: !
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.1"
services:

mysql:
image: mysql:8.0
container_name: tecnofit-mysql
working_dir: /application
volumes:
- .:/application
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=academia_tecnofit
- MYSQL_USER=professor
- MYSQL_PASSWORD=tecnofit
ports:
- "8082:3306"

webserver:
image: nginx:alpine
container_name: tecnofit-webserver
working_dir: /application
volumes:
- .:/application
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"

php-fpm:
build: phpdocker/php-fpm
container_name: tecnofit-php-fpm
working_dir: /application
volumes:
- .:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini

166 changes: 166 additions & 0 deletions phpdocker/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<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>phpdocker/nginx/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>
</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>Application file permissions</h1>

<p>As in all server environments, your application needs the correct file permissions to work proberly. You can change the files throught the container, so you won't care if the user exists or has the same ID on your host.</p>

<p><code>docker-compose exec php-fpm chown -R www-data:www-data /application/public</code></p>

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

<h1>Simple basic Xdebug configuration with integration to PHPStorm</h1>

<h2>To config xdebug you need add these lines in php-fpm/php-ini-overrides.ini:</h2>

<h3>For linux:</h3>

<pre><code>xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_autostart = 1
</code></pre>

<h3>For MacOS and Windows:</h3>

<pre><code>xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_autostart = 1
</code></pre>

<h2>Add the section “environment” to the php-fpm service in docker-compose.yml:</h2>

<p>environment:</p>

<p>PHP_IDE_CONFIG: "serverName=Docker"</p>

<h3>Create a server configuration in PHPStorm:</h3>

<ul>
<li>In PHPStorm open Preferences | Languages &amp; Frameworks | PHP | Servers</li>
<li>Add new server</li>
<li>The “Name” field should be the same as the parameter “serverName” in “environment” in docker-compose.yml</li>
<li>A value of the "port" field should be the same as first port(before a colon) in "webserver" service in docker-compose.yml</li>
<li>Select "Use path mappings" and set mappings between a path to your project on a host system and the Docker container.</li>
<li>Finally, add “Xdebug helper” extension in your browser, set breakpoints and start debugging</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>
Loading