[Update] Docker
Masih belum berjalan
This commit is contained in:
parent
3052aacb45
commit
9cb8155a35
@ -5,3 +5,6 @@ Dockerfile
|
||||
docker-compose.yml
|
||||
.git
|
||||
.gitignore
|
||||
tests
|
||||
*.log
|
||||
storage/logs/*
|
||||
15
Dockerfile
15
Dockerfile
@ -1,4 +1,4 @@
|
||||
# Stage 1: Build Vue
|
||||
# Stage 1: Build Vue (tetap sama)
|
||||
FROM node:20 as node_builder
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
@ -11,19 +11,24 @@ FROM php:8.3-fpm
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git unzip libzip-dev libpng-dev libonig-dev libxml2-dev curl \
|
||||
&& docker-php-ext-install pdo_mysql zip gd mbstring exif pcntl bcmath
|
||||
&& docker-php-ext-install pdo_mysql zip gd mbstring exif pcntl bcmath \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* # Cleanup untuk ukuran kecil
|
||||
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Copy source code KECUALI public (biar ga ketiban build Vue)
|
||||
# Copy source code
|
||||
COPY . .
|
||||
# Copy hasil build Vue dari stage 1
|
||||
# Copy hasil build Vue
|
||||
COPY --from=node_builder /app/dist /var/www/html/public
|
||||
|
||||
RUN composer install --no-dev --optimize-autoloader
|
||||
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
|
||||
RUN php artisan config:cache && php artisan route:cache && php artisan view:cache # Optimasi cache untuk performa laporan/transaksi
|
||||
|
||||
# Set permission dan user non-root
|
||||
RUN chown -R www-data:www-data /var/www/html
|
||||
USER www-data
|
||||
|
||||
EXPOSE 9000
|
||||
CMD ["php-fpm"]
|
||||
|
||||
@ -276,6 +276,13 @@ php artisan backup:run
|
||||
php artisan make:model ProductCategory -m
|
||||
```
|
||||
|
||||
### Production
|
||||
|
||||
> Pastikan `.env.production` sudah ada.
|
||||
|
||||
```bash
|
||||
docker compose --env-file .env.production up --build -d
|
||||
```
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
|
||||
@ -3,16 +3,16 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: laravel_app
|
||||
container_name: laravel_app_prod
|
||||
volumes:
|
||||
- .:/var/www/html
|
||||
command: php artisan serve --host=0.0.0.0 --port=8000
|
||||
- ./storage:/var/www/html/storage
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "9000"
|
||||
depends_on:
|
||||
- mysql
|
||||
environment:
|
||||
APP_ENV: local
|
||||
APP_ENV: production
|
||||
APP_DEBUG: false
|
||||
APP_KEY: ${APP_KEY}
|
||||
DB_CONNECTION: mysql
|
||||
DB_HOST: mysql
|
||||
@ -21,19 +21,36 @@ services:
|
||||
DB_USERNAME: ${DB_USERNAME}
|
||||
DB_PASSWORD: ${DB_PASSWORD}
|
||||
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: nginx_prod
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ./storage:/var/www/html/storage:ro
|
||||
depends_on:
|
||||
- laravel
|
||||
|
||||
mysql:
|
||||
image: mysql:8
|
||||
container_name: mysql_db
|
||||
container_name: mysql_db_prod
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: laravel
|
||||
MYSQL_USER: laravel
|
||||
MYSQL_PASSWORD: laravel
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
MYSQL_DATABASE: ${DB_DATABASE}
|
||||
MYSQL_USER: ${DB_USERNAME}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
|
||||
redis:
|
||||
image: redis:alpine
|
||||
container_name: redis_prod
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
|
||||
21
nginx.conf
Normal file
21
nginx.conf
Normal file
@ -0,0 +1,21 @@
|
||||
server {
|
||||
listen 80;
|
||||
index index.php index.html;
|
||||
error_log /var/log/nginx/error.log;
|
||||
access_log /var/log/nginx/access.log;
|
||||
root /var/www/html/public;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass laravel:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
}
|
||||
@ -196,8 +196,8 @@ import logo_bni from '@/../images/logo_bni.png'
|
||||
import logo_mastercard from '@/../images/logo_mastercard.png'
|
||||
import logo_visa from '@/../images/logo_visa.png'
|
||||
import logo_mandiri from '@/../images/logo_mandiri.png'
|
||||
import inputField from '@/components/inputField.vue'
|
||||
import inputSelect from '@/components/inputSelect.vue'
|
||||
import inputField from '@/components/InputField.vue'
|
||||
import inputSelect from '@/components/InputSelect.vue'
|
||||
|
||||
import axios from 'axios'
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user