Containers and basic BUILD for a new CMS

develop
Nathan Steel 9 months ago
parent 5c81fe5fa1
commit a79beb6ddc

1
.gitignore vendored

@ -0,0 +1 @@
php/www/basic/

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

@ -0,0 +1,25 @@
-- 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 'aLeaf'@'%';
-- 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?)
FLUSH PRIVILEGES;
-- Remove root, to prevent root login
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,30 @@
server {
listen 80 default_server;
# server_name localhost;
root /var/www/html/basic;
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;
}
#location ~ /.ht {
# deny all;
#}
}

@ -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();
?>
Loading…
Cancel
Save