This service provides an API for image processing, converting images to the WebP format, and caching them for efficient retrieval.
- Go 1.18 or higher
- Docker and Docker Compose (for containerization and local testing)
- An understanding of Go modules and HTTP server handling
-
Clone the Repository:
git clone [repository URL] cd my-image-service
-
Install Dependencies:
The project uses Go modules for dependency management.
go mod tidy
-
Environment Variables:
Set the necessary environment variables (e.g.,
API_SECRET
). You can do this by exporting them in your shell or by setting them in a.env
file at the root of the project. -
Running the Application Locally:
To run the service locally:
go run ./cmd/server/main.go
This will start the server on
localhost:8080
(or another port, if configured).
-
Building a Binary:
Compile the application into a binary:
go build -o image-service ./cmd/server
-
Building a Docker Image:
Use the provided
Dockerfile
to build a Docker image:docker build -t image-service .
-
Using Docker Compose:
Alternatively, use Docker Compose to build and run the service:
docker-compose up --build
After starting the service, you can interact with it via HTTP requests:
-
Convert an Image to WebP:
Send a request to the service with the image URL:
curl http://localhost:8080/path/to/image
The server will return the WebP converted image.
-
Health Check:
To check the health of the service:
curl http://localhost:8080/health
- Configuration: See
configs/config.yaml
for configuration options. - Logging: The service uses
logrus
for logging. Logs are output in JSON format. - Caching: Cached images are stored temporarily as defined in the configuration.
Contributions to this project are welcome. Please adhere to the project's coding standards and submit pull requests for any new features or bug fixes.
[Specify the license here]
For more information, please refer to the in-depth documentation in the /docs
directory.