Merge branch 'master' into agregando-contenido-clase-2

This commit is contained in:
Alejandro Lembke Barrientos 2022-09-06 22:04:30 -06:00
commit f9ad5029c0
11 changed files with 1693 additions and 0 deletions

View File

@ -0,0 +1,47 @@
# Download base image ubuntu 20.04
FROM ubuntu:20.04
# LABEL about the custom image
LABEL maintainer="admin@sysadminjournal.com"
LABEL version="0.1"
LABEL description="This is custom Docker Image for \
the PHP-FPM and Nginx Services."
# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive
# Update Ubuntu Software repository
RUN apt update
# Install nginx, php-fpm and supervisord from ubuntu repository
RUN apt install -y nginx php-fpm supervisor && \
rm -rf /var/lib/apt/lists/* && \
apt clean
# Define the ENV variable
ENV nginx_vhost /etc/nginx/sites-available/default
ENV php_conf /etc/php/7.4/fpm/php.ini
ENV nginx_conf /etc/nginx/nginx.conf
ENV supervisor_conf /etc/supervisor/supervisord.conf
# Enable PHP-fpm on nginx virtualhost configuration
COPY default ${nginx_vhost}
RUN sed -i -e 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' ${php_conf} && \
echo "\ndaemon off;" >> ${nginx_conf}
# Copy supervisor configuration
COPY supervisord.conf ${supervisor_conf}
RUN mkdir -p /run/php && \
chown -R www-data:www-data /var/www/html && \
chown -R www-data:www-data /run/php
# Volume configuration
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
# Copy start.sh script and define default command for the container
COPY start.sh /start.sh
CMD ["./start.sh"]
# Expose Port for the Application
EXPOSE 80 443

View File

@ -0,0 +1,17 @@
server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}

View File

@ -0,0 +1,2 @@
#!/bin/sh
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf

View File

@ -0,0 +1,34 @@
[unix_http_server]
file=/dev/shm/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
user=root ;
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /etc/supervisor/conf.d/*.conf
[program:php-fpm7.4]
command=/usr/sbin/php-fpm7.4 -F
numprocs=1
autostart=true
autorestart=true
[program:nginx]
command=/usr/sbin/nginx
numprocs=1
autostart=true
autorestart=true

View File

@ -0,0 +1,3 @@
<?php
echo "Estoy ejecuntado codigo de php";
?>

View File

@ -0,0 +1,3 @@
FROM php:7.2-apache
COPY ./Archivos/ /var/www/html/
EXPOSE 80

View File

@ -0,0 +1,13 @@
FROM node:18
#creamos un directorio para codigo js
RUN mkdir -p /home/app
#copiamos codigo a directorio
COPY . /home/app
#exponemos puesto
EXPOSE 3000
# ejecutamos comando para levantar servicio node
CMD ["node", "/home/app/index.js"]

View File

@ -0,0 +1,19 @@
version: "1.0"
services:
aplicacion:
build: .
ports:
- "3000:3000"
links:
- bdatos
bdatos:
image: mongo
ports:
- "27017:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=santiage
- MONGO_INITDB_ROOT_PASSWORD=santiagepass

View File

@ -0,0 +1,25 @@
import express from 'express'
import mongoose from 'mongoose'
const Animal = mongoose.model('Animal', new mongoose.Schema({
tipo: String,
estado: String,
}))
const app = express()
mongoose.connect('mongodb://santiage:santiagepass@bdatos:27017/miapp?authSource=admin')
app.get('/', async (_req, res) => {
console.log('listando... base de datos...')
const animales = await Animal.find();
return res.send(animales)
})
app.get('/crear/:pTipo', async (_req, res) => {
console.log('creando...')
await Animal.create({ tipo: _req.params.pTipo, estado: 'estado' })
return res.send('ok')
})
app.listen(3000, () => console.log('escuchando ...'))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
{
"name": "mongoapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.1",
"mongoose": "6.4.1"
}
}