Learn-Guide / Dockerfile
AnujPanthri
Update Dockerfile
d818c3c unverified
Raw
History Blame Contribute Delete
1.41 kB
# FROM composer
# EXPOSE 8000
# COPY ./ /app
# WORKDIR /app
# RUN cp .env.example .env;
# RUN composer install;
# RUN php artisan key:generate;
# RUN php artisan migrate --force;
# RUN ls -lh
# # RUN chmod -R 777 public
# RUN chmod -R 777 storage
# RUN chmod -R 777 database
# RUN chmod -R 777 bootstrap/cache
# RUN ls -lh
# CMD php artisan serve --host 0.0.0.0 --port 8000
# 1. Use an explicit PHP 8.3 CLI environment as the base
FROM php:8.3-cli-alpine
# 2. Install native system tools and required PHP extensions for Laravel & Termwind
RUN apk add --no-cache \
libxml2-dev \
git \
unzip \
&& docker-php-ext-install dom xml bcmath
# 3. Copy a verified, official Composer binary directly from its image
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# 4. Set up the working directory layout
WORKDIR /app
COPY . /app
# 5. Handle environment configuration and package deployment
RUN cp .env.example .env \
&& composer install --no-interaction --optimize-autoloader
# 6. Run framework bootstrapping scripts
RUN php artisan key:generate
RUN php artisan migrate --force;
# 7. Secure file permission states for storage engines
RUN chmod -R 777 storage database bootstrap/cache
# 8. Expose the networking gateway
EXPOSE 8000
# 9. Array syntax for CMD to handle system signals correctly (Fixes the warning)
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]