mirror of
https://github.com/v2board/v2board.git
synced 2025-03-13 06:04:42 +08:00
feat: adds the possibility of using docker for local deployment using docker-compose.
- nginx - phpmyadmin - php v8.2 - redis - mysql - supervisor
This commit is contained in:
parent
0ca47622a5
commit
74ad263193
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@ -0,0 +1,8 @@
|
||||
vendor/
|
||||
.github/
|
||||
docker/
|
||||
pm2.yaml
|
||||
init.sh
|
||||
update.sh
|
||||
update_dev.sh
|
||||
.env
|
12
.env.example
12
.env.example
@ -7,11 +7,11 @@ APP_URL=http://localhost
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=123456
|
||||
DB_DATABASE=board
|
||||
DB_USERNAME=board
|
||||
DB_PASSWORD=board
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@ -19,8 +19,8 @@ QUEUE_CONNECTION=redis
|
||||
SESSION_DRIVER=redis
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_HOST=redis
|
||||
REDIS_PASSWORD=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -17,5 +17,6 @@ yarn-error.log
|
||||
composer.phar
|
||||
composer.lock
|
||||
yarn.lock
|
||||
docker-compose.yml
|
||||
.DS_Store
|
||||
/**/docker/redis-data/*
|
||||
/**/docker/mysql-data/*
|
||||
|
87
docker-compose.yml
Normal file
87
docker-compose.yml
Normal file
@ -0,0 +1,87 @@
|
||||
version: "3.7"
|
||||
|
||||
networks:
|
||||
v2board.network:
|
||||
driver: bridge
|
||||
|
||||
services:
|
||||
php:
|
||||
build:
|
||||
context: ./docker
|
||||
dockerfile: Dockerfile.development
|
||||
restart: unless-stopped
|
||||
container_name: v2board.php
|
||||
tty: true
|
||||
depends_on:
|
||||
- mysql
|
||||
- redis
|
||||
networks:
|
||||
- v2board.network
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- .:/var/www
|
||||
|
||||
nginx:
|
||||
image: nginx:1.25-alpine
|
||||
container_name: v2board.nginx
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
depends_on:
|
||||
- php
|
||||
ports:
|
||||
- "80:80"
|
||||
- "433:433"
|
||||
volumes:
|
||||
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- .:/var/www
|
||||
networks:
|
||||
- v2board.network
|
||||
|
||||
mysql:
|
||||
image: mysql:5
|
||||
restart: unless-stopped
|
||||
container_name: v2board.mysql
|
||||
tty: true
|
||||
networks:
|
||||
- v2board.network
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- ./docker/mysql.cnf:/etc/mysql/conf.d/custom.cnf
|
||||
- ./docker/mysql-data:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_DATABASE: ${DB_DATABASE:-board}
|
||||
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-board}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD:-board}
|
||||
MYSQL_USER: ${DB_USERNAME:-board}
|
||||
|
||||
phpmyadmin:
|
||||
image: library/phpmyadmin
|
||||
container_name: v2board.phpmyadmin
|
||||
tty: true
|
||||
networks:
|
||||
- v2board.network
|
||||
depends_on:
|
||||
- mysql
|
||||
environment:
|
||||
PMA_HOSTS: mysql
|
||||
PMA_ARBITRARY: 1
|
||||
PMA_PORT: 3306
|
||||
ports:
|
||||
- '8080:80'
|
||||
|
||||
redis:
|
||||
image: bitnami/redis:latest
|
||||
restart: unless-stopped
|
||||
container_name: v2board.redis
|
||||
tty: true
|
||||
volumes:
|
||||
- ./docker/redis-data:/bitnami/redis/data
|
||||
networks:
|
||||
- v2board.network
|
||||
environment:
|
||||
ALLOW_EMPTY_PASSWORD: ${REDIS_ALLOW_EMPTY_PASSWORD:-no}
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-redis}
|
||||
ports:
|
||||
- "6379:6379"
|
60
docker/Dockerfile.development
Normal file
60
docker/Dockerfile.development
Normal file
@ -0,0 +1,60 @@
|
||||
FROM php:8.2-fpm-alpine
|
||||
LABEL MAINTAINER="Vagner Cardoso <vagnercardosoweb@gmail.com>"
|
||||
|
||||
# Environments
|
||||
ENV TZ=UTC
|
||||
ENV WORKDIR=/var/www
|
||||
|
||||
# Set timezone
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
# Updates and installs system dependencies
|
||||
RUN apk add --update --no-cache \
|
||||
git \
|
||||
bash \
|
||||
curl \
|
||||
zip \
|
||||
unzip \
|
||||
vim \
|
||||
tzdata \
|
||||
libxml2-dev \
|
||||
icu-dev \
|
||||
oniguruma-dev \
|
||||
linux-headers \
|
||||
supervisor \
|
||||
$PHPIZE_DEPS && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Configure php dependencies and install
|
||||
RUN docker-php-ext-configure pcntl --enable-pcntl
|
||||
RUN docker-php-ext-install fileinfo bcmath mbstring pdo_mysql intl pcntl sockets
|
||||
|
||||
# Install lib from pecl
|
||||
RUN pecl channel-update pecl.php.net \
|
||||
&& pecl install -o -f xdebug \
|
||||
&& pecl install -o -f redis \
|
||||
&& docker-php-ext-enable xdebug redis \
|
||||
&& rm -rf /tmp/pear
|
||||
|
||||
# Install composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Copy php settings
|
||||
COPY ./php-ini ${PHP_INI_DIR}/conf.d
|
||||
|
||||
# Copy supervisor
|
||||
COPY ./supervisord.conf /etc/supervisord.conf
|
||||
|
||||
# Workdir
|
||||
RUN mkdir -p ${WORKDIR}
|
||||
WORKDIR ${WORKDIR}
|
||||
|
||||
# Expose port
|
||||
EXPOSE 9000
|
||||
|
||||
# Copy entrypoint
|
||||
COPY entrypoint /usr/local/bin/entrypoint
|
||||
RUN chmod +x /usr/local/bin/entrypoint
|
||||
|
||||
# Run supervisor
|
||||
CMD ["supervisord", "-c", "/etc/supervisord.conf"]
|
7
docker/entrypoint
Normal file
7
docker/entrypoint
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
composer install -vvv -o --working-dir="$WORKDIR"
|
||||
|
||||
php-fpm
|
17
docker/mysql.cnf
Normal file
17
docker/mysql.cnf
Normal file
@ -0,0 +1,17 @@
|
||||
[mysqld]
|
||||
bind-address = 0.0.0.0
|
||||
|
||||
innodb_buffer_pool_size = 1024M
|
||||
|
||||
default_authentication_plugin=mysql_native_password
|
||||
|
||||
# Unicode
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
|
||||
[client]
|
||||
ssl-mode = DISABLED
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
54
docker/nginx.conf
Normal file
54
docker/nginx.conf
Normal file
@ -0,0 +1,54 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
root /var/www/public;
|
||||
server_name localhost www.localhost;
|
||||
index index.php index.html;
|
||||
|
||||
client_max_body_size 500M;
|
||||
client_body_buffer_size 512k;
|
||||
client_body_in_file_only clean;
|
||||
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
|
||||
charset utf-8;
|
||||
|
||||
access_log /var/www/storage/logs/nginx-access.log;
|
||||
error_log /var/www/storage/logs/nginx-error.log;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
gzip_static on;
|
||||
}
|
||||
|
||||
location = /favicon.ico { access_log off; log_not_found off; }
|
||||
location = /robots.txt { access_log off; log_not_found off; }
|
||||
|
||||
location ~ .*\.(js|css)?$ {
|
||||
expires 1h;
|
||||
error_log off;
|
||||
access_log /dev/null;
|
||||
}
|
||||
|
||||
error_page 404 /index.php;
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass 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 ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
}
|
6
docker/php-ini/20-xdebug.ini
Normal file
6
docker/php-ini/20-xdebug.ini
Normal file
@ -0,0 +1,6 @@
|
||||
xdebug.start_with_request = no
|
||||
xdebug.mode = debug
|
||||
xdebug.client_host = host.docker.internal
|
||||
xdebug.client_port = 9003
|
||||
xdebug.remote_cookie_expire_time = 36000
|
||||
xdebug.idekey = PHPSTORM
|
17
docker/php-ini/99-php.ini
Normal file
17
docker/php-ini/99-php.ini
Normal file
@ -0,0 +1,17 @@
|
||||
allow_url_fopen = On
|
||||
allow_url_include = Off
|
||||
asp_tags = Off
|
||||
display_errors = On
|
||||
display_startup_errors = On
|
||||
error_reporting = E_ALL
|
||||
enable_dl = Off
|
||||
file_uploads = On
|
||||
max_execution_time = 300
|
||||
max_input_time = 60
|
||||
max_input_vars = 100000
|
||||
memory_limit = 1024M
|
||||
session.gc_maxlifetime = 1440
|
||||
upload_max_filesize = 250M
|
||||
post_max_size = 500M
|
||||
max_file_uploads = 50
|
||||
date.timezone = UTC
|
0
docker/redis-data/.gitkeep
Normal file
0
docker/redis-data/.gitkeep
Normal file
41
docker/supervisord.conf
Normal file
41
docker/supervisord.conf
Normal file
@ -0,0 +1,41 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/www/storage/logs/supervisord.log
|
||||
pidfile=/var/www/storage/logs/supervisord.pid
|
||||
|
||||
[program:horizon]
|
||||
command=php /var/www/artisan horizon
|
||||
stopwaitsecs=3600
|
||||
autostart=true
|
||||
autorestart=true
|
||||
redirect_stderr=true
|
||||
startsecs=3
|
||||
startretries=3
|
||||
stdout_logfile=/var/www/storage/logs/supervisor-horizon.out.log
|
||||
stdout_logfile_maxbytes=2MB
|
||||
stderr_logfile=/var/www/storage/logs/supervisor-horizon.err.log
|
||||
stderr_logfile_maxbytes=2MB
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
user=root
|
||||
priority=999
|
||||
numprocs=1
|
||||
|
||||
[program:laravel-scheduler]
|
||||
command=bash -c "while true; do php /var/www/artisan schedule:run --verbose --no-interaction; sleep 60; done"
|
||||
stopwaitsecs=60
|
||||
autostart=true
|
||||
autorestart=true
|
||||
redirect_stderr=true
|
||||
startsecs=3
|
||||
startretries=3
|
||||
stdout_logfile=/var/www/storage/logs/supervisor-scheduler.out.log
|
||||
stdout_logfile_maxbytes=2MB
|
||||
stderr_logfile=/var/www/storage/logs/supervisor-scheduler.err.log
|
||||
stderr_logfile_maxbytes=2MB
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
user=root
|
||||
priority=999
|
||||
numprocs=1
|
||||
|
||||
[program:entrypoint]
|
||||
command=/usr/local/bin/entrypoint
|
Loading…
x
Reference in New Issue
Block a user