Compare commits

...

6 Commits

Author SHA1 Message Date
Nathan Steel d1c04cbea4 Add sass compile script, and DB perms to compose 8 months ago
Nathan Steel 8514412b0a Change nginx conf
Update to correct servername and directory.
Add a commented out server block to help remember that
this container CAN be used for multiple sites.
9 months ago
Nathan Steel b86478ad73 gitignore entire www directory
This will be a skeleton repo for the containers themselves,
so related site-data is irrelevant and should be checked out
independantly.
9 months ago
Nathan Steel b949329f1f Merge branch 'feature/baseContainers' into develop 9 months ago
Nathan Steel f733789aca README additions 9 months ago
Nathan Steel a79beb6ddc Containers and basic BUILD for a new CMS 9 months ago

2
.gitignore vendored

@ -0,0 +1,2 @@
# Ignore all websites in the container, these will be independantly checked out (different git repo)
php/www

@ -41,8 +41,15 @@ htaccess files generated can be switched to nginx with this
## Leaf create (cli to make a starter app if nothing already) ## Leaf create (cli to make a starter app if nothing already)
leaf create my-app --mvc leaf create my-app --mvc
sudo docker exec -it aLeaf-php leaf create html/mvc --mvc
leaf create basic --basic leaf create basic --basic
composer create-project leafs/mvc:v4.0-beta my-app composer create-project leafs/mvc:v4.0-beta my-app
## Shared folders in windows (virtualbox) VMs ## Shared folders in windows (virtualbox) VMs
Need to do this or symlinks don't work, and that messes up a bunch of composer stuff Need to do this or symlinks don't work, and that messes up a bunch of composer stuff
### Ignore this, in future for my own less-dependency application
leaf create basic --basic
leaf install bareui
mkdir basic/app/{controllers,database,models,routes,views/{components,errors,layouts,pages}} -p // https://askubuntu.com/a/828864

@ -0,0 +1,5 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

@ -0,0 +1,30 @@
-- Create a user (or more)
CREATE OR REPLACE USER nathan@'%' IDENTIFIED BY 'password';
CREATE USER 'aLeaf'@'%' IDENTIFIED BY "aLeaf";
-- Role admin, only they have permission to add others to their role
CREATE OR REPLACE ROLE admin WITH ADMIN nathan@'%';
GRANT ALL ON *.* TO admin WITH GRANT OPTION;
-- GRANT ALL PRIVILEGES ON *.* TO admin WITH GRANT OPTION;
CREATE DATABASE 'aNetwork';
GRANT ALL PRIVILEGES ON 'aNetwork'.* TO 'aLeaf'@'%'; -- The user the website is using for access
-- GRANT ALL PRIVILEGES ON *.* TO 'nathan'@'%' WITH GRANT OPTION; -- Priv, all of the belo
-- GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON *.* TO 'username'@'localhost';
-- GRANT USAGE ON *.* TO 'nathan'@'%'; -- Allows usage of the tables I guess (default on create?)
-- https://stackoverflow.com/questions/64653778/why-are-not-working-my-roles-in-my-mysql-database
SET DEFAULT ROLE admin FOR nathan; -- https://mariadb.com/kb/en/set-default-role/
-- SET ROLE ALL;
FLUSH PRIVILEGES;
-- Remove root, to prevent root login (security, yo)
DROP USER root, root@localhost
-- Create tables, and insert data into them
-- USE ecomdb; -- This is setup by default mariadb compose
-- CREATE TABLE products (id mediumint(8) unsigned NOT NULL auto_increment,Name varchar(255) default NULL,Price varchar(255) default NULL, ImageUrl varchar(255) default NULL,PRIMARY KEY (id)) AUTO_INCREMENT=1;
-- INSERT INTO products (Name,Price,ImageUrl) VALUES ("Laptop","100","c-1.png"),("Drone","200","c-2.png"),("VR","300","c-3.png"),("Tablet","50","c-5.png"),("Watch","90","c-6.png"),("Phone Covers","20","c-7.png"),("Phone","80","c-8.png"),("Laptop","150","c-4.png");

@ -0,0 +1,54 @@
# sudo docker compose down && sudo docker compose build --no-cache && sudo docker compose up -d --force-recreate
services:
nginx:
build: ./nginx
#image: nginx:1.27.1 #nginx:latest
container_name: aLeaf-nginx
#ports:
# - 84:80
restart: always
volumes:
- ./php/www:/var/www/html/
# This will overwrite default.conf with the one on the container, BUT "COPY" in dockerfile makes it ours by default
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
php:
build: ./php
#image: php:8.3-fpm
container_name: aLeaf-php
expose:
- 9000
volumes:
- ./php/www:/var/www/html/
db:
#build: ./db
image: mariadb:10.7
container_name: aLeaf-mariadb
volumes:
#- ./db/mysql:/var/lib/mysql # If sharing from windows host, not gonna work. Needs to be on unixFS
- /home/nathan/docker_vol/aleaf_mariadb:/var/lib/mysql
# bind-mount any sql files that should be run while initializing
# Can omit create database as done via environment
- ./db/schema.sql:/docker-entrypoint-initdb.d/schema.sql
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: mariadb
MYSQL_DATABASE: ecomdb
adminer:
container_name: aLeaf-adminer
image: adminer
restart: always
#ports:
# - "4141:4141"
# - "8080:8080"
environment:
ADMINER_DEFAULT_SERVER: aLeaf-mariadb
# docker network create -d bridge proxy # Shared with the NPM instance
networks:
default:
external: true
name: proxy

@ -0,0 +1,2 @@
FROM nginx:1.27.1
COPY ./default.conf /etc/nginx/conf.d/default.conf

@ -0,0 +1,56 @@
server {
listen 80 default_server;
server_name localhost aLeaf.local;
root /var/www/html/website/public;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
sendfile off;
client_max_body_size 100m;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
# Add a second, third, etc site like below
# server {
# listen 80; # Listening port, keep 80
# server_name aBasicPHP.local; # Server name, change to the domain name of the site
# root /var/www/html/basic; # Where the files for the site are (within container)
# index index.php index.html;
# error_log /var/log/nginx/error.log;
# access_log /var/log/nginx/access.log;
# sendfile off;
# client_max_body_size 100m;
# location / {
# try_files $uri $uri/ /index.php?$query_string;
# }
# location ~ \.php$ {
# include fastcgi_params;
# fastcgi_pass php:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param PATH_INFO $fastcgi_path_info;
# }
# }

@ -0,0 +1,30 @@
FROM php:8.3-fpm
RUN apt-get update && apt-get install -y --no-install-recommends \
libzip-dev \
wget \
git \
unzip
RUN docker-php-ext-install zip pdo pdo_mysql mysqli
RUN docker-php-ext-enable mysqli
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer global require leafs/cli -W
RUN ln -s /root/.composer/vendor/bin/leaf /usr/local/bin/leaf
# If you have a custom PHP ini file you can uncomment this line
# COPY ./php.ini /usr/local/etc/php/php.ini
RUN apt-get purge -y g++ \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*
WORKDIR /var/www
# RUN chown -R www-data:www-data /var/www
CMD ["php-fpm"]

@ -0,0 +1 @@
# If using a custom php.ini throw it here (after the container has run, then restart)

@ -0,0 +1,4 @@
<?php
phpinfo();
?>

@ -0,0 +1,3 @@
sass --no-source-map --style compressed \
--watch php/www/website/public/assets/aSkelly/scss:php/www/website/public/assets/aSkelly/css
Loading…
Cancel
Save