Skip to content

Commit eea9da0

Browse files
API and webapp Dockerfile (#5)
* [wip] first test dockerfile w/ supervisord using GitHub Actions * [fix] uv run
1 parent f85e553 commit eea9da0

File tree

5 files changed

+129
-0
lines changed

5 files changed

+129
-0
lines changed

.github/workflows/build-image.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Image Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dockerfile
8+
tags:
9+
- "*"
10+
workflow_dispatch:
11+
12+
jobs:
13+
image-build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v5
24+
with:
25+
images: meilametayebjee/codification-ape-graph-rag-api
26+
tags: |
27+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
28+
type=ref,event=branch
29+
type=ref,event=tag
30+
31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Login to DockerHub
38+
uses: docker/login-action@v3
39+
with:
40+
username: ${{ secrets.DOCKERHUB_USERNAME }}
41+
password: ${{ secrets.DOCKERHUB_TOKEN }}
42+
43+
- name: Build and push
44+
id: docker_build
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
build-args: |
52+
API_USERNAME=${{ secrets.API_USERNAME }}
53+
API_PASSWORD=${{ secrets.API_PASSWORD }}
54+
55+
- name: Image digest
56+
run: echo ${{ steps.docker_build.outputs.digest }}

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Use an official lightweight Python image
2+
FROM python:3.11-slim
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Install system dependencies
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
build-essential \
10+
curl \
11+
git \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Install uv (if needed)
15+
COPY uv.lock pyproject.toml ./
16+
# Install uv package manager
17+
RUN pip install uv
18+
19+
# Sync dependencies
20+
RUN uv sync
21+
22+
# Copy the rest of the code
23+
COPY . .
24+
25+
# Copy supervisord config
26+
COPY supervisord.conf /etc/supervisord.conf
27+
28+
# Expose ports: 8501 for Streamlit, 5000 for FastAPI
29+
EXPOSE 8501 5000
30+
31+
CMD ["/usr/local/bin/supervisord", "-c", "/etc/supervisord.conf"]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616
"fastapi>=0.115.12",
1717
"streamlit>=1.44.0",
1818
"langchain-openai>=0.3.11",
19+
"supervisor>=4.2.5",
1920
]
2021
authors = [
2122
{name="Thomas Faria", email="[email protected]"}

supervisord.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:streamlit]
5+
command=uv run streamlit run app/main.py
6+
directory=/app
7+
autostart=true
8+
autorestart=true
9+
stdout_logfile=/dev/stdout
10+
stderr_logfile=/dev/stderr
11+
12+
[program:fastapi]
13+
command=uv run uvicorn src.api.main:app --host 0.0.0.0 --port 5000
14+
directory=/app
15+
autostart=true
16+
autorestart=true
17+
stdout_logfile=/dev/stdout
18+
stderr_logfile=/dev/stderr

uv.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)