Skip to content

Commit

Permalink
Dockerization added
Browse files Browse the repository at this point in the history
  • Loading branch information
tedoaba committed Oct 23, 2024
1 parent 8dcaf5d commit 716a0d6
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__
.git
.venv
.week89
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Use official Python image as the base image
FROM python:3.10

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set the working directory
WORKDIR /app

# Copy and install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
curl \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js and npm for TailwindCSS
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Copy project dependencies first to improve caching
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt

# Copy Node dependencies and install them
COPY app/package.json .
RUN npm install

# Copy the rest of the project files
COPY app/. .

# Build CSS with Tailwind
RUN npm run create-css

# Expose port 5000 for the Flask app
EXPOSE 5000

# Run the Flask app
CMD ["flask", "run", "--host=0.0.0.0"]
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.8' # Updated version for better features

services:
app:
build: .
container_name: flask_app
command: flask run --host=0.0.0.0
ports:
- "5000:5000"
environment:
FLASK_ENV: development
DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
volumes:
- .:/app # This allows for live code updates; consider changing for production
depends_on:
- db
restart: unless-stopped # Automatically restart unless stopped manually

db:
image: postgres:13
container_name: postgres_db
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- pgdata:/var/lib/postgresql/data
restart: unless-stopped # Automatically restart unless stopped manually

volumes:
pgdata:

0 comments on commit 716a0d6

Please sign in to comment.