Image and video proxy for my pet-projects
Pepic is a small self-hosted media proxy that helps me to upload, store, serve and convert pictures and videos on my own servers.
Currently, I use it as a main storage for media files in my pet-projects and on my blog.
Pepic can upload and optimize media files in-flight to save you money and bandwidth. It's highly recommended to set ip up in combination with Cloudflare CDN for better caching.
Internally it uses ffmpeg for videos and vips for images, which makes it quite fast and supports many media file formats.
Images: JPG, PNG, GIF, WEBP, SVG, HEIF, TIFF, AVIF, etc
Video: basically everything ffmpeg supports
Pepic is open source, however it's not meant to be used by anyone. Only if you're brave (like me). Scroll down this README for better alternatives.
ffmpeg and vips for video and image processing to ensure high performance and fast processing times.vips and ffmpeg first, as they are two main external dependenciesbrew install vips ffmpeggit clone [email protected]:vas3k/pepic.git
cd pepicgo run main.go serve --config ./etc/pepic/config.yml⚠️ If you're getting
invalid flag in pkg-configerror, runbrew install pkg-configandexport CGO_CFLAGS_ALLOW="-Xpreprocessor". Then trygo runagain.
You can find docker-compose.example.yml in this repo and adapt it to your own needs.
Get Docker and Docker Compose
Download the Docker Compose example file and save it as docker-compose.yml on your local machine
curl https://raw.githubusercontent.com/vas3k/pepic/master/docker-compose.example.yml -o docker-compose.ymldocker-compose up./uploads) after that.…If your image URL looks like this: https://imgs.com/file.jpg
Add /500/ to its URL to get 500px (on the long side) version: https://imgs.com/500/file.jpg
Works only if live_resize option is set to true. If live_resize=false — it returns the original version. Same for video transcoding (where it's off by default).
⚠️ Note: Each resized version is saved as a separate file (with the same hash). When the same version of the file is requested again, Pepic just read it from disk and does not waste CPU time resizing it again. However, if you have many resized versions stored, this can eat quite a bit of disk space. Be careful.
// Not implemented yet, sorry... PRs are welcome
Because GIFs are terrible, Pepic automatically converts them to mp4 videos by default. You can change it to any other format you like using gif_convert setting in config.yml.
You can disable this behavior only if you set the store_originals=true flag, then GIF files will be saved "as is".
⚠️ If you plan to host anything bigger than a blog, always put Pepic behind a CDN. CloudFlare offers a free one if you don't hate big corporations :D
Let's say, you want to host it on https://media.mydomain.org
etc/pepic/config.yml to your tasteglobal:
host: 0.0.0.0
port: 8118 # internal host and port, leave it as it is
base_url: "https://media.mydomain.org"
secret_code: "secretpass"
max_upload_size: "500M"Don't forget to mount upload volume to store files on host (or you can lose those files when the container is killed).
docker run -p 8118:8118 -v /host/dir/uploads:/app/uploads --restart=unless-stopped $(docker build -q .)If you prefer docker-compose, you can use it too. Check out the included docker-compose.example.yml. You can easily transform it into your favourite k8s config or whatever is fashionable this summer.
Don't forget to periodically backup the
/host/dir/uploadsdirectory just in case :)
Just proxy all calls from the domain (media.mydomain.org) to Pepic backend (0.0.0.0:8118). Don't forget to set max file size and proxy timeot directives to avoid gateway errors on big files (especially videos).
Here's an example for nginx:
…Contributions are welcome.
Open an Issue if you want to report a bug or propose an idea.
After reading all this, you probably realized how bad it is and looking for other alternatives. Here's my recommendations:
It's MIT.
Contact me if you have any questions — [email protected].
❤️
No open issues yet, or sync has not completed.