[5 Mins Docker] Create Your Own Image Hosting Site Using GitHub Project Picsur
There are many free image hosting sites which you can upload your images then get URL to use it in your website or blog posts or social media sites. But there is a problem with those free sites, you will not have your own control for your data since that is free hosting. To make sure we got full control of our data, we will have to create our own self-hosting image hosting site. It has to be free and easy to set up.
Github project Picsur meets all those requirements and this post will give you a quick guide how you can create your self hosted images bed.
Github Project Link: https://github.com/caramelfur/picsur
Project Features and Screenshots
- Uploading and viewing images
- Anonymous uploads
- User accounts
- User roles and permissions
- Proper CORS restrictions
- Exif stripping
- Ability to keep original
- Support for many formats
- QOI
- JPG
- PNG
- WEBP (animated supported)
- TIFF
- BMP
- GIF (animated supported)
- Convert images
-
Edit images
Resize
- Rotate
- Flip
- Strip transparency
- Negative
- Greyscale
- Deletable images
- Proper DB migrations
- Show own images in list
- Correct previews on chats
- Expiring images
- ShareX endpoint
- ARM64 and AMD64 Docker image
Installation Pre-requirements
Free resources you will need to build this docker project:
- Server: Oracle Free VPS, Azure Free VPS, Google Cloud Free VPS, and others
- Create a Free Tier Windows/Linux Azure VPS VM
- [Free VPS] GCP (Google Cloud Platform) Tips and Tricks (Free 16G RAM, 4 vCPU VPS)
- System: Cloud Vendor Ubuntu, Debian, or DD an original version
- SWAP size increase: wget https://raw.githubusercontent.com/51sec/swap/main/swap.sh && bash swap.sh
- Enable Password ssh login
- Enable BBR
- systemctl restart docker
- Domain: (Optional) EU.ORG to get a free one
- Confirm port has not been used (you might need to install lsof using command : apt install lsof):
- lsof -i:8080
Pre-installed services:
- Docker,
- apt update
- apt install docker.io
- apt install docker-compose
- apt upgrade docker.io
- mkdir /root/data/docker_data/<docker_name>
- Docker-Compose (Using Ubuntu OS for the commands)
- Docker-compose down
- Optional command : use following command to backup your Docker data. You might need to change your folder name based on your docker configuraiton
- cp -r /root/data/docker_data/<docker_name> /root/data/docker_data_backup/<docker_name>
- docker-compose pull
- docker-compose up -d
- docker image prune
- Portainer (Optional)
- docker volume create portainer_data
- docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
- aapanel with Nginx (Optional)
- Nginx Proxy Manager (Optional)
Clean Up / Remove Docker
- Delete Docker and related resources
- cd /root/data/docker_data/<docker_name>
- docker-compose down
- cd ..
- rm -rf /root/data/docker_data/<docker_name>
Installation Steps
1 Log into your VPS and start to install required softwares
apt update && apt install docker.io -y && apt install docker-compose -y
2 Create a data folder
sudo -i mkdir -p /root/data/docker_data/picsur cd /root/data/docker_data/picsur
3 Create Docker Composer File
vi docker-compose.yml
Here is the content of this file:
version: '3'
services:
picsur:
image: ghcr.io/caramelfur/picsur:latest
container_name: picsur
ports:
- '8088:8080' #8088 can be changed to other unused tcp port
environment:
PICSUR_HOST: '0.0.0.0'
PICSUR_PORT: 8080
PICSUR_DB_HOST: picsur_postgres
PICSUR_DB_PORT: 5432
PICSUR_DB_USERNAME: picsur
PICSUR_DB_PASSWORD: Secure_DB_passw0rd # This has be same one as configured in the settings of picsur_postgres
PICSUR_DB_DATABASE: picsur
## Default admin username's password
PICSUR_ADMIN_PASSWORD: Secure_admin_passw0rd
## optional. If not set here, it will be generated randomly.
# PICSUR_JWT_SECRET: CHANGE_ME
# PICSUR_JWT_EXPIRY: 7d
## Maximum File zie
PICSUR_MAX_FILE_SIZE: 10240000 # 10 MB
## No need to touch this, unless you use a custom frontend
# PICSUR_STATIC_FRONTEND_ROOT: "/picsur/frontend/dist"
## Warning: Verbose mode might log sensitive data
# PICSUR_VERBOSE: "true"
restart: unless-stopped
picsur_postgres:
image: postgres:14-alpine
container_name: picsur_postgres
environment:
POSTGRES_DB: picsur
POSTGRES_PASSWORD: Secure_DB_passw0rd
POSTGRES_USER: picsur
restart: unless-stopped
volumes:
- ./picsur-data:/var/lib/postgresql/data
4 Open Firewall Port
Here is an example using Oracle cloud:
5 Test using public ip address
Get your VPSs's public IP
Curl ifconfig.me
Access your Picsur website: http://<Public IP>:8088
NPM - Setting Up Nginx Reverse Proxy Manager
Update / Backup Picsur
Following commands show how to backup and update docker:
cd /root/data/docker_data/picsur docker-compose down cp -r /root/data/docker_data/picsur /root/data/docker_data/picsur.archive # backup docker-compose pull docker-compose up -d # no need to use "docker-compose stop" to stop docker. "docker-compose up -d" will stop and auto update new docker. docker image prune # prune command is used to remove all unused images
Remove Docker
cd /root/data/docker_data/picsur docker-compose down cd .. rm -rf /root/data/docker_data/picsur
Videos
References
- 【好玩儿的 Docker 项目】10 分钟搭建一个内置图片转换功能的图床 ——Picsur
- How to Install Picsur on Your Synology NAS
- https://www.youtube.com/watch?v=mJXlAry2TuY
共有 0 条评论