This is a basic configuration to start the PostApp application using Docker Compose. It consists of two services: a PostgreSQL database server and a React application.
-
Install Docker Compose on your computer: Docker Compose Installation
-
Navigate to the project directory:
cd postapp-docker-compose
-
Start the application with Docker Compose:
docker-compose up -d
-
Access the React application by opening http://localhost:3000 in your browser.
-
Use the following information for the database connection:
- Host: localhost
- Port: 5439
- Database: postgres
- Username: postgres
- Password: depixen-pass
- Container name: postapp
- A container that includes a PostgreSQL database server.
- Configures POSTGRES_PASSWORD, POSTGRES_DB, and POSTGRES_USER environment variables.
- Port: 5439 (mapped to port 5432 on the local machine)
- Uses a Docker volume to store the database data.
- Container name: react-postapp
- A container that includes the React application.
- Port: 3000
- Depends on the db service, so it won't start until the db service is up.
- depixen-volume: A Docker volume used to store the data of the PostgreSQL database container.
PostApp is a simple RESTful API application that allows users to manage posts. It provides endpoints to retrieve, create, update, and delete posts.
Before running the application, make sure you have the following installed:
- Go programming language
- gorilla/mux package
- jinzhu/gorm package
-
Clone the repository:
-
Change to the project directory:
cd PostApp
-
Install the dependencies:
go mod download
To run the application, execute the following command:
go run main.go
The application will start listening on localhost
at port 8000
by default.
The following API endpoints are available:
GET /api/posts
- Retrieve all postsGET /api/posts/{id}
- Retrieve a specific post by IDPOST /api/posts
- Create a new postDELETE /api/posts/{id}
- Delete a post by IDPATCH /api/posts/{id}
- Update a post by ID
Assuming the application is running on localhost:8000
, you can interact with the API endpoints using tools like cURL or Postman.
To retrieve all posts:
GET http://localhost:8000/api/posts
To retrieve a specific post:
GET http://localhost:8000/api/posts/{id}
To create a new post:
POST http://localhost:8000/api/posts
Request Body:
{
"title": "New Post",
"description": "This is a new post",
"imageuri": "https://example.com/image.jpg"
}
To delete a post:
DELETE http://localhost:8000/api/posts/{id}
To update a post:
PATCH http://localhost:8000/api/posts/{id}
Request Body:
{
"title": "Updated Post",
"description": "This post has been updated",
"imageuri": "https://example.com/new-image.jpg"
}
Contributions to the project are welcome. If you find any issues or want to add new features, please open an issue or submit a pull request.
This project is licensed under the MIT License.