The API Documentation can be found by accessing the url
http://localhost:6945/docs/index.html
Note: The host and port will change when you set a custom host and port in the build/app.env
file.
- git Installed in your system
- Docker Installed in your system
- golang-migrate/migrate Installed in your system
- ej-agas/psgc-publication-parser Installed in your system
- GNU Make (Optional)
Clone the repository
git clone [email protected]:ej-agas/ph-locations.git && cd ph-locations
Copy .env.example
and docker-compose.yaml.dist
cp build/app.env.example build/app.env
cp build/docker-compose.yaml.dist build/docker-compose.yaml
(Optional) Replace the default password of the PostgreSQL user in the build/app.env
file you've just created.
POSTGRES_PASSWORD=SET_A_SECURE_PASSWORD
Run make docker
make docker
If you don't have GNU make installed in your system, run the following command
docker build -t ph-locations:latest . -f build/Dockerfile.dev && docker compose -f build/docker-compose.yaml up -d --build
Try to access the root path
curl localhost:6945
If you get the JSON below, then everything went well
{
"status": 200,
"message": "Philippine Standard Geographic Code (PSGC) REST API"
}
Enter the ph_locations_db
container by running the command:
docker exec -it ph_locations_db bash
Inside the container, enter the PostgreSQL shell by running the command:
psql --user ph_locations_user --password -d postgres
Note: The shell will prompt for a password, use the POSTGRES_PASSWORD
value in your build/app.env
file
Once inside, execute a CREATE DATABASE
SQL query.
CREATE DATABASE ph_locations_db;
Exit the PostgreSQL shell by running exit and also for the ph_locations_db
container
exit
Run the migrations using golang-migrate/migrate
migrate -source file://migrations -database postgresql://ph_locations_user:YOUR_DATABASE_PASSWORD@localhost:5432/ph_locations_db?sslmode=disable up
Note: Change the YOUR_DATABASE_PASSWORD
string in the command to the POSTGRES_PASSWORD
value in your build/app.env
file.
Run the PSGC publication parser
psgc-pub-parser parse publication_datafile.xlsx --host localhost --port 5432 --db ph_locations_db --user ph_locations_user --password YOUR_DATABASE_PASSWORD
Note: Change the YOUR_DATABASE_PASSWORD
flag value in the command to the POSTGRES_PASSWORD
value in your build/app.env
file.