├── Dockerfile ├── LICENSE ├── README.md ├── docker-compose.yml ├── docker-swarm.yml ├── nginx ├── conf.d │ └── readme.md ├── letsencrypt │ └── readme.md ├── nginx.conf └── sites-available │ └── app.conf ├── public └── index.html └── sh-up.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | # Atenção, este Dockerfile foi feito para ser usado em containers com ALPINE, outras versões de linux podem ser incompativeis 2 | # Use a versão do NGINX especificada ou use uma versão padrão 3 | ARG NGINX_VERSION=${NGINX_VERSION} 4 | FROM nginx:${NGINX_VERSION}-alpine 5 | 6 | # Copia o arquivo de configuração nginx.conf personalizado para o contêiner 7 | COPY nginx/nginx.conf /etc/nginx/ 8 | 9 | # Atualiza e instala os pacotes necessários 10 | # certbot certbot-nginx são os responsáveis pela geração de HTTPS 11 | RUN apk update && apk upgrade && \ 12 | apk --update add logrotate openssl bash && \ 13 | apk add --no-cache certbot certbot-nginx 14 | 15 | # Remove a configuração padrão do NGINX 16 | RUN rm -rf /etc/nginx/conf.d/default.conf 17 | 18 | # add user www-data 19 | RUN adduser -D -H -u 1000 -s /bin/bash www-data -G www-data 20 | 21 | # Cria diretórios para o conteúdo do site e dá suas respectivas permissões 22 | RUN mkdir -p /var/www && \ 23 | chown -R www-data:www-data /var/www && \ 24 | chmod 755 -R /var/www 25 | 26 | # Cria diretórios para as configurações do NGINX 27 | RUN mkdir -p /etc/nginx/sites-available /etc/nginx/conf.d && \ 28 | chown -R www-data:www-data /etc/nginx/sites-available /etc/nginx/conf.d 29 | 30 | # Define o diretório de trabalho para o NGINX 31 | WORKDIR /etc/nginx 32 | 33 | # Limpeza: Remove pacotes não utilizados para reduzir o tamanho da imagem 34 | RUN apk del --no-cache 35 | 36 | # Inicia o NGINX quando o contêiner é executado 37 | CMD ["nginx", "-g", "daemon off;"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Urnau Tecnologias e outros 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ambiente de Desenvolvimento 2 | 3 | ## Realizar o build da imagem docker 4 | ```sh 5 | docker compose build 6 | ``` 7 | 8 | ## Realizar o up da imagem docker 9 | ```sh 10 | docker compose up 11 | ``` 12 | 13 | # Ambiente de Produção 14 | - Ter configurado o server_name corretamente no arquivo `./nginx/sites-available/app.conf` 15 | - Iniciar o Docker Swarm 16 | ```sh 17 | docker swarm init 18 | ``` 19 | - Criar rede overlay para o swarm 20 | ```sh 21 | docker network create -d overlay --attachable net_swarm 22 | ``` 23 | 24 | - Execute o comando `sh sh-up.sh` para realizar todos os processos necessários para rodar a imagem no ambiente. 25 | ## Criando certificado 26 | - Acesse o container docker do nginx, e então execute o seguinte comando: 27 | ```sh 28 | certbot --nginx 29 | ``` 30 | - Feito isso basta seguir informações e configurando as configurações que forem solicitadas. 31 | 32 | ## Renovar certificado 33 | - Repita o mesmo passo da criação de certificado 34 | 35 | # Extras: 36 | 🔹 Hostinger - Servidores/Hospedagem de sites [Ótimos Preços] + 20% de Desconto pelo Link: 37 | https://urnau.com.br/cupons/hostinger 38 | 39 | 🔷 PLAYLIST: Curso Grátis de Deploy de aplicação Laravel em Produção: 40 | https://www.youtube.com/playlist?list=PLQsSC6fujdEncVWbJLTepdkrqSGfFiqcL -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | nginx: 4 | build: 5 | context: ./ 6 | args: 7 | NGINX_VERSION: '1.25.2' 8 | # https://hub.docker.com/_/nginx 9 | image: yourusernamedockerhub/nginx 10 | ports: 11 | - '80:80' 12 | - '443:443' 13 | volumes: 14 | - ./nginx/nginx.conf:/etc/nginx/nginx.conf 15 | - ./nginx/sites-available:/etc/nginx/sites-available 16 | - ./nginx/conf.d:/etc/nginx/conf.d 17 | - ./nginx/letsencrypt:/etc/letsencrypt 18 | - ./public:/var/www/public 19 | networks: 20 | - net_local 21 | 22 | networks: 23 | net_local: 24 | driver: bridge 25 | -------------------------------------------------------------------------------- /docker-swarm.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | #Para servidor Linux 3 | services: 4 | nginx: 5 | build: 6 | context: ./ 7 | args: 8 | NGINX_VERSION: '1.25.2' 9 | # https://hub.docker.com/_/nginx 10 | image: yourusernamedockerhub/nginx 11 | ports: 12 | - 80:80 13 | - 443:443 14 | volumes: 15 | - ./nginx/nginx.conf:/etc/nginx/nginx.conf 16 | - ./nginx/sites-available:/etc/nginx/sites-available 17 | - ./nginx/conf.d:/etc/nginx/conf.d 18 | - ./nginx/letsencrypt:/etc/letsencrypt 19 | - ./public:/var/www/public 20 | networks: 21 | - net_swarm 22 | deploy: 23 | replicas: 1 24 | resources: 25 | limits: 26 | cpus: "1" 27 | memory: 1G 28 | reservations: 29 | cpus: "0.25" 30 | memory: 20M 31 | restart_policy: 32 | condition: on-failure 33 | 34 | networks: 35 | net_swarm: 36 | external: true 37 | name: net_swarm 38 | -------------------------------------------------------------------------------- /nginx/conf.d/readme.md: -------------------------------------------------------------------------------- 1 | Aqui podem ficar arquivos de configurações do nginx ou complementares como é o caso de arquivos de upstream. -------------------------------------------------------------------------------- /nginx/letsencrypt/readme.md: -------------------------------------------------------------------------------- 1 | Nesta pasta ficarão os ceriticados emitidos -------------------------------------------------------------------------------- /nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes auto; # voce pode subistituir o auto pelo número de núcles disponíveis ao nginx 3 | pid /run/nginx.pid; 4 | 5 | events { 6 | worker_connections 2048; 7 | multi_accept on; 8 | use epoll; 9 | } 10 | 11 | http { 12 | server_tokens off; 13 | sendfile on; 14 | tcp_nopush on; 15 | tcp_nodelay on; 16 | keepalive_timeout 15; # Define o tempo máximo em segundos que uma conexão pode ser mantida em espera 17 | types_hash_max_size 2048; 18 | client_max_body_size 20M; 19 | 20 | 21 | gzip on; 22 | gzip_disable "msie6"; 23 | 24 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 25 | '$status $body_bytes_sent "$http_referer" ' 26 | '"$http_user_agent" "$http_x_forwarded_for"'; 27 | 28 | access_log /var/log/nginx/access.log main; # Localização do arquivo de log de acesso 29 | # access_log /dev/stdout; # sem logs 30 | error_log /var/log/nginx/error.log; # Localização do arquivo de log de erros 31 | # error_log /dev/stderr; # sem logs 32 | 33 | add_header X-Frame-Options SAMEORIGIN; 34 | add_header X-Content-Type-Options nosniff; 35 | add_header X-XSS-Protection "1; mode=block"; 36 | 37 | ssl_protocols TLSv1.2 TLSv1.3; 38 | ssl_prefer_server_ciphers off; 39 | ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384'; 40 | 41 | 42 | include /etc/nginx/conf.d/*.conf; 43 | include /etc/nginx/sites-available/*.conf; 44 | include /etc/nginx/mime.types; 45 | default_type application/octet-stream; 46 | 47 | open_file_cache off; 48 | charset UTF-8; 49 | } 50 | -------------------------------------------------------------------------------- /nginx/sites-available/app.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | # server_name _; # todos os dominíos possíveis 4 | server_name nginx.urnau.com.br; 5 | 6 | root /var/www/public; 7 | index index.html index.htm; 8 | 9 | location / { 10 | try_files $uri $uri/ =404; # Tenta encontrar o arquivo solicitado, senão retorna 404 11 | } 12 | 13 | # Configurações de cache (exemplo) 14 | location ~* \.(css|js|jpg|jpeg|png)$ { 15 | expires 6h; # Exemplos: max, 30m, 1y, off 16 | log_not_found off; 17 | } 18 | 19 | ## CONFIGURAÇÕES PARA O PHP 20 | # location / { 21 | # try_files $uri $uri/ /index.php$is_args$args; 22 | # } 23 | 24 | # location ~ \.php$ { 25 | # try_files $uri /index.php =404; 26 | # fastcgi_pass my-upstream; 27 | # fastcgi_index index.php; 28 | # fastcgi_buffers 16 16k; 29 | # fastcgi_buffer_size 32k; 30 | # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 31 | # fastcgi_read_timeout 600; 32 | # include fastcgi_params; 33 | # } 34 | } -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 |Este site é fruto de um conteúdo produzido para o YouTube onde é configurado o uso de SSL.
35 |