This project requires docker and a pre-existing psql database.
- Clone the repository and navigate to the project directory
git clone https://github.com/Lord-Kelsier/backend-super-tic-tac-toe.git
cd backend-super-tic-tac-toe
- Create a
.env
file in the project root directory and add the following environment variables
DB_NAME=<Your DB name>
DB_PASSWORD=<Your DB ultra secret password>
DB_USER=<Your DB user>
DB_HOST=<Your DB host>
DB_PORT=<Your DB port>
SECRET=<Your secret>
- Compose the project
docker compose up -d
And that's it! The project should be running on http://localhost:5318/api-docs/. In case you dont have a database, before running the project, you follow the next steps to create a database:
- Create a new docker network
docker network create backend-network
- Create a new directory to store the database data
mkdir database
cd database
- Crea un archivo
docker-compose.yml
en el directorio y agrega el siguiente contenido
version: '3.9'
services:
db:
container_name: psqldb
image: postgres:14-alpine
ports:
- '5433:5432'
volumes:
- ./data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=MyAwesomePassword
networks:
- db
networks:
db:
name: backend-network
external: true
- Compose the project
docker compose -f docker-compose.yml up -d
- Create the database
docker exec -it psqldb bash
psql -U postgres
CREATE DATABASE super_tic_tac_toe;
Now you can run the project with the first steps.
Remember to change the database credentials in the .env
file, in this case the values are:
DB_NAME=super_tic_tac_toe
DB_PASSWORD=MyAwesomePassword
DB_USER=postgres # This is the default user
DB_HOST=psqldb # This is the name of the container
DB_PORT=5432 # This is the port of the container
Also, in this case you should change 3rd step of the proyect installation to:
docker compose -f docker-compose-dev.yml up -d
En caso de que salga el error de que el archivo /App/entrypoint.sh no se encuentra. Debes asegurarte que la secuencia de final de linea del archivo corresponde e LF en vez de CRLF