0% found this document useful (0 votes)
59 views6 pages

Documentaçao Docker Install

This document provides instructions for setting up Docker containers and Docker Compose files for different types of projects including PHP, Nginx, React, and Laravel projects. It includes Dockerfiles and docker-compose files for building images and linking containers for the app code, web server, and database. It also provides commands for building, pushing, pulling and running the images and linked containers.

Uploaded by

globalr7on
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views6 pages

Documentaçao Docker Install

This document provides instructions for setting up Docker containers and Docker Compose files for different types of projects including PHP, Nginx, React, and Laravel projects. It includes Dockerfiles and docker-compose files for building images and linking containers for the app code, web server, and database. It also provides commands for building, pushing, pulling and running the images and linked containers.

Uploaded by

globalr7on
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PREPARAÇÃO DE RECIPIENTES PARA

PROJETOS
app.dockerfile
FROM php:8.0-fpm
WORKDIR /var/www
RUN docker-php-ext-install bcmath
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg-dev \
libpng-dev \
libwebp-dev \
--no-install-recommends \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install pdo_mysql -j$(nproc) gd
ADD . /var/www
RUN chown -R www-data:www-data /var/www

web.dockerfile
FROM nginx:1.21

COPY vhost.conf /etc/nginx/conf.d/default.conf

RUN ln -sf /dev/stdout /var/log/nginx/access.log \


&& ln -sf /dev/stderr /var/log/nginx/error.log

vhost.conf

server {
listen 80;
index index.php index.html;
root /var/www/public;

location / {
try_files $uri /index.php?args;
}

location ~ \.php$ {
fastcgi_split_path_info ˆ(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}

Sem banco
docker-compose.yaml
version: '3.7'

services:
app:
build:
context: .
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
web:
build:
context: .
dockerfile: web.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
depends_on:
- "app"
ports:
- 8080:80

apos Criar

● sudo chmod -R 777 storage


● sudo

after that run:


php artisan cache:clear
php artisan config:clear
php artisan config:cache
com BANCO docker-compose.yaml
version: '3.7'

services:
app:
build:
context: .
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
web:
build:
context: .
dockerfile: web.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
depends_on:
- "app"
ports:
- 8080:80
db:
image: mysql:latest
environment:
MYSQL_DATABASE: 'laravel_db'
MYSQL_USER: 'laravel_user'
MYSQL_PASSWORD: 'Laravel'
MYSQL_ROOT_PASSWORD: 'Laravel'
ports:
- "6033:3306"
expose:
- "6033"
volumes:
- ./my-db:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
links:
- db
environment:
PMA_ARBITRARY: 1
volumes:
- ./php-make/upload.ini:/usr/local/etc/php/php.ini
ports:
- 13306:80
volumes:
my-db:
networks:
default:
external:
name: localdev

docker-compose exec app php artisan migrate:refresh --seed

Docker REACT JS

Comandos para gerar images e fazer push e pull aos repositorios do docker-hub

criar um build da imagen


docker build -t app:blestland-site --platform linux/x86_64 .(adicionar platform caso seja M1)

gerar a tag com o nome da imagen e o nome do repositorio


docker tag app:blestland-site itxnacional/blestland:latest

fazer push no docker-hub


docker push itxnacional/blestland:latest

No servidor do digital ocean fazer pull para compartilhar projecto do docker-hub


docker pull itxnacional/blestland

Rolar projeto no novo servidor


docker run -p 3000:3000 itxnacional/blestland

Docker-compose Sonarqube
criar un arquivo docker-compose.yml
version: '3.7'

services:
jenkins:
image: jenkins/jenkins:lts
ports:
- "8189:8189"
- "50000:50000"
networks:
- jenkins
volumes:
- /var/jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
postgres:
image: postgres:9.6
networks:
- jenkins
environment:
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonarpasswd
volumes:
- /var/postgres-data:/var/lib/postgresql/data
sonarqube:
image: sonarqube:lts
ports:
- "9000:9000"
- "9092:9092"
networks:
- jenkins
environment:
SONARQUBE_JDBC_USERNAME: sonar
SONARQUBE_JDBC_PASSWORD: sonarpasswd
SONARQUBE_JDBC_URL: "jdbc:postgresql://postgres:5432/sonar"
depends_on:
- postgres

networks:
jenkins:

adicionar Network
https://github.com/docker/for-linux/issues/418

My recommended work-around is to create a network utilizing an unused private address


range on your machine:

docker network create localdev --subnet 10.0.1.0/24


Configure docker compose to use this as an external network. Either adding the following to
the compose file or the override file as shown:

$ cat docker-compose.override.yml
version: '3'
networks:
default:
external:
name: localdev
Estructura Docker para site HTML, CSS, JAVASCRIPT

My recommended work-around is to create a network utilizing an unused private address


range on your machine:
docker network create localdev --subnet 10.0.1.0/24

docker-compose.yml
version: '3'

services:
proxy:
image: intergalaxy-test-nginx
build:
context: .
ports:
- "80:80"
networks:
default:
external:
name: localdev3

Dockerfile
FROM nginx:alpine
COPY ./ /usr/share/nginx/html

ERROS
Error Clase nao encontrada Jensseger quando no local funciona e no servidor não
Solução:
1. Remova completamente a pasta vendor/jenssegers
2. Na linha de comando (cmd), vá para a pasta do projeto (laravel-master)
3. Execute o comando composer selfupdate para atualizar o seu composer
4. Execute o comando composer require jenssegers/agent
5. Se o comando acima falhar, acrescente "jenssegers/agent": "*" na seção require
do seu arquivo composer.json, caso ainda não esteja lá
6. Execute o comando composer update -o jenssegers/agent

https://pt.stackoverflow.com/questions/6086/classe-n%C3%A3o-encontrada-mas-em-outro-p
rojeto-funcionava

You might also like