Create Image Server on Linux Ubuntu 23.04
Here I am using Vultr Cloud Compute with the cheapest option that has 25GB Storage. Credits to this tutorial I found in the fivem forum
Creating Sudo User​
If we are using the root user, first we can create a sudo user so we don't use the root user. I will be following this tutorial.
adduser admin
Follow the prompts, the user information is optional. Next use this command
usermod -aG sudo admin
This will give sudo permission for the admin
user. Then we can exit root user and login into the new user account.
Installing Docker​
This one will be according to docker official documentation on ubuntu installation. First we should remove any possible conflicts while installing.
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Then run these accordingly
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Install
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
You now have downloaded & installed the docker successfully
Running the image server​
Run this command
sudo docker run -d --restart always -e MAX_UPLOADS_PER_MINUTE="250" -e MAX_UPLOADS_PER_HOUR="1000" -e MAX_UPLOADS_PER_DAY="5000" -v /home/admin/screenshots:/images -p 5000:5000 hauxir/imgpush:latest
And you are good to go!
Testing to upload in FiveM​
Make a simple client script in your client side and you can use this snippet to test.
RegisterCommand('screenshot', function()
local server = 'http://THE.IPADDRESS.OFYOUR.IMAGESERVER:5000'
exports['screenshot-basic']:requestScreenshotUpload(server, 'file',
{ encoding = 'png', quality = 0.5 },
function(data)
local image = json.decode(data)
print(data)
local link = ('%s/%s'):format(server,image.filename)
TriggerEvent('chat:addMessage', { template = '<img src="{0}" style="width: 50%; height: 43%;" />', args = {link} })
end)
end)