Skip to content

Commit

Permalink
added nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
abraryaser02 committed May 10, 2024
1 parent 6d19f87 commit 8218f01
Show file tree
Hide file tree
Showing 15 changed files with 3,453 additions and 46 deletions.
Binary file added .DS_Store
Binary file not shown.
57 changes: 57 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: '3.9'

services:
backend:
container_name: backend
build:
context: ./services/backend/
dockerfile: Dockerfile-prod
command: sh -c "while ! nc -z backend-db 5432; do sleep 0.1; done; exec gunicorn --workers 3 --bind 0.0.0.0:8000 wsgi:app"
volumes:
- ./services/backend/:/usr/src/app/
ports:
- 5001:8000 # Map external port 5001 to internal port 8000
environment:
- FLASK_APP=project/__init__.py
- FLASK_ENV=production
- APP_SETTINGS=project.config.ProductionConfig
- DATABASE_URL=postgresql://postgres:postgres@backend-db:5432/backend_prod
depends_on:
- backend-db

backend-db:
image: postgres:13
container_name: backend-db
volumes:
- postgres_volume:/var/lib/postgresql/data
ports:
- 5435:5432 # Map external port 5435 to internal port 5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=backend_prod

my-app:
container_name: my-app
build:
context: ./services/client/my-app/
dockerfile: Dockerfile-prod-2
volumes:
- ./services/client/my-app/build:/usr/share/nginx/html # Mount the build directory for serving static files
depends_on:
- backend

nginx:
container_name: nginx
image: nginx:latest
ports:
- "8000:80" # Expose port 8000 on host for accessing Nginx
volumes:
- ./services/nginx/nginx.conf:/etc/nginx/nginx.conf # Mount the Nginx configuration file
- ./services/client/my-app/build:/usr/share/nginx/html # Mount the build directory for serving static files
depends_on:
- backend
- my-app

volumes:
postgres_volume:
Binary file modified services/.DS_Store
Binary file not shown.
28 changes: 28 additions & 0 deletions services/backend/Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Dockerfile-prod

FROM python:3.9-slim

# Install dependencies
RUN apt-get update \
&& apt-get install -y netcat-openbsd --no-install-recommends \
&& apt-get clean

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Create and set the working directory
WORKDIR /usr/src/app

# Install Python dependencies
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application
COPY . /usr/src/app/

# Expose the port
EXPOSE 8000

# Default command (can be overridden by docker-compose)
CMD ["gunicorn", "--workers", "3", "--bind", "0.0.0.0:8000", "wsgi:app"]
Loading

0 comments on commit 8218f01

Please sign in to comment.