Skip to content

Commit

Permalink
render deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
tedoaba committed Oct 28, 2024
1 parent fd4f85b commit 4d0bc9a
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 22 deletions.
30 changes: 16 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# Use the official Python image as a base image
# Use official Python image
FROM python:3.10

# Set the working directory in the container
# Set environment variables for Flask
ENV PYTHONUNBUFFERED=1

# Set working directory
WORKDIR /app

# Copy the requirements file into the container
# Copy requirements file and install dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt

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

# Copy the entire application into the container
# Copy project files
COPY . .

# Set environment variables
ENV FLASK_APP=app
ENV FLASK_ENV=development
# Install npm and necessary packages (for running Tailwind CSS commands)
RUN apt-get update && apt-get install -y nodejs npm
WORKDIR /app/app # Move to where `package.json` is located
RUN npm install

# Expose the port the app runs on
EXPOSE 5000
# Expose Flask port
EXPOSE 8000

# Command to run the application
CMD ["flask", "run", "--host=0.0.0.0"]
# Command to run on container start
CMD ["flask", "--app", "app", "run", "--host=0.0.0.0", "--port=8000", "--debug"]
28 changes: 28 additions & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pandas
numpy
matplotlib
seaborn
dbt
dbt-postgres
psycopg2
psycopg2-binary
telethon
sqlalchemy
databases
scikit-learn
scipy
python-dotenv
xgboost
mlflow
imblearn
tensorflow
shap
lime
mlflow
flask
click
flask_sqlalchemy
Flask-Migrate
pytest
dbt
dash
34 changes: 26 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
services:
flask:
web:
build: .
container_name: flask_app
command: flask --app app run --host=0.0.0.0 --port=8000 --debug
ports:
- "5000:5000"
- "8000:8000"
environment:
- DATABASE_URL=${DATABASE_URL}
- FLASK_APP=app
- FLASK_SECRET_KEY=${FLASK_SECRET_KEY}
- SQLALCHEMY_DATABASE_URI=postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
- ENVIRONMENT=${ENVIRONMENT}
depends_on:
- db
- css
volumes:
- .:/app

db:
image: postgres:17
restart: always
container_name: postgres_db
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

css:
image: node:14
container_name: css_processor
working_dir: /app/app
volumes:
- .:/app
command: ["npm", "run", "create-css"]

volumes:
postgres_data:
postgres_data:
22 changes: 22 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
- type: web
name: css-builder
env: node
buildCommand: "npm install"
startCommand: "npx tailwindcss -i ./static/src/input.css -o ./static/css/main.css --minify"
plan: free

- type: web
name: init-db
env: python
buildCommand: "pip install -r requirements.txt"
startCommand: "flask --app app init-db"
plan: free
autoDeploy: false

- type: web
name: flask-dash-app
env: python
buildCommand: "pip install -r requirements.txt"
startCommand: "flask --app app run --host 0.0.0.0 --port 8000 --debug"
plan: free

0 comments on commit 4d0bc9a

Please sign in to comment.