Skip to content

Commit

Permalink
test docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammed-saalim committed Apr 24, 2024
1 parent ef0e087 commit c3c71bd
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 410 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: main
name: Build Docker Image

on:
push:
Expand All @@ -8,23 +8,15 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Run your Flask application
run: |
export API_KEY=$API_KEY
python app.py
env:
API_KEY: ${{ secrets.APIKEY_OPENAI }}
- name: Build Docker image
run: |
docker build -t your_image_name \
--build-arg OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY }}" .
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use the official Python image as base
FROM python:3.8-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /app

# Copy the dependencies file to the working directory
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code to the working directory
COPY . .

# Expose the port Flask is running on
EXPOSE 5000

# Command to run the application
CMD ["sh", "-c", "python app.py $OPENAI_API_KEY"]
Loading

0 comments on commit c3c71bd

Please sign in to comment.