Compare commits
8 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
14c74ccaec | 4 weeks ago |
|
|
fcc7b6d7f4 | 4 weeks ago |
|
|
d1c04cbea4 | 10 months ago |
|
|
8514412b0a | 11 months ago |
|
|
b86478ad73 | 11 months ago |
|
|
b949329f1f | 11 months ago |
|
|
f733789aca | 11 months ago |
|
|
a79beb6ddc | 11 months ago |
@ -0,0 +1,2 @@
|
|||||||
|
# Ignore all websites in the container, these will be independantly checked out (different git repo)
|
||||||
|
php/www
|
||||||
@ -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,59 @@
|
|||||||
|
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 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# php:9000
|
||||||
|
|
||||||
|
# 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,104 @@
|
|||||||
|
# The rootless daemon needs to be running for rootless operations
|
||||||
|
# ls $XDG_RUNTIME_DIR/podman/podman.sock
|
||||||
|
# systemctl --user start podman.socket
|
||||||
|
# systemctl --user enable podman.socket
|
||||||
|
# sudo usermod -aG podman $USER
|
||||||
|
# Can enable low ports with
|
||||||
|
# sudo sysctl net.ipv4.ip_unprivileged_port_start=0
|
||||||
|
|
||||||
|
# http://localhost:8081/dashboard#/
|
||||||
|
# http://aleaf.local:8080/
|
||||||
|
|
||||||
|
#podman info
|
||||||
|
#systemctl --user status podman.socket
|
||||||
|
#ls /run/user/$(id -u)/podman/
|
||||||
|
|
||||||
|
# for docker compose stuff
|
||||||
|
# export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock
|
||||||
|
# echo 'export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock' >> ~/.bashrc
|
||||||
|
|
||||||
|
# Create a Pod (kinda a service container for containers)
|
||||||
|
# Expose all the ports of said pod (that will be accessed directly/not by other containers)
|
||||||
|
podman pod create --name aleaf -p 80:80 -p 8080:8080
|
||||||
|
# Don't add the ports if using traefik as entry point, only without
|
||||||
|
#podman pod create --name aleaf
|
||||||
|
# podman rootless doesn't allow priviledged ports < 1024
|
||||||
|
|
||||||
|
# This allows ports <1024 to be used in non root
|
||||||
|
# sudo sysctl net.ipv4.ip_unprivileged_port_start=0
|
||||||
|
|
||||||
|
#podman network create traefik
|
||||||
|
|
||||||
|
podman build -t aleaf-nginx ./nginx
|
||||||
|
podman build -t aleaf-php ./php
|
||||||
|
|
||||||
|
# --pod aleaf # removed --pod from everything atm
|
||||||
|
podman run -d \
|
||||||
|
--pod aleaf \
|
||||||
|
--name aleaf-mariadb \
|
||||||
|
-e MYSQL_ROOT_PASSWORD=mariadb \
|
||||||
|
-e MYSQL_DATABASE=ecomdb \
|
||||||
|
-v ./db/mysql:/var/lib/mysql:Z \
|
||||||
|
-v ./db/schema.sql:/docker-entrypoint-initdb.d/schema.sql:Z \
|
||||||
|
docker.io/library/mariadb:10.7
|
||||||
|
|
||||||
|
podman run -d \
|
||||||
|
--pod aleaf \
|
||||||
|
--name aleaf-adminer \
|
||||||
|
-e ADMINER_DEFAULT_SERVER=aleaf-mariadb \
|
||||||
|
docker.io/library/adminer
|
||||||
|
#-l 'traefik.enable=true' \
|
||||||
|
#-l 'traefik.http.routers.adminer.rule=Host(`adminer.local`)' \
|
||||||
|
#-l 'traefik.http.routers.adminer.entrypoints=web' \
|
||||||
|
#-l 'traefik.http.services.adminer.loadbalancer.server.port=8080' \
|
||||||
|
#-l 'traefik.docker.network=traefik' \
|
||||||
|
# docker.network=podman apparently not needed
|
||||||
|
|
||||||
|
podman run -d \
|
||||||
|
--pod aleaf \
|
||||||
|
--name aleaf-php \
|
||||||
|
-v ./php/www:/var/www/html:Z \
|
||||||
|
aleaf-php
|
||||||
|
|
||||||
|
# aleaf.local
|
||||||
|
podman run -d \
|
||||||
|
--pod aleaf \
|
||||||
|
--name aleaf-nginx \
|
||||||
|
-v ./php/www:/var/www/html:Z \
|
||||||
|
-v ./nginx/default.conf:/etc/nginx/conf.d/default.conf:Z \
|
||||||
|
aleaf-nginx
|
||||||
|
#-l 'traefik.enable=true' \
|
||||||
|
#-l 'traefik.http.routers.aleaf.rule=Host(`aleaf.local`)' \
|
||||||
|
#-l 'traefik.http.routers.aleaf.entrypoints=web' \
|
||||||
|
#-l 'traefik.http.services.aleaf.loadbalancer.server.port=80' \
|
||||||
|
#-l 'traefik.docker.network=traefik' \
|
||||||
|
|
||||||
|
#podman run -d \
|
||||||
|
#--name traefik \
|
||||||
|
#-p 8080:80 \
|
||||||
|
#-p 8081:8080 \
|
||||||
|
#-v /run/user/$(id -u)/podman/podman.sock:/var/run/docker.sock:ro \
|
||||||
|
#docker.io/library/traefik:v3.0 \
|
||||||
|
#--api.insecure=true \
|
||||||
|
#--providers.docker=true \
|
||||||
|
#--providers.docker.endpoint=unix:///var/run/docker.sock \
|
||||||
|
#--providers.docker.exposedbydefault=false \
|
||||||
|
#--entrypoints.web.address=:80
|
||||||
|
# -- stuff used to read container labels (nginx this instance)
|
||||||
|
|
||||||
|
# Stop/start the stack/pod
|
||||||
|
#podman pod start aleaf
|
||||||
|
#podman pod stop aleaf
|
||||||
|
#podman pod rm aleaf
|
||||||
|
|
||||||
|
# Autostart (systemd)
|
||||||
|
#podman generate systemd --name aleaf --files --new
|
||||||
|
#mkdir -p ~/.config/systemd/user
|
||||||
|
#mv *.service ~/.config/systemd/user/
|
||||||
|
#systemctl --user daemon-reload
|
||||||
|
#systemctl --user enable pod-aleaf.service
|
||||||
|
#systemctl --user start pod-aleaf.service
|
||||||
|
|
||||||
|
|
||||||
|
# podman exec -it traefik ls -l /var/run/docker.sock
|
||||||
|
# sudo usermod -aG podman $USER
|
||||||
@ -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…
Reference in New Issue