{"id":19055755,"url":"https://github.com/fatimajamali81/docker-nginx-postgres","last_synced_at":"2026-04-30T20:31:23.689Z","repository":{"id":249812589,"uuid":"832631940","full_name":"fatimajamali81/docker-nginx-postgres","owner":"fatimajamali81","description":"This project demonstrates a multi-container application using Docker Compose, including a web application served by Nginx and a PostgreSQL database","archived":false,"fork":false,"pushed_at":"2024-07-23T12:40:18.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-11T20:20:28.741Z","etag":null,"topics":["docker","docker-compose","multi-container","nginx","nginx-docker","nginx-server","postgresql-database"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fatimajamali81.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-23T12:10:38.000Z","updated_at":"2024-07-23T12:40:34.000Z","dependencies_parsed_at":"2024-07-23T14:15:07.242Z","dependency_job_id":"39353ad8-c5e2-46fb-a9eb-6ba07ecc1eca","html_url":"https://github.com/fatimajamali81/docker-nginx-postgres","commit_stats":null,"previous_names":["fatimajamali81/docker-nginx-postgres"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fatimajamali81/docker-nginx-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatimajamali81%2Fdocker-nginx-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatimajamali81%2Fdocker-nginx-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatimajamali81%2Fdocker-nginx-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatimajamali81%2Fdocker-nginx-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fatimajamali81","download_url":"https://codeload.github.com/fatimajamali81/docker-nginx-postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatimajamali81%2Fdocker-nginx-postgres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32476682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","multi-container","nginx","nginx-docker","nginx-server","postgresql-database"],"created_at":"2024-11-08T23:46:53.139Z","updated_at":"2026-04-30T20:31:23.674Z","avatar_url":"https://github.com/fatimajamali81.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-Container Docker Compose, nginx \u0026 postgres Project\n\nThis project demonstrates a multi-container application using Docker Compose, including a web application served by Nginx and a PostgreSQL database. The application, running in a Python Flask container, interacts with the PostgreSQL database. Nginx serves as a reverse proxy to the Flask application.\n\n## Prerequisites\n\n- Docker\n- Docker Compose\n\n## Setup\n\n1. Clone the repository:\n   ```sh\n   git clone \u003crepository_url\u003e\n   cd my_docker_compose_project\n   ```\nBuild and run the containers:\n\n```sh\ndocker-compose up --build\n```\nAccess the web application at `http://localhost`.\n\n\n## Purpose and Actions of Each File\n\n### 1. `docker-compose.yml`\n\nDefines the multi-container setup:\n\n- **web**: \n  - Builds the application container from the `app` directory.\n  - Sets the `DATABASE_URL` environment variable.\n  - Maps port `5000` on the host to port `5000` in the container.\n\n- **nginx**: \n  - Builds the Nginx container from the `nginx` directory.\n  - Maps port `80` on the host to port `80` in the container.\n  - Forwards requests to the `web` service on port `5000`.\n\n- **db**: \n  - Builds the PostgreSQL container from the `postgres` directory.\n  - Sets environment variables for PostgreSQL (`POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB`).\n  - Maps port `5432` on the host to port `5432` in the container.\n\n### 2. `nginx/Dockerfile`\n\nBuilds the Nginx image:\n\n- Uses the official Nginx image.\n- Copies the Nginx configuration file and static HTML files into the container.\n\n### 3. `nginx/default.conf`\n\nConfigures Nginx to proxy requests to the Flask application:\n\n- Forwards requests from port `80` to the `web` service on port `5000`.\n\n### 4. `nginx/html/index.html`\n\nA simple static HTML page served by Nginx:\n\n- Displays a welcome message indicating that the application is connected to a PostgreSQL database.\n\n### 5. `app/Dockerfile`\n\nBuilds the Flask application container:\n\n- Uses the Python 3.9 slim image.\n- Installs dependencies from `requirements.txt`.\n- Runs the Flask application.\n\n### 6. `app/requirements.txt`\n\nLists the Python packages needed for the application:\n\n- `flask` for the web framework.\n- `psycopg2-binary` for PostgreSQL database connectivity.\n\n### 7. `app/app.py`\n\nA simple Flask application:\n\n- Connects to PostgreSQL using `psycopg2`.\n- Exposes an endpoint that retrieves and returns data from the `users` table in PostgreSQL.\n\n### 8. `postgres/Dockerfile`\n\nBuilds the PostgreSQL image:\n\n- Uses the official PostgreSQL image.\n- Copies the initialization SQL script into the container.\n\n### 9. `postgres/init.sql`\n\nInitial SQL script for PostgreSQL:\n\n- Creates a `users` table.\n- Inserts sample data into the table.\n\n\n### Conclusion\n\nThis project provides a practical example of using Docker Compose to set up a multi-container application with Nginx, a Flask application, and PostgreSQL. It demonstrates how to configure and connect these components in a development environment.\n\n\n### Summary\n\n- **Nginx**: Serves as the reverse proxy for the Flask application.\n- **Flask App**: Connects to the PostgreSQL database and provides an endpoint to retrieve data.\n- **PostgreSQL**: Stores data and is initialized with a sample dataset.\n\n### License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatimajamali81%2Fdocker-nginx-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffatimajamali81%2Fdocker-nginx-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatimajamali81%2Fdocker-nginx-postgres/lists"}