initial commit
This commit is contained in:
commit
e5a0e260a1
5 changed files with 181 additions and 0 deletions
40
README.md
Normal file
40
README.md
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Deployment of the Ambient Music player with Docker Stack
|
||||
|
||||
This project uses Docker to deploy a Ambient music player with Nginx as the web server.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker installed on your machine
|
||||
- Docker Compose installed
|
||||
|
||||
## Installation
|
||||
|
||||
1. Clone the repository
|
||||
|
||||
`git clone https://github.com/colmaris/ambient.git`
|
||||
|
||||
2. Navigate to the project directory:
|
||||
|
||||
`cd src/`
|
||||
|
||||
3. Install getiD3 lib from [here](https://www.getid3.org/)
|
||||
|
||||
4. Copy your music file in mp3
|
||||
|
||||
5. Build and start the containers with Docker Compose:
|
||||
|
||||
docker-compose up --build
|
||||
|
||||
## Accessing the Application
|
||||
|
||||
Once the containers are running, open your browser and go to `http://localhost`. You should see the page generated by `index.php`.
|
||||
|
||||
### Generate playlist.
|
||||
|
||||
Enter in the php container `docker compose exec php bash` and navigate to the public directory. Then execute the `playlit_gen.php` script : `php playlist_gen.php`. All done and enjoy your music !
|
||||
|
||||
## Stopping the Containers
|
||||
|
||||
To stop the containers, you can use:
|
||||
|
||||
`docker compose down`
|
32
docker-compose.yml
Normal file
32
docker-compose.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
services:
|
||||
# PHP Service
|
||||
php:
|
||||
build:
|
||||
context: . # Build context is current directory
|
||||
dockerfile: docker/php/Dockerfile
|
||||
container_name: php83_ambient # Name our container
|
||||
volumes:
|
||||
- ./src:/var/www/public # Mount our source code
|
||||
networks:
|
||||
- ambient-network # Connect to our network
|
||||
# Make container restart unless stopped manually
|
||||
restart: unless-stopped
|
||||
|
||||
# Nginx Service
|
||||
nginx:
|
||||
image: nginx:latest # Use official Nginx image
|
||||
container_name: nginx_ambient
|
||||
ports:
|
||||
- "8080:80" # Map port 8080 on our PC to 80 in container
|
||||
volumes:
|
||||
- ./src:/var/www/public # Mount same source code
|
||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||
depends_on:
|
||||
- php # Wait for PHP container
|
||||
networks:
|
||||
- ambient-network
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
ambient-network:
|
||||
driver: bridge # Standard Docker network type
|
41
docker/nginx/default.conf
Normal file
41
docker/nginx/default.conf
Normal file
|
@ -0,0 +1,41 @@
|
|||
server {
|
||||
# Listen on port 80
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# Root directory and index files
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
# Logging
|
||||
error_log /var/log/nginx/error.log;
|
||||
access_log /var/log/nginx/access.log;
|
||||
|
||||
# Try files or directories, fallback to PHP
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Handle PHP files
|
||||
location ~ \.php$ {
|
||||
# Pass to PHP container
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
|
||||
# Important! This tells PHP what file to process
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
|
||||
# Include standard FastCGI parameters
|
||||
include fastcgi_params;
|
||||
|
||||
# Some extra settings for better performance
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 256k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
}
|
||||
|
||||
# Deny access to hidden files
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
}
|
46
docker/php/Dockerfile
Normal file
46
docker/php/Dockerfile
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Start with PHP 8.3 FPM (FastCGI Process Manager)
|
||||
FROM php:8.3-fpm
|
||||
|
||||
# Update package list and install dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev \
|
||||
libicu-dev \
|
||||
zip \
|
||||
unzip
|
||||
|
||||
# Clean up to reduce image size
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install PHP extensions
|
||||
# Each one serves specific purpose:
|
||||
RUN docker-php-ext-install \
|
||||
pdo_mysql \
|
||||
mbstring \
|
||||
exif \
|
||||
pcntl \
|
||||
bcmath \
|
||||
gd \
|
||||
intl \
|
||||
zip \
|
||||
opcache
|
||||
|
||||
# Redis for caching/sessions
|
||||
RUN pecl install redis && docker-php-ext-enable redis
|
||||
|
||||
|
||||
# Add our PHP config
|
||||
COPY ./docker/php/php.ini /usr/local/etc/php/conf.d/custom.ini
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www
|
||||
|
||||
# What command to run
|
||||
CMD ["php-fpm"]
|
||||
|
||||
# Document that we use port 9000
|
||||
EXPOSE 9000
|
22
docker/php/php.ini
Normal file
22
docker/php/php.ini
Normal file
|
@ -0,0 +1,22 @@
|
|||
[PHP]
|
||||
# Memory and execution time limits
|
||||
memory_limit = 128M # Maximum memory one script can use
|
||||
max_execution_time = 30 # Maximum time script can run (seconds)
|
||||
upload_max_filesize = 2M # Maximum file upload size
|
||||
post_max_size = 2M # Maximum POST request size
|
||||
|
||||
# Error handling
|
||||
display_errors = Off # Show errors (turn Off in production!)
|
||||
display_startup_errors = On # Show startup errors
|
||||
log_errors = On # Write errors to log
|
||||
error_reporting = E_ALL # Report all errors
|
||||
|
||||
[Date]
|
||||
date.timezone = Europe\Paris # Use UTC for consistent timestamps
|
||||
|
||||
[opcache]
|
||||
# Code caching settings
|
||||
opcache.enable = 1 # Enable code caching
|
||||
opcache.memory_consumption = 256 # Memory for cached code
|
||||
opcache.interned_strings_buffer = 16
|
||||
opcache.max_accelerated_files = 16229
|
Loading…
Add table
Reference in a new issue