Docker setup improvements and fixes

pull/6331/head
Your Name 5 days ago
parent faa2d97490
commit b12d41b07d

@ -1,19 +1,22 @@
.git # Folders
.git/
tests/
mariadb-11-data/
redis-data/
node_modules/
vendor/
storage/
bootstrap/cache/
.ddev/
#Files
.gitignore .gitignore
.env .env
.env.* .env.*
!.env.docker .env.example
node_modules .env.docker.example
vendor
storage/logs/*
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/views/*
bootstrap/cache/*
.ddev
docker-compose.yml docker-compose.yml
Dockerfile Dockerfile
README.md README.md
.editorconfig .editorconfig
.phpunit.result.cache .phpunit.result.cache
tests

@ -12,26 +12,33 @@ This setup uses `serversideup/php:8.4-fpm-nginx` as the base image and is design
1. **Copy the environment file:** 1. **Copy the environment file:**
```bash ```bash
cp .env.docker.example .env.docker cp .env.docker.example .env
``` ```
2. **Update `.env.docker` with your configuration:** 2. **Update `.env` with your configuration:**
- Set `APP_KEY` (generate with: `docker compose run --rm pixelfed php artisan key:generate --show`) - Set `APP_KEY` ( generate with https://laravel-encryption-key-generator.vercel.app/ )
- Update `APP_URL`, `APP_DOMAIN`, `ADMIN_DOMAIN`, `SESSION_DOMAIN` with your domain - Update `APP_URL`, `APP_DOMAIN`, `ADMIN_DOMAIN`, `SESSION_DOMAIN` with your domain
- Set secure database passwords for `DB_PASSWORD` and `DB_ROOT_PASSWORD` - Set secure database passwords for `DB_PASSWORD` and `DB_ROOT_PASSWORD`
- Configure mail settings - Configure mail settings
3. **Build and start the containers:** 3. **Build container**
```bash
docker compose build
```
4. **Build and start the containers:**
```bash ```bash
docker compose up -d docker compose up -d
``` ```
4. **Generate application key (if not done in step 2):** 5. **Generate application key (if not done in step 2):**
```bash ```bash
docker compose exec pixelfed php artisan key:generate docker compose exec pixelfed php artisan instance:actor
docker compose exec pixelfed php artisan import:cities
docker compose exec pixelfed php artisan passport:keys
``` ```
5. **Create admin user:** 6. **Create admin user:**
```bash ```bash
docker compose exec pixelfed php artisan user:create docker compose exec pixelfed php artisan user:create
``` ```
@ -77,25 +84,11 @@ server {
} }
``` ```
## Services
- **pixelfed:** Main application (port 8080)
- **db:** MariaDB 11 database
- **redis:** Redis cache and queue backend
- **horizon:** Laravel Horizon queue worker
## Volumes
- `db-data`: Database persistence
- `redis-data`: Redis persistence
- `./storage`: Application storage (uploads, cache, logs)
- `./bootstrap/cache`: Laravel bootstrap cache
## Useful Commands ## Useful Commands
```bash ```bash
# View logs # View logs
docker compose logs -f pixelfed docker compose logs -f
# Run artisan commands # Run artisan commands
docker compose exec pixelfed php artisan [command] docker compose exec pixelfed php artisan [command]
@ -144,6 +137,6 @@ docker compose exec pixelfed php artisan view:clear
``` ```
### Database Connection Issues ### Database Connection Issues
- Verify database credentials in `.env.docker` - Verify database credentials in `.env`
- Check if database container is running: `docker compose ps` - Check if database container is running: `docker compose ps`
- View database logs: `docker compose logs db` - View database logs: `docker compose logs -f db`

@ -31,20 +31,21 @@ RUN install-php-extensions \
zip \ zip \
pdo_mysql \ pdo_mysql \
redis \ redis \
vips vips \
ffi
# Copy application files # Copy application files
COPY --chown=www-data:www-data . /var/www/html COPY --chown=www-data:www-data . /var/www/html
# Install composer dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Set proper permissions # Set proper permissions
RUN chown -R www-data:www-data /var/www/html \ RUN chown -R www-data:www-data /var/www/html \
&& find /var/www/html -type f -exec chmod 644 {} \; \ && find /var/www/html -type f -exec chmod 644 {} \; \
&& find /var/www/html -type d -exec chmod 755 {} \; \ && find /var/www/html -type d -exec chmod 755 {} \; \
&& chmod -R ug+rwx /var/www/html/storage /var/www/html/bootstrap/cache && chmod -R ug+rwx /var/www/html/storage /var/www/html/bootstrap/cache
# Install composer dependencies
RUN composer install --no-ansi --no-interaction --optimize-autoloader
# Switch back to www-data user # Switch back to www-data user
USER www-data USER www-data

12
composer.lock generated

@ -62,16 +62,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.359.9", "version": "3.359.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "754b25dae2f50b568b55735931a3cd73263ac5ae" "reference": "10989892e99083c73e8421b85b5d6f7d2ca0f2f5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/754b25dae2f50b568b55735931a3cd73263ac5ae", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/10989892e99083c73e8421b85b5d6f7d2ca0f2f5",
"reference": "754b25dae2f50b568b55735931a3cd73263ac5ae", "reference": "10989892e99083c73e8421b85b5d6f7d2ca0f2f5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -153,9 +153,9 @@
"support": { "support": {
"forum": "https://github.com/aws/aws-sdk-php/discussions", "forum": "https://github.com/aws/aws-sdk-php/discussions",
"issues": "https://github.com/aws/aws-sdk-php/issues", "issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.359.9" "source": "https://github.com/aws/aws-sdk-php/tree/3.359.10"
}, },
"time": "2025-11-10T19:14:56+00:00" "time": "2025-11-11T19:08:54+00:00"
}, },
{ {
"name": "bacon/bacon-qr-code", "name": "bacon/bacon-qr-code",

@ -1,6 +1,32 @@
version: '3.8'
services: services:
## MariaDB and Redis (optional)
db:
image: mariadb:11
container_name: pixelfed-db
restart: unless-stopped
env_file:
- .env
environment:
MARIADB_DATABASE: ${DB_DATABASE}
MARIADB_USER: ${DB_USERNAME}
MARIADB_PASSWORD: ${DB_PASSWORD}
MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes:
- ./mariadb-11-data:/var/lib/mysql
networks:
- pixelfed-network
redis:
image: redis:7-alpine
container_name: pixelfed-redis
restart: unless-stopped
command: redis-server --appendonly yes
volumes:
- ./redis-data:/data
networks:
- pixelfed-network
## Pixelfed containers - App (Web/API), Horizon Queue, Scheduled task.
pixelfed: pixelfed:
build: build:
context: . context: .
@ -10,10 +36,12 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
env_file: env_file:
- .env.docker - .env
environment: environment:
# SSL Configuration (handled by reverse proxy)
SSL_MODE: "off"
# PHP Configuration # PHP Configuration
AUTORUN_LARAVEL_MIGRATION_ISOLATION: "true"
PHP_POST_MAX_SIZE: "500M" PHP_POST_MAX_SIZE: "500M"
PHP_UPLOAD_MAX_FILE_SIZE: "500M" PHP_UPLOAD_MAX_FILE_SIZE: "500M"
PHP_OPCACHE_ENABLE: "1" PHP_OPCACHE_ENABLE: "1"
@ -21,14 +49,13 @@ services:
# Laravel Auto-run Configuration # Laravel Auto-run Configuration
AUTORUN_ENABLED: "true" AUTORUN_ENABLED: "true"
AUTORUN_LARAVEL_MIGRATION: "true" AUTORUN_LARAVEL_MIGRATION: "true"
AUTORUN_LARAVEL_MIGRATION_ISOLATION: "true"
AUTORUN_LARAVEL_STORAGE_LINK: "true" AUTORUN_LARAVEL_STORAGE_LINK: "true"
AUTORUN_LARAVEL_EVENT_CACHE: "true" AUTORUN_LARAVEL_EVENT_CACHE: "true"
AUTORUN_LARAVEL_ROUTE_CACHE: "true" AUTORUN_LARAVEL_ROUTE_CACHE: "true"
AUTORUN_LARAVEL_VIEW_CACHE: "true" AUTORUN_LARAVEL_VIEW_CACHE: "true"
AUTORUN_LARAVEL_CONFIG_CACHE: "true" AUTORUN_LARAVEL_CONFIG_CACHE: "true"
# SSL Configuration (handled by reverse proxy)
SSL_MODE: "off"
volumes: volumes:
- ./storage:/var/www/html/storage - ./storage:/var/www/html/storage
- ./bootstrap/cache:/var/www/html/bootstrap/cache - ./bootstrap/cache:/var/www/html/bootstrap/cache
@ -38,43 +65,51 @@ services:
networks: networks:
- pixelfed-network - pixelfed-network
db: horizon:
image: mariadb:11 build:
container_name: pixelfed-db context: .
dockerfile: Dockerfile
container_name: pixelfed-horizon
restart: unless-stopped restart: unless-stopped
command: ["php", "/var/www/html/artisan", "horizon"]
env_file: env_file:
- .env.docker - .env
environment: environment:
MYSQL_DATABASE: ${DB_DATABASE} # Laravel Auto-run Configuration
MYSQL_USER: ${DB_USERNAME} AUTORUN_LARAVEL_STORAGE_LINK: "true"
MYSQL_PASSWORD: ${DB_PASSWORD} AUTORUN_LARAVEL_EVENT_CACHE: "true"
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} AUTORUN_LARAVEL_ROUTE_CACHE: "true"
volumes: AUTORUN_LARAVEL_VIEW_CACHE: "true"
- ./mariadb-11-data:/var/lib/mysql AUTORUN_LARAVEL_CONFIG_CACHE: "true"
networks: PHP_POST_MAX_SIZE: "500M"
- pixelfed-network PHP_UPLOAD_MAX_FILE_SIZE: "500M"
PHP_OPCACHE_ENABLE: "1"
redis:
image: redis:7-alpine
container_name: pixelfed-redis
restart: unless-stopped
command: redis-server --appendonly yes
volumes: volumes:
- ./redis-data:/data - ./storage:/var/www/html/storage
- ./bootstrap/cache:/var/www/html/bootstrap/cache
depends_on:
- db
- redis
networks: networks:
- pixelfed-network - pixelfed-network
horizon: scheduler:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: pixelfed-horizon container_name: pixelfed-scheduler
restart: unless-stopped restart: unless-stopped
command: php artisan horizon command: ["php", "/var/www/html/artisan", "schedule:work"]
stop_signal: SIGTERM
env_file: env_file:
- .env.docker - .env
environment: environment:
AUTORUN_ENABLED: "false" # Laravel Auto-run Configuration
AUTORUN_LARAVEL_STORAGE_LINK: "true"
AUTORUN_LARAVEL_EVENT_CACHE: "true"
AUTORUN_LARAVEL_ROUTE_CACHE: "true"
AUTORUN_LARAVEL_VIEW_CACHE: "true"
AUTORUN_LARAVEL_CONFIG_CACHE: "true"
PHP_POST_MAX_SIZE: "500M" PHP_POST_MAX_SIZE: "500M"
PHP_UPLOAD_MAX_FILE_SIZE: "500M" PHP_UPLOAD_MAX_FILE_SIZE: "500M"
PHP_OPCACHE_ENABLE: "1" PHP_OPCACHE_ENABLE: "1"
@ -84,6 +119,9 @@ services:
depends_on: depends_on:
- db - db
- redis - redis
healthcheck:
test: ["CMD", "healthcheck-schedule"]
start_period: 10s
networks: networks:
- pixelfed-network - pixelfed-network

Loading…
Cancel
Save