- Make:
- macOS:
$ xcode-select --install
- Linux: https://www.gnu.org
- Windows:
$ choco install make
https://chocolatey.org
- macOS:
- Python:
$ asdf install
(https://asdf-vm.com)[https://asdf-vm.com/guide/getting-started.html] - Poetry: https://python-poetry.org
To confirm these system dependencies are configured correctly:
$ make bootstrap
$ make doctor
Install project dependencies into a virtual environment:
$ make install
To start the API server and static site:
$ make run
View all example images: http://localhost:5000/examples
View test images with automatic reload: http://localhost:5000/test
To view a specific image with automatic reload, simply drop the file extension.
- Visit http://localhost:5000/<my_new_template_id>
- Add a
default.png
(or JPG) background image intemplates/<my_new_template_id>
directory - Update
config.yml
in thetemplates/<my_new_template_id>
directory - Refresh http://localhost:5000/images/<my_new_template_id> to see the example
- Adjust
config.yml
as necessary to position and style the text - Visit http://localhost:5000/templates to validate all templates
Run the tests:
$ make test
Run static analysis:
$ make check
Keep all of the above tasks running on change:
$ make dev
This service is built to run on Heroku. Route traffic through a CDN to cache generated images.
You can also build this service as a container simply by running either of the following commands:
# Using Docker:
docker build --tag memegen --file Containerfile .
# Using Podman:
podman build --tag memegen --file Containerfile .
You can then run the container by running:
# Run the container
docker run --publish 5000:5000 --env DOMAIN="set.your.domain" memegen
# Validate functionality
$ curl http://127.0.0.1:5000/docs/ -sI
HTTP/1.1 200 OK
date: Sun, 24 Oct 2021 19:16:07 GMT
server: uvicorn
last-modified: Sun, 24 Oct 2021 18:27:30 GMT
content-type: text/html; charset=utf-8
access-control-allow-origin: *
If you want to build the image for multiple CPU architectures, you can either use buildah
or docker buildx
. Below are examples for both, and assume you're in the root of the repository:
On Debian/Ubuntu, you'll need to run:
sudo apt install --yes podman buildah qemu-user-static
On any RHEL flavor OS, you'll need to run:
sudo yum install --yes podman buildah qemu-user-static
On Arch or Manjaro Linux, you'll need to run:
sudo pacman -Sy podman buildah qemu-arch-extra
This assumes you have docker buildx already installed!
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag "ghcr.io/${GITHUB_USERNAME}/memegen:latest" \
--push .
# Create a multi-architecture manifest
buildah manifest create memegen
# Build your amd64 architecture container
buildah bud \
--tag "ghcr.io/${GITHUB_USERNAME}/memegen:latest" \
--manifest memegen \
--arch amd64 .
# Build your arm64 architecture container
buildah bud \
--tag "ghcr.io/${GITHUB_USERNAME}/memegen:latest" \
--manifest memegen \
--arch arm64 .
# Enter your GitHub Personal Access Token below
read -s GITHUB_PERSONAL_ACCESS_TOKEN
# Log into your GitHub Container Registry
echo "${GITHUB_PERSONAL_ACCESS_TOKEN}" | buildah login --username danmanners --password-stdin ghcr.io
# Push the full manifest, with both CPU Architectures
buildah manifest push --all memegen \
"docker://ghcr.io/${GITHUB_USERNAME}/memegen:latest"
Please note that building the
--arch arm
build on anamd64
(Intel/AMD) system can take nearly an hour.