Chatea Conecta is a chat application that allows users to connect and chat with people from around the world.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
To run this project, you need the following tools installed:
- 🐳 Docker: Required to run all services (Redis, MySQL, Django, Celery) using docker-compose.
Alternatively, you can manually install and manage the services below if not using Docker. If not using Docker, make sure to install:
- 🐍 Python 3.9: Required if you plan to run the Django app directly without Docker.
- 🐬 MySQL: Required if running the database outside of Docker.
- 🛠️ Redis: Required if running Redis outside of Docker.
- Clone this repository to your local machine
Open your terminal and run the following commands:
git clone https://github.com/amssdias/chatea-conecta.git
cd chatea-conecta
- Set up environment variables:
Create a .env
file in the project directory to configure environment variables like your Redis password, MySQL credentials, and Django settings. For example:
SECRET_KEY=<secret-key>
ALLOWED_HOSTS=<allowed=hosts>
DB_NAME=<database-name>
DB_HOST=<database-host>
DB_PORT=<database-port>
MYSQL_USER=<mysql-username>
MYSQL_PASSWORD=<mysql-password>
MYSQL_ROOT_PASSWORD=<mysql-root-password>
REDIS_PROTOCOL=<redis-protocol>
REDIS_PORT=<redis-port>
REDIS_PASSWORD=<redis-password>
DJANGO_REDIS_CACHE_DB=<redis-cache-db-index>
REDIS_DB_CHANNEL=<redis-channel-db-index>
REDIS_DB_CELERY=<redis-celery-db-index>
ENVIRON=<development/production>
SENTRY_DNS=<sentry-dns>
- Add redis.conf file (with same password in the
.env
file):
requirepass <your-redis-password>
- 🚀 Run the application with Docker Compose:
docker-compose up --build
The application will be accessible at http://localhost:8000.
Below is the Dockerfile with explanations for each instruction.
# Use the official Python 3.9 image from the Docker Hub
FROM python:3.9
# Set the working directory inside the container to /usr/src/app
WORKDIR /usr/src/app
RUN pip install pipenv
# Copy the Pipfile and Pipfile.lock
COPY Pipfile Pipfile.lock ./
# Install all packages (including development packages) system-wide
RUN pipenv install --dev --system
# Copy the rest of the application code to the working directory
COPY . .
# Expose port 8000 to the host
EXPOSE 8000
# Command to run the Django development server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000", "--settings=chat_connect.settings.settings_development"]
- Install pipenv: Install pipenv using
pip install pipenv
. - Copy Pipfile and Pipfile.lock: Copy Pipfile and Pipfile.lock to the Docker container.
- Install All Packages System-wide:
- Use
pipenv install --dev --system --deploy
to install all packages, including development packages, system-wide (without creating a virtual environment). - The
--system
flag tells pipenv to install the packages globally rather than in a virtual environment. - The
--deploy
flag ensures that the exact versions specified in Pipfile.lock are used, and the build will fail if Pipfile.lock is out of date or missing. As well it avoids install dev dependacies
- Copy Application Code: Copy the rest of your application code to the Docker container.
- Set Environment Variables for Development: Set the necessary environment variables for the development and production environment.
- Expose Port: Expose port 8000 for the application.
- Run Development Server: Use the default Python environment to run Django's development server.
To build the Docker image for the chat application, use the following command:
docker build -t chat-app .
To run the Docker container, use:
docker run -p 8000:8000 --env-file .env chat-app