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

Rodando projeto em docker #9

Open
wants to merge 1 commit into
base: generico
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM php:7.1-fpm

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
nodejs \
npm

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd

# Get latest Composer
COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer

# RUN /bin/bash -c composer install

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user

# Set working directory
WORKDIR /var/www

USER $user
55 changes: 55 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@


version: "0.1"
services:
app:
build:
args:
user: sira
uid: 1000
context: ./
dockerfile: Dockerfile
image: sira
container_name: sira-app
restart: unless-stopped
working_dir: /var/www/
ports:
- 8001:8001
volumes:
- ./:/var/www
networks:
- sira

db:
image: mysql:8.3.0
container_name: sira-db
restart: unless-stopped
ports:
- 3306:3306
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: 1234
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- sira

nginx:
image: nginx:latest
container_name: sira-nginx
restart: unless-stopped
ports:
- 8000:80
volumes:
- ./:/var/www
- ./nginx:/etc/nginx/conf.d
networks:
- sira

networks:
sira:
driver: bridge


25 changes: 25 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80;
root /var/www/public;

index index.php index.html;


error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;

location ~ \.php$ {
try_files $uri =404;
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;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}