feat: php docker cli

This commit is contained in:
Supan Adit Pratama 2022-05-02 17:51:32 +07:00
parent 8a254b4176
commit 8bb631c172
3 changed files with 12 additions and 17 deletions

View File

@ -1,20 +1,15 @@
FROM php:7.4-apache FROM php:7.4-cli
RUN apt-get update RUN apt-get update
RUN apt-get install -y git zip RUN apt-get install -y git zip
# Set Apache Root
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Enable Some Apache Mod
RUN a2enmod rewrite headers
RUN docker-php-ext-install pdo pdo_mysql RUN docker-php-ext-install pdo pdo_mysql
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
# Composer # Composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
WORKDIR /todo
CMD [ "php", "artisan","serve" ,"--host","0.0.0.0"]

View File

@ -83,25 +83,25 @@ docker-compose -f docker-compose.dev.yml up -d
### Installing / Updating Dependencies ### Installing / Updating Dependencies
```bash ```bash
docker-compose -f docker-compose.dev.yml exec -w /var/www/html todo composer install # Composer Install docker-compose -f docker-compose.dev.yml exec -w /todo todo composer install # Composer Install
``` ```
### Generate Key ### Generate Key
```bash ```bash
docker-compose -f docker-compose.dev.yml exec -w /var/www/html todo php artisan key:generate # Generate Key docker-compose -f docker-compose.dev.yml exec -w /todo todo php artisan key:generate # Generate Key
``` ```
### Database Migration ### Database Migration
```bash ```bash
docker-compose -f docker-compose.dev.yml exec -w /var/www/html todo php artisan migrate docker-compose -f docker-compose.dev.yml exec -w /todo todo php artisan migrate
``` ```
### Database Seed ### Database Seed
```bash ```bash
docker-compose -f docker-compose.dev.yml exec -w /var/www/html todo php artisan db:seed docker-compose -f docker-compose.dev.yml exec -w /todo todo php artisan db:seed
``` ```
### Shutdown Application ### Shutdown Application
@ -113,7 +113,7 @@ docker-compose -f docker-compose.dev.yml down
### Updating `.env` ### Updating `.env`
```bash ```bash
docker-compose -f docker-compose.dev.yml exec -w /var/www/html todo php artisan config:cache docker-compose -f docker-compose.dev.yml exec -w /todo todo php artisan config:cache
``` ```
### Rebuilding Dockerfile ### Rebuilding Dockerfile

View File

@ -5,9 +5,9 @@ services:
context: . context: .
dockerfile: PHP.Dockerfile dockerfile: PHP.Dockerfile
ports: ports:
- "80:80" - "8000:8000"
volumes: volumes:
- "./:/var/www/html" - "./:/todo"
mysqldb: mysqldb:
image: "bitnami/mysql:8.0" image: "bitnami/mysql:8.0"