Skip to content

Commit

Permalink
dockerise (#182)
Browse files Browse the repository at this point in the history
* dockerise

* Update docker-compose.yaml

* Create Dockerfile
  • Loading branch information
aryanbhosale authored Aug 15, 2024
1 parent e430ed5 commit 5f2f64c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Use an official Python runtime as a parent image
FROM python:3.11-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements.txt file
COPY requirements.txt .

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy the entire project directory (including quartz_solar_forecast)
COPY . /app

# Install the quartz_solar_forecast package in editable mode
RUN pip install -e .

# Expose port 8000 to the outside world
EXPOSE 8000

# Run the application using python main.py
CMD ["python", "api/main.py"]
2 changes: 1 addition & 1 deletion api/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uvicorn

if __name__ == "__main__":
uvicorn.run("app.api:app", host="localhost", port=8000, reload=True)
uvicorn.run("app.api:app", host="0.0.0.0", port=8000, reload=True)
21 changes: 18 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

x-shared_environment: &shared_environment
LOG_LEVEL: ${LOG_LEVEL:-info}

Expand All @@ -15,6 +13,7 @@ services:
restart: always
environment:
<<: *shared_environment

open-meteo-sync:
image: ghcr.io/open-meteo/open-meteo
container_name: open-meteo-sync
Expand All @@ -25,5 +24,21 @@ services:
environment:
<<: *shared_environment

web:
build:
context: .
dockerfile: Dockerfile
container_name: fastapi-app
ports:
- "8000:8000"
env_file:
- .env
volumes:
- .:/app
depends_on:
- open-meteo-api
- open-meteo-sync
restart: always

volumes:
data:
data:

0 comments on commit 5f2f64c

Please sign in to comment.