Monday, 30 May 2022

docker

Docker File 

 php.dockerfile

FROM php:8.1.1-fpm

WORKDIR /var/www/html

RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libwebp-dev \
libxpm-dev \
libgif-dev \
libldap2-dev \
libgmp-dev \
libzip-dev \
libcurl3-dev \
netcat \
&& docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp -with-xpm \
&& docker-php-ext-install -j$(nproc) gd

RUN docker-php-ext-install pdo pdo_mysql zip gmp exif curl

RUN chown -R www-data:www-data /var/www

RUN php -v


RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/bin --filename=composer
#RUN cd /var/www/html/
#RUN composer update -o
#
#RUN php artisan optimize
#COPY /nginx/crontab /etc/crontabs/root
#RUN pwd
#RUN ls
#RUN chmod 777 -R storage
#RUN chmod 777 -R bootstrap/cache/
# RUN set -x ; \
# addgroup -g 82 -S www-data ; \
# adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
# RUN chown -R www-data:www-data /var/www

 npm.dockerfile

FROM node:13.7

WORKDIR /var/www/html


RUN npm install
RUN npm run production
.dockerignore
version: '3.1'

networks:
fantise:
driver: bridge
volumes:
docker:
driver: local
meilisearch:
driver: local
mysql:
driver: local
src:
driver: local
services:
site:
image: nginx:stable-alpine
container_name: fantise_library_nginx
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- ./src:/var/www/html
- ./docker/cofigs/conf.d/default.conf:/etc/nginx/conf.d/default.conf
- ./docker/cofigs/nginx.conf:/etc/nginx/nginx.conf
depends_on:
- php
- redis
- meilisearch
- mysql
networks:
- fantise
php:
build:
context: .
dockerfile: docker/php.dockerfile
container_name: fantise_php
volumes:
- ./src:/var/www/html
- ./docker/cofigs/php-prod.ini:/usr/local/etc/php/conf.d/php-prod.ini
networks:
- fantise
composer:
build:
context: .
dockerfile: docker/artisan.dockerfile
container_name: fantise_composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: [ 'composer' ]
networks:
- fantise
npm:
image: node:latest
container_name: fantise_npm
volumes:
- ./src:/var/www/html
- ./docker/logs:/root/.npm/_logs/
working_dir: /var/www/html
entrypoint: ['npm']
artisan:
build:
context: .
dockerfile: docker/php.dockerfile
container_name: artisan
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
links:
- mysql
entrypoint: ['php', '/var/www/html/artisan']
networks:
- fantise
mysql:
container_name: fantise_mysql
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- ./mysql:/var/lib/mysql
networks:
- fantise
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
retries: 3
timeout: 5s
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- './redis:/data'
networks:
- fantise
healthcheck:
test: ["CMD", "redis-cli", "ping"]
retries: 3
timeout: 5s
meilisearch:
image: 'getmeili/meilisearch:latest'
ports:
- '${FORWARD_MEILISEARCH_PORT:-7700}:7700'
volumes:
- ./meilisearch:/data.ms
networks:
- fantise
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health"]
retries: 3
timeout: 5s

Monday, 29 November 2021

composer and docker docker-compose

 

composer:
image: composer:latest
container_name: fantise_composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
networks:
- fantise

npm:
image: node:13.7
container_name: fantise_npm
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: ['npm']
site:
image: library/nginx:stable
container_name: fantise_nginx
ports:
- "61141:80"
volumes:
- ./src:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
depends_on:
- php
- mysql
 
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html/public;
client_max_body_size 0;
location / {
try_files $uri $uri/ /index.php?$query_string;

}

location ~ \.php$ {

try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass fantise_php: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 / {


   proxy_pass http://localhost:61141;
proxy_read_timeout 310s;
proxy_set_header Host $host;
proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection "";
client_max_body_size 0;
proxy_request_buffering off;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header SERVER_NAME $host

Friday, 26 November 2021

List of cool linux things

 cli

btop

Resource monitor that shows usage and stats for processor, memory, disks, network and processes.

https://github.com/aristocratos/btop
Screenshot 1
ranger 

ranger is a console file manager with VI key bindings. It provides a minimalistic and nice curses interface with a view on the directory hierarchy. It ships with rifle, a file launcher that is good at automatically finding out which program to use for what file type.

 https://github.com/ranger/rangerhttps://raw.githubusercontent.com/ranger/ranger-assets/master/screenshots/twopane.png


trash cli

trash-cli trashes files recording the original path, deletion date, and permissions. It uses the same trashcan used by KDE, GNOME, and XFCE, but you can invoke it from the command line (and scripts).



https://github.com/andreafrancia/trash-cli

ncdu

sudo apt-get install ncdu
 
ncdu - Wikipedia

 speedtest-cli

 https://github.com/sivel/speedtest-cli

 

Command line interface for testing internet bandwidth using speedtest.net

cheat.sh

 

 gooey

Joplin

 

https://joplinapp.org/

 Ulauncher

BitWarden

 

https://bitwarden.com/download/ 

MailSpring

https://getmailspring.com/

Stacer

https://oguzhaninan.github.io/Stacer-Web/

Thursday, 20 April 2017

How to calculate if table rows are inserted consecutively in MySQL



As a Developer, I'm often working with asynchronous code, code that isn't well  synchronous be that with workers or events, sometimes this means the created time is out of order and to report on it we need to validate the created date time.

SELECT @a := 0;
SELECT invid, `date`, `date` - @a AS gap, @a := `date`
FROM INVOICES AS i
HAVING gap < 0

Monday, 20 March 2017

Linux Clipboard Text To Speech

Install festival and esound-clients.

To do so, follow this tutorial: https://help.ubuntu.com/community/TextToSpeech

Install xsel:

sudo apt-get install xsel

Create new file in your home folder, call it "clipboardtospeech.sh" or something.

nano ~/apps/clipboardtospeech.sh

edit it and paste the following line:

xsel --clipboard | festival --tts

Make the script executable

cmod +x ~/apps/clipboardtospeech.sh

Make the file executable make a hotkey that launches the shell script:

~/apps/clipboardtospeech.sh 

Rsync over proxy gcloud / jumpbox

So I needed to pushdown some log files off of a box without a public IP, rather then rsync to the jump box / proxy then  rsync to my local box i made use of the ssh proxy command.

 rsync -avz -e 'ssh -o ProxyCommand="ssh proxxye.url.com -i ~/.ssh/google_compute_engine -W my-internal-ip.internal:22"' my-internal-ip.internal:/var/www/log/workers ~/code/logs/

Wednesday, 27 April 2016

Cross Brouser Support For onPaste clipboardData


Some of the current browsers support a 'clipboardData' property as part of a paste event. This should allow you to query the different data formats created from the current data on the clipboard.

Safari and Chrome have the best support, but it is still incomplete. Firefox has no support if you discount using the XPCOM objects interface. The IE interface is older and only supports Text or URL data.


Firefox, Safari IE and Chrome all sanitize any HTML being pasted. Opera will only paste plain text so HTML sanitation is not an issue. Some earlier version of IE could cause some security issues as they copy hyper-links in full.

Try copying and pasting this paragraph and link into the box below.