Update Dockerfile
This commit is contained in:
2
.env
2
.env
@@ -1 +1,3 @@
|
|||||||
PG_PASS=guR8uchQhQFAGi4yXfHPrF2AHTgN15sOViDL7tu0bfoiPmdI
|
PG_PASS=guR8uchQhQFAGi4yXfHPrF2AHTgN15sOViDL7tu0bfoiPmdI
|
||||||
|
PG_USER=lismikro
|
||||||
|
PG_DB=lismikro
|
||||||
@@ -36,20 +36,21 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8088:8080"
|
- "8088:8080"
|
||||||
depends_on:
|
depends_on:
|
||||||
- laravel-db
|
- postgresql
|
||||||
command: php artisan serve --host=0.0.0.0 --port=8080
|
command: php artisan serve --host=0.0.0.0 --port=8080
|
||||||
networks:
|
networks:
|
||||||
- proxy
|
- proxy
|
||||||
python-listener:
|
python-listener:
|
||||||
build:
|
build:
|
||||||
context: ./htdocs/listenerlist
|
context: ./htdocs/listenerlis
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: python-listener
|
container_name: python-listener
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./htdocs/listenerlist:/app
|
- ./htdocs/listenerlis:/app
|
||||||
depends_on:
|
depends_on:
|
||||||
- laravel-db
|
postgresql:
|
||||||
|
condition: service_healthy
|
||||||
networks:
|
networks:
|
||||||
- proxy
|
- proxy
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ WORKDIR /var/www/html
|
|||||||
# RUN composer create-project laravel/laravel:^10 /var/www/html
|
# RUN composer create-project laravel/laravel:^10 /var/www/html
|
||||||
|
|
||||||
# Set permission
|
# Set permission
|
||||||
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
|
# RUN chown -R www-data:www-data /var/www/html/htdocs/storage /var/www/html/htdocs/bootstrap/cache
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD ["php-fpm"]
|
#CMD ["php-fpm"]
|
||||||
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
|||||||
19
htdocs/entrypoint.sh
Normal file
19
htdocs/entrypoint.sh
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Tunggu database siap
|
||||||
|
until php artisan migrate:status > /dev/null 2>&1; do
|
||||||
|
echo "Waiting for database to be ready..."
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
||||||
|
# Cek apakah migration sudah pernah dijalankan
|
||||||
|
if php artisan migrate:status | grep -q "| Y"; then
|
||||||
|
echo "Database already migrated, skipping migration and seeding."
|
||||||
|
else
|
||||||
|
echo "Running migrations and seeders..."
|
||||||
|
php artisan migrate --force
|
||||||
|
php artisan db:seed --force
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Jalankan Laravel server
|
||||||
|
exec php artisan serve --host=0.0.0.0 --port=8080
|
||||||
@@ -2,10 +2,8 @@ FROM python:3.11-slim
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY app.py .
|
COPY . /app
|
||||||
|
|
||||||
# Jika ada requirements.txt, tambahkan:
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
# COPY requirements.txt .
|
|
||||||
# RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
CMD ["python", "app.py"]
|
CMD ["python", "app.py"]
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ from flask import Flask, request, jsonify
|
|||||||
from sqlalchemy import create_engine, Column, Integer, String, Text, ForeignKey, DateTime
|
from sqlalchemy import create_engine, Column, Integer, String, Text, ForeignKey, DateTime
|
||||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
from sqlalchemy.orm import declarative_base, sessionmaker
|
||||||
import datetime
|
import datetime
|
||||||
|
import time
|
||||||
|
from sqlalchemy.exc import OperationalError
|
||||||
# Konfigurasi logging
|
# Konfigurasi logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename='listener.log',
|
filename='listener.log',
|
||||||
@@ -18,9 +19,21 @@ logging.basicConfig(
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Konfigurasi Database dengan SQLAlchemy
|
# Konfigurasi Database dengan SQLAlchemy
|
||||||
DATABASE_URL = "postgresql://lismikro:lismikro@localhost:5432/lismikro"
|
DATABASE_URL = "postgresql://lismikro:lismikro@postgresql:5432/lismikro"
|
||||||
engine = create_engine(DATABASE_URL)
|
engine = create_engine(DATABASE_URL)
|
||||||
SessionLocal = sessionmaker(bind=engine)
|
SessionLocal = sessionmaker(bind=engine)
|
||||||
|
for i in range(10):
|
||||||
|
try:
|
||||||
|
engine = create_engine(DATABASE_URL)
|
||||||
|
connection = engine.connect()
|
||||||
|
connection.close()
|
||||||
|
print("Database connected successfully.")
|
||||||
|
break
|
||||||
|
except OperationalError as e:
|
||||||
|
print(f"Database not ready yet ({i+1}/10): {e}")
|
||||||
|
time.sleep(5)
|
||||||
|
else:
|
||||||
|
raise Exception("Database not available after 10 attempts")
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
# Model Database
|
# Model Database
|
||||||
|
|||||||
4
htdocs/listenerlis/requirements.txt
Normal file
4
htdocs/listenerlis/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
flask
|
||||||
|
sqlalchemy
|
||||||
|
hl7
|
||||||
|
psycopg2-binary
|
||||||
Reference in New Issue
Block a user