Add Docker Compose setup for local runs
PHP 8.3 + Apache image serving public/ on port 8080, with pdo_sqlite and mbstring built in. The container entrypoint applies migrations as www-data before starting Apache; the SQLite database and generated JWT signing key persist in a named "storage" volume. `docker compose up -d` is now the primary way to run the project without a local PHP toolchain. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM php:8.3-apache
|
||||
|
||||
# --- PHP extensions and CLI tools ----------------------------------------------
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libsqlite3-dev \
|
||||
libonig-dev \
|
||||
unzip \
|
||||
curl \
|
||||
&& docker-php-ext-install pdo_sqlite mbstring \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# --- Composer ----------------------------------------------------------------
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# --- Apache: document root -> public/, allow .htaccess rewrites -------------
|
||||
RUN a2enmod rewrite
|
||||
COPY docker/apache.conf /etc/apache2/sites-available/000-default.conf
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# --- PHP dependencies (own layer, cached unless composer.* changes) --------
|
||||
COPY composer.json composer.lock ./
|
||||
RUN composer install --no-dev --no-interaction --no-progress --prefer-dist --no-autoloader
|
||||
|
||||
# --- Application source ----------------------------------------------------
|
||||
COPY . .
|
||||
RUN composer dump-autoload --optimize --no-dev \
|
||||
&& mkdir -p storage \
|
||||
&& chown -R www-data:www-data storage
|
||||
|
||||
# --- Entrypoint: migrate, then hand off to Apache ------------------------
|
||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
CMD ["apache2-foreground"]
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
|
||||
CMD curl -fsS http://localhost/api/health || exit 1
|
||||
Reference in New Issue
Block a user