Skip to content

Commit

Permalink
Merge pull request #2 from tooniez/1-feat-add-local-docker-services
Browse files Browse the repository at this point in the history
🚀 [Feat] Initial Setup for Local Development Services
  • Loading branch information
tooniez authored Sep 28, 2024
2 parents 0221683 + 45617e7 commit c5baf37
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

HOST=localhost
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=postgres
POSTGRES_DB_PORT=5432

MONGO_INITDB_ROOT_USERNAME=mongo
MONGO_INITDB_ROOT_PASSWORD=mongo
MONGO_DB_PORT=27017

REDIS_PORT=6379
ELASTICSEARCH_PORT=9200
MINIO_API_PORT=9000
MINIO_CONSOLE_PORT=9001
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin
MAILHOG_SMTP_PORT=1025
MAILHOG_WEB_PORT=8025
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
up:
docker compose --env-file .env.local up --force-recreate -d

up-mongodb:
docker compose --env-file .env.local up mongodb --force-recreate -d

up-postgres:
docker compose --env-file .env.local up postgres --force-recreate

up-redis:
docker compose --env-file .env.local up redis --force-recreate -d

up-elasticsearch:
docker compose --env-file .env.local up elasticsearch --force-recreate -d

up-minio:
docker compose --env-file .env.local up minio --force-recreate -d

up-mailhog:
docker compose --env-file .env.local up mailhog --force-recreate -d

logs:
docker compose --env-file .env.local logs -f
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Local Development Services

This project provides a local development environment with essential services for building and testing modern web applications. It includes a variety of databases, caching solutions, search capabilities, object storage, and email testing tools, all containerized for easy setup.

## Features
- MongoDB for flexible, document-based data storage
- PostgreSQL for robust relational database needs
- Redis for high-performance caching and real-time data processing
- Elasticsearch for powerful full-text search and analytics
- MinIO for S3-compatible object storage
- MailHog for testing email functionality in a sandboxed environment

All services are pre-configured with Docker Compose, allowing developers to quickly spin up a complete development stack with a single command. This setup ensures consistency across different development environments and simplifies the process of onboarding new team members.


## Prerequisites

- Docker
- Docker Compose
- Make (optional, for using Makefile commands)

## Services

This project uses several services, all containerized using Docker:

1. **MongoDB**: NoSQL database
- Default port: 27017

2. **PostgreSQL**: Relational database
- Default port: 5432

3. **Redis**: In-memory data structure store
- Default port: 6379

4. **Elasticsearch**: Search and analytics engine
- Default port: 9200

5. **MinIO**: Object storage
- API port: 9000
- Console port: 9001

6. **MailHog**: Email testing tool
- SMTP port: 1025
- Web interface port: 8025

## Running the Project

To start all services:

```
make up
```

To stop all services:

```
make down
```

To view logs:

```
make logs
```

To access the MinIO console:

```
http://localhost:9001
```

To access the MailHog web interface:

```
http://localhost:8025
```

## Additional Information

For more details on each service, refer to their respective documentation:

- [MongoDB](https://www.mongodb.com/docs)
- [PostgreSQL](https://www.postgresql.org/docs)
- [Redis](https://redis.io/docs)
- [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)
- [MinIO](https://docs.min.io/docs/minio-docker-quickstart-guide.html)
- [MailHog](https://github.com/mailhog/MailHog)

# License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
86 changes: 86 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
services:
mongodb:
image: mongo:latest
container_name: mongodb
restart: always
ports:
- ${MONGO_DB_PORT}:27017
volumes:
- mongodb_data:/data/db
env_file:
- .env.local
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}

postgres:
image: postgres:16.4
container_name: postgres
restart: always
environment:
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_USER=${DB_USER}
- POSTGRES_DB=${DB_NAME}
ports:
- ${POSTGRES_DB_PORT}:5432
volumes:
- postgres_data:/var/lib/postgresql/data
env_file:
- .env.local

redis:
image: redis:7.2-alpine
container_name: redis
restart: always
ports:
- ${REDIS_PORT:-6379}:6379
volumes:
- redis_data:/data
command: redis-server --save 20 1 --loglevel warning

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.1
container_name: elasticsearch
restart: always
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- ${ELASTICSEARCH_PORT:-9200}:9200
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data

minio:
image: minio/minio:RELEASE.2024-03-10T02-53-48Z
container_name: minio
restart: always
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin}
ports:
- ${MINIO_API_PORT:-9000}:9000
- ${MINIO_CONSOLE_PORT:-9001}:9001
volumes:
- minio_data:/data

mailhog:
image: mailhog/mailhog:v1.0.1
container_name: mailhog
restart: always
ports:
- ${MAILHOG_SMTP_PORT:-1025}:1025
- ${MAILHOG_WEB_PORT:-8025}:8025

volumes:
mongodb_data:
driver: local
postgres_data:
driver: local
redis_data:
driver: local
elasticsearch_data:
driver: local
minio_data:
driver: local

0 comments on commit c5baf37

Please sign in to comment.