This is a microservice that uses a Docker container to run a Python Flask server that generates mockups using the GIMP CLI.
- Docker installed on your local machine
- Set the environment variables in a
.env
file. A template.env
file is provided in.env.template
. - Build the Docker container
sudo docker build -t mockupforge-ms .
. - Run the container
sudo docker run -p 5000:8080 mockupforge-ms
.
To deploy the microservice to a cloud platform:
- Build the Docker image and push it to a container registry.
- Deploy the container to your chosen cloud platform (e.g., AWS ECS, Google Cloud Run, Kubernetes).
- Set the necessary environment variables and configurations.
- Expose the appropriate port and configure any required networking settings.
- Monitor and scale the service as needed.
The Flask server will be accessible at http://localhost:5000
.
All API endpoints require authentication. Include your API key in the Authorization header of your requests:
Authorization: Bearer YOUR_API_KEY_HERE
Headers:
Authorization: Bearer YOUR_API_KEY_HERE
Response:
{
"status": "ok",
"message": "success",
"data": {
"mockups": {
"mockup_type_1": {
"dimensions": ["max_width", "max_height"]
},
"mockup_type_2": {
"dimensions": ["max_width", "max_height"]
}
}
}
}
It is highly recommended to query this endpoint before generating mockups since it contains the available mockup types where are passed into POST /v1/mockup
in the request body as type
and it also includes the maximum dimensions of the image. It is important to note these since the image will always be rescaled by the mockup generator to fit these dimensions. It is recommended to include blank space in the desired design to fit these dimensions to avoid image transformation.
Headers:
Authorization: Bearer YOUR_API_KEY_HERE
Content-Type: application/json
Request Body:
{
"type": "mockup_type", // string, must be in mockups
"image": "image_url", // string
"color": ["r", "g", "b"] // float[], length=3
}
Response:
Will return a response with type of image/png, which is the generated mockup.
Here's a step-by-step guide to create a mockup using Mockup Forge:
-
Clone the repository:
git clone https://github.com/munozarturo/mockupforge
-
Start the Docker daemon:
systemctl start docker
-
Define
API_KEY
in the.env
file (you can choose your own):API_KEY="api-key"
-
Build and run the Docker image:
docker build -t mockupforge-ms . docker run -p 5000:8080 mockupforge-ms
-
Get the available mockups:
curl -X GET "127.0.0.1:5000/v1/mockup" \ -H "Authorization: Bearer api-key"
You should receive a response like this:
{ "message": "success", "status": "ok", "data": { "mockups": { "hoodie": { "dimensions": [525, 525] }, "sweater": { "dimensions": [697, 677] }, "tshirt": { "dimensions": [676, 865] } } } }
-
Make a mockup request:
curl -X POST "127.0.0.1:5000/v1/mockup" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer api-key" \ -d '{ "type": "hoodie", "image": "http://munozarturo.com/assets/mockupforge/mockup-design-mf.png", "color": [30, 30, 30] }' \ -o "mockup-mf.png"
This will generate a
mockup-mf.png
file with your mockup: