dockerize wip

This commit is contained in:
hackerESQ
2024-09-04 17:48:40 -05:00
parent 1c98c374bb
commit 9b7dfb2baf
8 changed files with 195 additions and 6 deletions
+6 -6
View File
@@ -19,12 +19,12 @@ LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=investbrain
# DB_USERNAME=root
# DB_PASSWORD=
DB_CONNECTION=mysql
DB_HOST=investbrain-mysql
DB_PORT=3306
DB_DATABASE=investbrain
DB_USERNAME=investbrain
DB_PASSWORD=investbrain
SESSION_DRIVER=redis
SESSION_LIFETIME=120
+48
View File
@@ -0,0 +1,48 @@
networks:
investbrain_network:
driver: bridge
services:
app:
build:
context: .
dockerfile: docker/Dockerfile
container_name: investbrain-app
restart: unless-stopped
tty: true
expose:
- "9000"
volumes:
- .:/var/www/app:delegated
depends_on:
- mysql
networks:
- investbrain_network
nginx:
image: nginx:alpine
container_name: investbrain-nginx
restart: unless-stopped
tty: true
ports:
- "8000:80"
volumes:
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
- .:/var/www/app:delegated
depends_on:
- app
networks:
- investbrain_network
mysql:
image: mysql:8.4
container_name: investbrain-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: investbrain
MYSQL_DATABASE: investbrain
MYSQL_USER: investbrain
MYSQL_PASSWORD: investbrain
volumes:
- investbrain-mysql:/var/lib/mysql
networks:
- investbrain_network
volumes:
investbrain-mysql:
+1
View File
@@ -0,0 +1 @@
dump.rdb
+54
View File
@@ -0,0 +1,54 @@
# use PHP 8.3
FROM php:8.3-fpm
ENV DEBIAN_FRONTEND noninteractive
# Set the working directory
COPY . /var/www/app
WORKDIR /var/www/app
# Install common php extension dependencies
RUN apt-get update && apt-get install -y \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev \
zlib1g-dev \
libzip-dev \
unzip \
libicu-dev \
git \
curl \
redis \
supervisor \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
gd \
zip \
pdo_mysql \
mysqli \
intl
# Install Node.js and npm
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest
# Copy over supervisor configuration
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Update permissions
RUN chown -R www-data:www-data . \
&& chmod -R 775 ./storage \
&& chmod +x ./docker/entrypoint.sh
# install composer
COPY --from=composer:2.6.5 /usr/bin/composer /usr/local/bin/composer
# copy composer.json to workdir & install dependencies
RUN composer install
# Run NPM build
RUN npm install && npm run build
# Run everything else
CMD ["./docker/entrypoint.sh"]
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
echo "Running entrypoint script..."
if [ ! -f /var/www/app/.env ]; then
echo "Ope, gotta create an .env file!"
cp /var/www/app/.env.example /var/www/app/.env
fi
echo "Waiting a second for the database to become available..."
sleep 2
echo "Running migrations..."
/usr/local/bin/php /var/www/app/artisan migrate
echo "Spinning up Supervisor daemon..."
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
+25
View File
@@ -0,0 +1,25 @@
server {
listen 80;
server_name localhost;
root /var/www/app/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass investbrain-app:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.ht {
deny all;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
+2
View File
@@ -0,0 +1,2 @@
# Redis RDB and AOF file location
dir /var/www/app/docker
+41
View File
@@ -0,0 +1,41 @@
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
[program:php]
command=php-fpm -F
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/php.log
stderr_logfile=/var/log/supervisor/php_error.log
[program:redis]
command=redis-server /var/www/app/docker/redis.conf
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/redis.log
stderr_logfile=/var/log/supervisor/redis_error.log
[program:scheduler]
command=php artisan schedule:work
autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:queue-worker]
command=php artisan queue:work --sleep=3 --tries=1 --memory=256 --timeout=3600
process_name=%(program_name)s_%(process_num)02d
autorestart=true
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
numprocs=2
[supervisorctl]