-
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 pull request #4 from marcosfreitas/develop
Refactoring to Alpine
- Loading branch information
Showing
25 changed files
with
282 additions
and
497 deletions.
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,52 @@ | ||
# @version 4.0.0 | ||
# Configures NGINX . | ||
|
||
FROM nginx:1.19-alpine | ||
LABEL maintainer="marcosfreitas@c4network.com.br" | ||
|
||
# @todo change user to not run as root | ||
#RUN apk add --no-cache shadow &&\ | ||
# usermod -u 1000 nginx | ||
|
||
#USER nginx | ||
|
||
EXPOSE 80 | ||
# @todo not prepared to work with SSL connections yet | ||
EXPOSE 443 | ||
|
||
# @bug misconfiguration, should be tested | ||
#RUN cd / &&\ | ||
# wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh &&\ | ||
# chmod +x wait-for-it.sh | ||
|
||
RUN apk update && apk add --no-cache openssl shadow bash wait4ports &&\ | ||
rm /etc/nginx/nginx.conf &&\ | ||
rm /etc/nginx/conf.d/default.conf | ||
|
||
# From the context of this Dockerfile | ||
ADD /nginx/nginx.conf /etc/nginx/nginx.conf | ||
|
||
#ENV DOCKERIZE_VERSION v0.6.1 | ||
#RUN wget https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz \ | ||
# && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz \ | ||
# && rm dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz | ||
|
||
# @bug problem with folder's permissions | ||
RUN mkdir -p /etc/nginx/sites-enabled &&\ | ||
mkdir -p /etc/nginx/sites-available &&\ | ||
chmod 751 -R /etc/nginx; | ||
|
||
ADD /nginx/vhost-app.conf /etc/nginx/sites-available/app | ||
|
||
RUN ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/app | ||
|
||
RUN ls -l /etc/nginx/conf.d; | ||
RUN ls -l /etc/nginx/; | ||
|
||
# @bug problem with relative paths | ||
#RUN rm -rf /var/www/html | ||
#VOLUME /../../www /var/www/html | ||
#VOLUME /../../.docker/nginx/templates /etc/nginx/templates | ||
#RUN ls /etc/nginx/templates/snippets; | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
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
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
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
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
.docker/nginx/templates/snippets/http-server.conf.template
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,24 @@ | ||
# @info default http:80 server | ||
|
||
server { | ||
listen ${NGINX_PORT} default_server; | ||
listen [::]:${NGINX_PORT} default_server; | ||
|
||
root ${NGINX_ROOT}; | ||
|
||
server_name ${NGINX_HOST}; | ||
|
||
# to SSL permanent redirect for all request on port 80 | ||
#server_name _; | ||
#return 301 https://$host$request_uri; | ||
|
||
# load general security configurations | ||
include conf.d/snippets/security-locations.conf; | ||
|
||
# Performance configuration | ||
include conf.d/snippets/cache-directives.conf; | ||
include conf.d/snippets/performance.conf; | ||
|
||
# base configurations of virtual host | ||
include conf.d/snippets/base-vhosts.conf; | ||
} |
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
src/server/nginx/snippets/php.conf → ...ginx/templates/snippets/php.conf.template
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,12 +1,12 @@ | ||
# cache-directives.conf already have bypasses | ||
|
||
location ~ \.php$ { | ||
#include snippets/fastcgi-php.conf; | ||
#include conf.d/snippets/fastcgi-php.conf; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
|
||
include snippets/fastcgi-extra-php-params.conf; | ||
include conf.d/snippets/fastcgi-extra-php-params.conf; | ||
|
||
# With php-fpm (or other unix sockets): | ||
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | ||
fastcgi_pass ${PHP_HOST}:${PHP_PORT}; | ||
} |
File renamed without changes.
File renamed without changes.
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
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,31 @@ | ||
FROM php:7.4-fpm-alpine | ||
LABEL maintainer="marcosfreitas@c4network.com.br" | ||
|
||
ARG APP_ENVIROMENT | ||
|
||
EXPOSE 9000 | ||
|
||
# Added script to easy install PHP extensions | ||
|
||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/ | ||
|
||
# @info fix permissions | ||
# Use the default production configuration | ||
RUN apk update && apk add --no-cache shadow bash composer &&\ | ||
usermod -u 1000 www-data &&\ | ||
mv "$PHP_INI_DIR/php.ini-$APP_ENVIROMENT" "$PHP_INI_DIR/php.ini" &&\ | ||
install-php-extensions mysqli pdo_mysql bcmath gd &&\ | ||
php-fpm -m | ||
|
||
COPY /src/scripts/ /usr/share/.docker/src/scripts | ||
|
||
RUN chmod +x /usr/share/.docker/src/scripts/*.sh &&\ | ||
mkdir -p /var/www/html &&\ | ||
bash /usr/share/.docker/src/scripts/set-right-permissions-by-path.sh /var/www/ &&\ | ||
bash /usr/share/.docker/src/scripts/set-right-permissions-by-path.sh /var/www/html | ||
|
||
WORKDIR /var/www/html | ||
|
||
USER www-data | ||
|
||
ENTRYPOINT [ "/usr/share/.docker/src/scripts/laravel-initial-configurations.sh" ] |
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
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,21 @@ | ||
#!/bin/bash | ||
|
||
# Run as: | ||
# bash this-script.sh /var/www and again passing your project folder /var/www/project-path | ||
|
||
FILE_PATH=$1; | ||
|
||
if [[ ! -d "$FILE_PATH" ]]; then | ||
echo 'Path argument not defined'; | ||
exit; | ||
fi; | ||
|
||
chmod 775 ${FILE_PATH} -R && \ | ||
chmod 2775 ${FILE_PATH} -R && \ | ||
chown -R www-data:www-data ${FILE_PATH} -R; | ||
|
||
if [[ ! -z $(ls -A .) ]]; then | ||
cd ${FILE_PATH} && find * -type d -exec chmod -R 775 {} \; && find * -type f -exec chmod -R 664 {} \; | ||
else | ||
echo 'Path is empty, not running commands for children.'; | ||
fi; |
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 @@ | ||
COMPOSE_PROJECT_NAME=SKINNY_HOSTS | ||
APP_ENVIROMENT=development |
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,3 @@ | ||
__OLD | ||
!/.docker | ||
www |
This file was deleted.
Oops, something went wrong.
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,5 +1,32 @@ | ||
# Laravel Host em docker - para testes | ||
Imagem pré-configurada com nginx e php-fpm 7.2 para efeito de testes. Não utilize em produção. | ||
# Imagens Alpine com NGINX, PHP-FPM e MySQL para hospedagem Laravel em Docker (Em desenvolvimento) | ||
|
||
**Os arquivos Laravel devem ser instalados previamente na pasta www.** | ||
|
||
[![Docker Build Status](https://img.shields.io/docker/automated/marcosfreitas/docker-laravel-host?style=for-the-badge)](https://hub.docker.com/r/marcosfreitas/docker-laravel-host/) | ||
Este projeto está equipado com docker-compose, ao clonar você pode executar desta forma: | ||
|
||
`docker-compose up -d` | ||
|
||
A imagem construída do projeto Laravel foi publicada no Docker HUB: | ||
|
||
https://hub.docker.com/r/marcosfreitas/skinny-hosts/ | ||
|
||
[![Docker Build Status](https://img.shields.io/docker/automated/marcosfreitas/skinny-hosts?style=for-the-badge)](https://hub.docker.com/r/marcosfreitas/skinny-hosts/) | ||
|
||
# Detalhes dos Containeres | ||
|
||
### NGINX | ||
O serviço de NGINX possui configurações customizadas a partir dos templates em **.docker/nginx**. | ||
Ele depende do serviço de php e se comunica pelo host e porta passados nas variáveis de ambiente. | ||
|
||
### PHP-FPM | ||
O serviço de PHP-FPM não possui configurações customizadas, mas a construção do container prepara as permissões corretas de arquivos e a instalação do Laravel de acordo com os scripts Bash nas pasta **.docker/src/scripts**. | ||
|
||
### MySQL | ||
O MySQL possui a versão 8+ com implementação de fallback de autenticação para versão 5.7. | ||
|
||
|
||
## Detalhes | ||
|
||
Na raiz do repositório há o arquivo .env que define o nome do projeto que reflete nas configurações do Laravel, prefixo de containeres e nome de Banco de dados, além do ambiente (development ou production) para o php-fpm. | ||
|
||
O arquivo docker-compose.yml implementa outras variáveis de ambiente utilizadas pelo dockerize. |
Oops, something went wrong.