Last active
March 7, 2023 18:22
-
-
Save jovanialferez/d1b260242f1bca83aba2e1646fb777fb to your computer and use it in GitHub Desktop.
Laravel docker-compose setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
networks: | |
app-network: | |
driver: bridge | |
volumes: | |
db-data: | |
driver: local | |
services: | |
app: | |
build: | |
context: . | |
restart: unless-stopped | |
tty: true | |
working_dir: /var/www | |
volumes: | |
- ./:/var/www | |
- ./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini | |
networks: | |
- app-network | |
mysql: | |
image: mariadb:10.4 | |
restart: unless-stopped | |
tty: true | |
ports: | |
- "3306:3306" | |
environment: | |
MYSQL_DATABASE: laravel | |
MYSQL_ROOT_PASSWORD: secret | |
SERVICE_TAGS: dev | |
SERVICE_NAME: mysql | |
volumes: | |
- db-data:/var/lib/mysql | |
networks: | |
- app-network | |
redis: | |
image: redis:4-alpine | |
volumes: | |
- db-data:/data | |
networks: | |
- app-network | |
webserver: | |
image: nginx:alpine | |
restart: unless-stopped | |
ports: | |
- "8080:80" | |
volumes: | |
- ./:/var/www | |
- ./nginx.conf:/etc/nginx/conf.d/default.conf | |
depends_on: | |
- app | |
- mysql | |
networks: | |
- app-network | |
mailhog: | |
image: mailhog/mailhog:latest | |
ports: | |
- "1025:1025" | |
- "8025:8025" | |
networks: | |
- app-network | |
adminer: | |
image: adminer | |
restart: unless-stopped | |
ports: | |
- "8088:8080" | |
networks: | |
- app-network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
/usr/local/sbin/php-fpm -D | |
sudo /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.4-fpm-alpine | |
RUN docker-php-ext-install pdo pdo_mysql pcntl bcmath | |
RUN apk --no-cache add supervisor sudo | |
RUN apk --no-cache add $PHPIZE_DEPS \ | |
&& pecl install xdebug \ | |
&& docker-php-ext-enable xdebug | |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
COPY docker_startup.sh /scripts/docker_startup.sh | |
RUN chmod 755 /scripts/*.sh | |
RUN addgroup --gid 1000 -S www \ | |
&& adduser -S --uid 1000 www -G www \ | |
&& echo "www ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/www \ | |
&& chmod 0440 /etc/sudoers.d/www | |
COPY --chown=www:www . /var/www | |
USER www | |
WORKDIR /var/www | |
CMD ["/scripts/docker_startup.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
client_max_body_size 64M; | |
listen 80; | |
index index.php index.html; | |
access_log /dev/stdout; | |
error_log /dev/stderr; | |
root /var/www/public; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
gzip_static on; | |
} | |
location ~ \.php$ { | |
# try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass app:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[supervisord] | |
nodaemon=true | |
logfile=/dev/null ; each program below will send the logs to /dev/stdout anyway | |
pidfile=/run/supervisord.pid | |
[unix_http_server] | |
file=/run/supervisord.sock | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:///run/supervisord.sock | |
[program:artisan-worker] | |
user=www | |
command=/usr/local/bin/php /var/www/artisan queue:work --tries=3 | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 | |
autorestart=true | |
startretries=0 | |
[program:artisan-scheduler] | |
user=www | |
command=sh -c "sleep 60 && /usr/local/bin/php /var/www/artisan schedule:run" | |
stdout_logfile=/dev/stdout | |
stdout_logfile_maxbytes=0 | |
stderr_logfile=/dev/stderr | |
stderr_logfile_maxbytes=0 | |
autorestart=true | |
startretries=0 | |
# [program:artisan-horizon] | |
# user=www | |
# command=/usr/local/bin/php /var/www/artisan horizon | |
# stdout_logfile=/dev/stdout | |
# stdout_logfile_maxbytes=0 | |
# stderr_logfile=/dev/stderr | |
# stderr_logfile_maxbytes=0 | |
# autorestart=true | |
# startretries=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xdebug.remote_enable=1 | |
xdebug.remote_autostart=1 | |
xdebug.remote_connect_back=0 | |
xdebug.remote_host=192.168.1.101 # host ip | |
#xdebug.remote_host=host.docker.internal | |
#xdebug.remote_host=127.0.0.1 | |
xdebug.remote_handler=dbgp | |
xdebug.idekey=VSCODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment