This project sets up a PostgreSQL database using Docker and Docker Compose. It includes a Makefile
for managing the Docker setup, a docker-compose.yml
file for defining the services, a Dockerfile
for building the PostgreSQL image, and an example .env
file for environment variables.
- Docker 🐳
- Docker Compose 🛠️
-
Clone the repository:
git clone [email protected]:PepeCodeHub/PostgreSQL-docker.git cd PostgreSQL-docker
-
Copy the
.env.example
file to.env
and fill in the required environment variables:cp .env.example .env
make build
: Build the Docker image and run the containers. 🚀make up
: Start the containers without rebuilding. 🔄make down
: Stop and remove the containers. 🛑make logs
: View logs from the containers. 📜make ps
: Show running containers. 📋make clean
: Clean up unused Docker resources. 🧹make publish
: Tag and push the Docker image to Docker Hub. 📤make help
: Display available commands. ❓
The docker-compose.yml
file defines a single service:
db
: The PostgreSQL database service. 🗄️
The Dockerfile
is based on the postgres:alpine
image and sets up the PostgreSQL database. 🐘
The .env
file should contain the following variables:
POSTGRES_USER
: The PostgreSQL user. 👤POSTGRES_PASSWORD
: The PostgreSQL password. 🔑POSTGRES_DB
: The PostgreSQL database name. 🗃️DOCKER_USERNAME
: Your Docker Hub username. 🧑💻IMAGE_NAME
: The name of the Docker image. 🏷️TAG
: The tag for the Docker image. 🏷️
-
Build and start the containers:
make build
-
Start the containers without rebuilding:
make up
-
Stop and remove the containers:
make down
-
View logs from the containers:
make logs
-
Show running containers:
make ps
-
Clean up unused Docker resources:
make clean
-
Tag and push the Docker image to Docker Hub:
make publish
-
Display available commands:
make help
The Docker image is available on Docker Hub: f3an/postgresql-docker-db
The Docker image is available on GitHub: f3an/postgresql-docker-db
PostgreSQL DB in Docker 🐘