1- # Use a lightweight Python image
2- FROM python:slim
1+ # Use an official Python runtime as a parent image
2+ FROM python:3.9- slim
33
44# Set environment variables to prevent Python from writing .pyc files & Ensure Python output is not buffered
55ENV PYTHONDONTWRITEBYTECODE=1 \
@@ -8,26 +8,34 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
88# Set the working directory
99WORKDIR /app
1010
11- # Install system dependencies required by LightGBM
12- RUN apt-get update && apt-get install -y --no-install-recommends \
13- libgomp1 \
14- && apt-get clean \
15- && rm -rf /var/lib/apt/lists/*
11+ # Copy the current directory contents into the container
12+ COPY . /app
1613
17- # Copy the application code
18- COPY . .
14+ # Add the required library for LightGBM
15+ RUN apt-get update && apt-get install -y libgomp1 && rm -rf /var/lib/apt/lists/*
1916
20- # Install the package in editable mode
21- RUN pip install --no-cache-dir -e .
22-
23- # Train the model before running the application
24- RUN python pipeline/training_pipeline.py
17+ # Install any needed packages specified in requirements.txt
18+ RUN pip install --no-cache-dir -r requirements.txt
2519
2620# Expose the port that Flask will run on
2721EXPOSE 5000
2822
2923# Command to run the app
3024CMD ["python" , "application.py" ]
3125
26+ from flask import Flask
27+
28+ app = Flask(__name__)
29+
30+ @app.route('/' )
31+ def home():
32+ return "Hello, AWS Lambda!"
33+
34+ from application import app
35+
36+ def handler(event, context):
37+ from serverless_wsgi import handle_request
38+ return handle_request(app, event, context)
39+
3240
3341
0 commit comments