/gtav-fivem-server

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Grand Theft Auto V Private Server With Docker

FX Server version: 2468 (Download Latest)

ℹ️ Note: If server version is updated, change version in this README and fivem_server/fx_server_version

Information

This repo allows the setup of a FiveM GTAV server using docker-compose.

See official server setup guide for more information on what's going on in the background

Links

The following scripts are included in this server:


First Start Usage

Follow these steps when starting the server for the first time.

Run $ python3 generate_env_file.py to generate default SQL information
After running, this will generate an env_file containing your DB username and password

Configure server by editing fivem_server/server.cfg before running the following commands

ℹ️ Note: Make sure to replace the username/password/database in the db connect string with values generated from the script above

Run $ docker-compose up -d --build to start up the server

Wait a minute and initialize the database using the following command:

$ docker exec -it fivem_db_container mysql -u[username] -p[mysql_password] -e "$(cat fivem_server/database_files/es_extended_db.sql)"

Finally, restart the FiveM server container using $ docker-compose restart fivem_server so it can connect to the DB

That's it! 🎉 Start up the FiveM client and connect to the server!

Adding Scripts/Mods

See Script/Mod README

Once scripts are added to the local_resources folder, rebuild and run the fivem docker container to load the new resources with the following command

$ docker-compose up --no-deps -d --build fivem_server

Docker Notes

The docker container for the MySQL DB is mounted on a volume and not bind mounted. This means that the data is stored in an internal volume in docker. When you stop/start/recreate the MySQL container, the SQL data is retained.

ℹ️ Note: See FAQ section for information on how to remove the volume

F.A.Q

❓ Q: I've messed up and need to start over, how do I do that?

Run $ docker-compose down --volumes to tear down the stack. --volumes tells docker to also remove the mounted volumes.

⚠️ Warning: Removing the volumes will cause you to lose all data! (This includes database data). Make sure to backup your database if you plan on removing the volumes

❓ Q: How do I backup my database?

Run the following command:

$ docker exec fivem_db_container sh -c 'exec mysqldump --all-databases -u[username] -p[mysql_password]' > /some/path/on/your/host/all-databases.sql

❓ Q: Ok I've backed up my DB, now how do I restore that backup?

Run the following command:

$ docker exec -i fivem_db_container sh -c 'exec mysql -u[username] -p[mysql_password]' < /some/path/on/your/host/all-databases.sql