dockerizada
This commit is contained in:
parent
86e51517d9
commit
1077d97355
|
@ -0,0 +1,35 @@
|
||||||
|
FROM php:7.4-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 \
|
||||||
|
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:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# 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
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use League\Csv\Reader;
|
||||||
|
use Iterator;
|
||||||
|
|
||||||
|
class CsvService
|
||||||
|
{
|
||||||
|
private const BARRIOS = 'csv/barrios.csv';
|
||||||
|
private const PRODUCTOS = 'csv/productos.csv';
|
||||||
|
|
||||||
|
public static function reader(String $path) : Reader {
|
||||||
|
$csv = Reader::createFromPath(resource_path($path), 'r');
|
||||||
|
$csv->setDelimiter("|");
|
||||||
|
$csv->setEnclosure("'");
|
||||||
|
$csv->setHeaderOffset(0);
|
||||||
|
return $csv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getBarrios() : Iterator {
|
||||||
|
$csv = CsvService::reader(CsvService::BARRIOS);
|
||||||
|
return $csv->getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getProductos() : Iterator {
|
||||||
|
$csv = CsvService::reader(CsvService::PRODUCTOS);
|
||||||
|
return $csv->getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"keywords": ["framework", "laravel"],
|
"keywords": ["framework", "laravel"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0.2",
|
"php": "^7.0.2",
|
||||||
"ext-exif": "*",
|
"ext-exif": "*",
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
"laravel/framework": "^8.65",
|
"laravel/framework": "^8.65",
|
||||||
"laravel/sanctum": "^2.11",
|
"laravel/sanctum": "^2.11",
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
|
"league/csv": "^9.8",
|
||||||
"league/glide-laravel": "^1.0"
|
"league/glide-laravel": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,59 @@
|
||||||
|
version: "3.3"
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
args:
|
||||||
|
user: www
|
||||||
|
uid: ${USERID}
|
||||||
|
context: ./
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: laravel-image
|
||||||
|
container_name: pedi2-app
|
||||||
|
restart: unless-stopped
|
||||||
|
working_dir: /var/www/
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www
|
||||||
|
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mysql:5.7
|
||||||
|
container_name: pedi2-db
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: ${DB_DATABASE}
|
||||||
|
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
|
||||||
|
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||||
|
MYSQL_USER: ${DB_USERNAME}
|
||||||
|
SERVICE_TAGS: dev
|
||||||
|
SERVICE_NAME: mysql
|
||||||
|
volumes:
|
||||||
|
- ./mysql/my.cnf:/etc/mysql/my.cnf
|
||||||
|
- ./mysql/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
|
||||||
|
- dbdata:/var/lib/mysql
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
ports:
|
||||||
|
- ${DB_PORT_EXPOSED}:3306
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:alpine
|
||||||
|
container_name: pedi2-nginx
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- ${NGINX_PORT}:80
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www
|
||||||
|
- ./nginx/conf.d/:/etc/nginx/conf.d/
|
||||||
|
networks:
|
||||||
|
- app-network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
app-network:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
#Volumes
|
||||||
|
volumes:
|
||||||
|
dbdata:
|
||||||
|
driver: local
|
|
@ -0,0 +1,3 @@
|
||||||
|
[mysqld]
|
||||||
|
general_log = 1
|
||||||
|
general_log_file = /var/lib/mysql/general.log
|
|
@ -0,0 +1,20 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
index index.php index.html;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
root /var/www/public;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
nombre|region
|
||||||
|
EJEMPLO|SIN REGION
|
|
Loading…
Reference in New Issue