Skip to content

Commit a83ea73

Browse files
committed
docker container deployed on local host
1 parent e5a1c37 commit a83ea73

2 files changed

Lines changed: 49 additions & 14 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Docker Build and Push
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Log in to Docker Hub
17+
uses: docker/login-action@v2
18+
with:
19+
username: ${{ secrets.DOCKER_USERNAME }}
20+
password: ${{ secrets.DOCKER_PASSWORD }}
21+
22+
- name: Build and push Docker image
23+
uses: docker/build-push-action@v4
24+
with:
25+
context: .
26+
push: true
27+
tags: ${{ secrets.DOCKER_USERNAME }}/mlops1_hotel:latest

Dockerfile

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
55
ENV PYTHONDONTWRITEBYTECODE=1 \
@@ -8,26 +8,34 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
88
# Set the working directory
99
WORKDIR /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
2721
EXPOSE 5000
2822

2923
# Command to run the app
3024
CMD ["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

Comments
 (0)