mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
Making the whole app into one docker image for easier usage (#104)
This commit is contained in:
28
docker/standalone/nginx.conf
Normal file
28
docker/standalone/nginx.conf
Normal file
@ -0,0 +1,28 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name _;
|
||||
root /var/www/html/public;
|
||||
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
|
||||
index index.php;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
}
|
3
docker/standalone/php.ini
Normal file
3
docker/standalone/php.ini
Normal file
@ -0,0 +1,3 @@
|
||||
[PHP]
|
||||
post_max_size = 100M
|
||||
upload_max_filesize = 100M
|
61
docker/standalone/start.sh
Normal file
61
docker/standalone/start.sh
Normal file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
INIT_FLAG="/var/www/html/storage/.INIT_ENV"
|
||||
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-"password"}
|
||||
NAME=${NAME:-"vito"}
|
||||
EMAIL=${EMAIL:-"vito@example.com"}
|
||||
PASSWORD=${PASSWORD:-"password"}
|
||||
|
||||
# Check if the flag file does not exist, indicating a first run
|
||||
if [ ! -f "$INIT_FLAG" ]; then
|
||||
echo "First run of the container. Initializing MySQL..."
|
||||
|
||||
# Start MySQL temporarily
|
||||
service mysql start
|
||||
|
||||
# Wait for MySQL to start up completely (may need to adjust the sleep duration)
|
||||
sleep 3
|
||||
|
||||
# Create Database
|
||||
mysql -u root -p`echo password` -e "CREATE DATABASE IF NOT EXISTS vito CHARACTER SET utf8 COLLATE utf8_general_ci;"
|
||||
|
||||
# Change Password
|
||||
mysql -u root -p`echo password` -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD'; FLUSH PRIVILEGES;"
|
||||
|
||||
cp /var/www/html/.env.docker /var/www/html/.env
|
||||
|
||||
# Modify /var/www/html/.env and set DB_PASSWORD=password to DB_PASSWORD=MYSQL_ROOT_PASSWORD
|
||||
sed -i "s/DB_PASSWORD=password/DB_PASSWORD=$MYSQL_ROOT_PASSWORD/g" /var/www/html/.env
|
||||
|
||||
php /var/www/html/artisan key:generate
|
||||
|
||||
php /var/www/html/artisan migrate --force
|
||||
|
||||
php /var/www/html/artisan user:create "$NAME" "$EMAIL" "$PASSWORD"
|
||||
|
||||
openssl genpkey -algorithm RSA -out /var/www/html/storage/ssh-private.pem
|
||||
chmod 600 /var/www/html/storage/ssh-private.pem
|
||||
ssh-keygen -y -f /var/www/html/storage/ssh-private.pem > /var/www/html/storage/ssh-public.key
|
||||
|
||||
# Create the flag file to indicate completion of initialization tasks
|
||||
touch "$INIT_FLAG"
|
||||
fi
|
||||
|
||||
service mysql start
|
||||
|
||||
service php8.1-fpm start
|
||||
|
||||
service nginx start
|
||||
|
||||
php /var/www/html/artisan migrate --force
|
||||
php /var/www/html/artisan config:clear
|
||||
php /var/www/html/artisan config:cache
|
||||
php /var/www/html/artisan route:clear
|
||||
php /var/www/html/artisan route:cache
|
||||
php /var/www/html/artisan view:clear
|
||||
php /var/www/html/artisan view:cache
|
||||
php /var/www/html/artisan icons:cache
|
||||
|
||||
echo "Vito is running! 🚀"
|
||||
|
||||
/usr/bin/supervisord
|
16
docker/standalone/supervisord.conf
Normal file
16
docker/standalone/supervisord.conf
Normal file
@ -0,0 +1,16 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
user=root
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
redirect_stderr=true
|
||||
|
||||
[program:worker]
|
||||
user=root
|
||||
autostart=1
|
||||
autorestart=1
|
||||
numprocs=1
|
||||
command=/usr/bin/php /var/www/html/artisan queue:work --sleep=3 --backoff=0 --queue=default,ssh,ssh-long --timeout=3600 --tries=1
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/html/storage/logs/worker.log
|
||||
stopwaitsecs=3600
|
Reference in New Issue
Block a user