Set up docker compose
This commit is contained in:
parent
941ef99d32
commit
5520a16b6c
5 changed files with 74 additions and 1 deletions
9
.dockerignore
Normal file
9
.dockerignore
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
README.md
|
||||||
|
.env.example
|
||||||
|
vendor/
|
||||||
|
storage/database.sqlite
|
||||||
|
storage/logs/
|
||||||
|
.DS_Store
|
||||||
|
*.log
|
||||||
41
Dockerfile
Normal file
41
Dockerfile
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
FROM php:8.4-cli
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
unzip \
|
||||||
|
libzip-dev \
|
||||||
|
libsqlite3-dev \
|
||||||
|
sqlite3 \
|
||||||
|
&& docker-php-ext-install zip pdo_sqlite \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy composer files
|
||||||
|
COPY composer.json composer.lock ./
|
||||||
|
|
||||||
|
# Install PHP dependencies
|
||||||
|
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||||
|
|
||||||
|
# Copy application code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chmod +x bin/check-and-post \
|
||||||
|
&& mkdir -p storage \
|
||||||
|
&& touch storage/database.sqlite \
|
||||||
|
&& chmod 666 storage/database.sqlite \
|
||||||
|
&& chmod 755 storage \
|
||||||
|
&& chown -R appuser:appuser /app
|
||||||
|
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
CMD ["php", "-f", "bin/check-and-post"]
|
||||||
|
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
|
||||||
|
// Define base_path function if not exists
|
||||||
|
if (!function_exists('base_path')) {
|
||||||
|
function base_path($path = '') {
|
||||||
|
return __DIR__ . '/../' . $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$capsule = new Capsule;
|
$capsule = new Capsule;
|
||||||
|
|
||||||
$capsule->addConnection([
|
$capsule->addConnection([
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Myrmidex\\LemmyPoster\\": "src/"
|
"Feddev\\LemmyArticlePoster\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
|
||||||
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
container_name: lemmy-poster
|
||||||
|
working_dir: /app
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- storage:/app/storage
|
||||||
|
command: ["sh", "-c", "while true; do php bin/check-and-post; sleep 300; done"]
|
||||||
|
environment:
|
||||||
|
- PHP_ENV=production
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
storage:
|
||||||
|
driver: local
|
||||||
Loading…
Reference in a new issue