### Container Entrypoint Script Logic (Bash) Source: https://context7.com/spritsail/fivem/llms.txt An example of the entrypoint script for the FiveM container. It handles initial configuration, RCON password generation, OneSync setup, and license key validation. ```bash #!/bin/sh # entrypoint script breakdown # Debug mode (optional) export DEBUG=1 docker run -e DEBUG=1 -ti spritsail/fivem # Check if config directory is empty (first run) if ! find . -mindepth 1 | read -r; then >&2 echo "Creating default configs..." cp -r /opt/cfx-server-data/* /config # Generate random RCON password if not provided RCON_PASS="${RCON_PASSWORD-$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 16)}" sed -i "s/{RCON_PASS}/${RCON_PASS}/g" /config/server.cfg >&2 echo "----------------------------------------------" >&2 echo "RCON password is set to: ${RCON_PASS}" >&2 echo "----------------------------------------------" fi # OneSync configuration (enabled by default) if [ -z "$NO_ONESYNC" ]; then ONESYNC_ARGS="+set onesync on +set onesync_population true" fi # Build config arguments CONFIG_ARGS= if [ -z "${NO_DEFAULT_CONFIG}" ]; then CONFIG_ARGS="$CONFIG_ARGS $ONESYNC_ARGS +exec /config/server.cfg" fi # License key handling if [ -z "${NO_LICENSE_KEY}${NO_LICENCE_KEY}" ]; then # Support both spellings if [ -z "${LICENSE_KEY}" ] && [ -n "${LICENCE_KEY}" ]; then LICENSE_KEY="${LICENCE_KEY}" fi # Validate license key requirement if [ -z "${NO_DEFAULT_CONFIG}"] && [ -z "${LICENSE_KEY}" ]; then >&2 printf "License key not found in environment, please create one at https://keymaster.fivem.net!\n" exit 1 fi # Prevent txAdmin + LICENSE_KEY conflict if [ -z "${CONFIG_ARGS}" ] && [ -n "${LICENSE_KEY}" ] && [ -n "${NO_DEFAULT_CONFIG}" ]; then >&2 printf "txadmin does not use the \$LICENSE_KEY environment variable.\n Please remove it and set it through the txadmin web UI\n\n" exit 1 fi CONFIG_ARGS="$CONFIG_ARGS +set sv_licenseKey ${LICENSE_KEY}" fi # Launch FXServer with musl loader exec /opt/cfx-server/ld-musl-x86_64.so.1 \ --library-path "/usr/lib/v8/:/lib/:/usr/lib/" \ -- \ /opt/cfx-server/FXServer \ +set citizen_dir /opt/cfx-server/citizen/ \ $CONFIG_ARGS \ $* ``` -------------------------------- ### Retrieving txAdmin PIN and Correct Deployment (Bash) Source: https://context7.com/spritsail/fivem/llms.txt Shows how to retrieve the txAdmin setup PIN from container logs and provides a corrected Docker run command, highlighting the common mistake of using LICENSE_KEY with txAdmin. ```bash # View txAdmin setup PIN docker logs FiveM | grep PIN # txAdmin PIN: 123456 # Common error: Using LICENSE_KEY with txAdmin # ERROR: txadmin does not use the $LICENSE_KEY environment variable. # Please remove it and set it through the txadmin web UI # Correct txAdmin deployment docker run -d \ --name FiveM \ -e NO_DEFAULT_CONFIG=1 \ -p 30120:30120 \ -p 30120:30120/udp \ -p 40120:40120 \ -v /volumes/fivem:/config \ -v txData:/txData \ -ti \ spritsail/fivem ``` -------------------------------- ### Dockerfile for FiveM Image Build (Dockerfile) Source: https://context7.com/spritsail/fivem/llms.txt A multi-stage Dockerfile example for building a custom FiveM Docker image. It utilizes build arguments for specifying FiveM versions. ```dockerfile # Dockerfile with version control ARG FIVEM_NUM=21703 ARG FIVEM_VER=21703-0b6d5de3902cda6dd91be0c489d9b7243e554bb1 ARG DATA_VER=0e7ba538339f7c1c26d0e689aa750a336576cf02 FROM spritsail/alpine:3.22 as builder ARG FIVEM_VER ARG DATA_VER WORKDIR /output ``` -------------------------------- ### Dockerfile for FiveM Server Source: https://context7.com/spritsail/fivem/llms.txt This Dockerfile defines how to build a FiveM server image. It downloads and extracts the FiveM runtime and server data, installs necessary packages, and sets up the entrypoint. It supports build arguments for specifying FiveM and data versions. ```dockerfile FROM scratch ARG FIVEM_VER ARG FIVEM_NUM ARG DATA_VER LABEL org.opencontainers.image.authors="Spritsail " org.opencontainers.image.version=${FIVEM_NUM} io.spritsail.version.fivem=${FIVEM_VER} io.spritsail.version.fivem_data=${DATA_VER} # Build stage for downloading and preparing files FROM alpine:latest AS builder ARG FIVEM_VER ARG DATA_VER # Download and extract FiveM runtime RUN wget -O- https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/${FIVEM_VER}/fx.tar.xz \ | tar xJ --strip-components=1 \ --exclude alpine/dev --exclude alpine/proc \ --exclude alpine/run --exclude alpine/sys \ && mkdir -p /output/opt/cfx-server-data /output/usr/local/share \ && wget -O- http://github.com/citizenfx/cfx-server-data/archive/${DATA_VER}.tar.gz \ | tar xz --strip-components=1 -C opt/cfx-server-data \ \ && apk -p $PWD add tini # Add configuration files ADD server.cfg /output/opt/cfx-server-data ADD entrypoint /output/usr/bin/entrypoint RUN chmod +x /output/usr/bin/entrypoint # Final stage FROM scratch COPY --from=builder /output/ / WORKDIR /config EXPOSE 30120 CMD [""] ENTRYPOINT ["/sbin/tini", "--", "/usr/bin/entrypoint"] ``` -------------------------------- ### Run FiveM Docker Container Source: https://context7.com/spritsail/fivem/llms.txt Starts a FiveM server in a detached Docker container. It configures the container to be interactive and allocate a pseudo-TTY, sets an environment variable for a license key, maps a port for server access, and uses the 'spritsail/fivem' image. ```bash docker run -d --name FiveM -e LICENSE_KEY=key -p 30120:30120 -ti spritsail/fivem ``` -------------------------------- ### FiveM Server Management Commands Source: https://context7.com/spritsail/fivem/llms.txt A collection of common Docker commands for managing a running FiveM server container. This includes connecting to the shell, viewing logs, stopping, starting, restarting, and removing the container, as well as backing up and restoring configuration data. ```bash # Connect to running container shell docker exec -it FiveM sh # View real-time logs docker logs -f FiveM # Check RCON password from logs docker logs FiveM 2>&1 | grep "RCON password" # RCON password is set to: aB3dEf9GhIjK1mN2 # Stop server gracefully docker stop FiveM # Force stop if hung docker kill FiveM # Remove container (config persists in volume) docker rm FiveM # Restart server docker restart FiveM # View resource usage docker stats FiveM # CONTAINER CPU % MEM USAGE / LIMIT MEM % # FiveM 15.3% 512MiB / 8GiB 6.4% # Backup configuration docker cp FiveM:/config /backup/fivem-config-$(date +%Y%m%d) # Restore configuration docker cp /backup/fivem-config-20250101 FiveM:/config # Update to latest image docker pull spritsail/fivem:latest docker stop FiveM docker rm FiveM docker run -d \ --name FiveM \ -e LICENSE_KEY=your_key \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ spritsail/fivem:latest # Common error: Container crashes on startup ``` -------------------------------- ### Container Management (Bash) Source: https://context7.com/spritsail/fivem/llms.txt Commands to execute within the FiveM container to edit configuration files and restart the server. Useful for applying changes after initial setup. ```bash # Edit configuration after initial setup docker exec -it FiveM sh vi /config/server.cfg # Restart server to apply changes docker restart FiveM ``` -------------------------------- ### Run FiveM Server with Docker Source: https://github.com/spritsail/fivem/blob/master/README.md This command launches a FiveM server container. It sets the container name, restart policy, license key, port mappings, and volume for configuration. It's crucial to use interactive and pseudo-tty options for the container to start correctly. ```shell docker run -d \ --name FiveM \ --restart=on-failure \ -e LICENSE_KEY= \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ spritsail/fivem ``` -------------------------------- ### Docker Compose Deployment for FiveM Server Source: https://context7.com/spritsail/fivem/llms.txt This snippet provides a Docker Compose configuration to deploy a FiveM server with persistent storage. It defines the service, image, ports, volumes, and environment variables required for a reproducible deployment. It also includes commands to start, check status, stop, and view logs for the Docker Compose services. ```yaml # docker-compose.yml version: '3' services: fivem: image: spritsail/fivem container_name: fivem restart: always stdin_open: true tty: true volumes: - "/path/to/resources/folder:/config" ports: - "30120:30120" - "30120:30120/udp" environment: LICENSE_KEY: "license-key-here" ``` ```bash # Start the server docker-compose up -d # Check service status docker-compose ps # Name Command State Ports # fivem /sbin/tini -- Up 0.0.0.0:30120->30120/tcp, 0.0.0.0:30120->30120/udp # Stop the server docker-compose down # View logs docker-compose logs -f fivem ``` -------------------------------- ### Docker Build and Run Commands Source: https://context7.com/spritsail/fivem/llms.txt These commands demonstrate how to build a FiveM Docker image with specific versions or the latest tag, inspect image labels, and run a FiveM server container. It includes options for setting build arguments, naming the image, mapping ports, and mounting volumes for configuration. ```bash # Build custom image with specific version docker build \ --build-arg FIVEM_NUM=21703 \ --build-arg FIVEM_VER=21703-0b6d5de3902cda6dd91be0c489d9b7243e554bb1 \ --build-arg DATA_VER=0e7ba538339f7c1c26d0e689aa750a336576cf02 \ -t my-fivem:21703 . # Build with latest version docker build -t my-fivem:latest . # Inspect image labels docker inspect my-fivem:21703 | grep -A 5 Labels # "io.spritsail.version.fivem": "21703-0b6d5de3902cda6dd91be0c489d9b7243e554bb1" # "io.spritsail.version.fivem_data": "0e7ba538339f7c1c26d0e689aa750a336576cf02" # Run custom built image docker run -d \ --name custom-fivem \ -e LICENSE_KEY=your_key \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ my-fivem:21703 ``` -------------------------------- ### Run FiveM Server with Docker Source: https://context7.com/spritsail/fivem/llms.txt This snippet demonstrates how to run a FiveM server in a Docker container. It includes essential configurations like license key, port mapping, and volume mounting for persistent data. It also shows how to verify the container is running and view its logs. ```bash # Run FiveM server with basic configuration docker run -d \ --name FiveM \ --restart=on-failure \ -e LICENSE_KEY=your_license_key_here \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ spritsail/fivem # Expected output on first run: # Creating default configs... # ---------------------------------------------- # RCON password is set to: aB3dEf9GhIjK1mN2 # ---------------------------------------------- # Verify container is running docker ps | grep FiveM # FiveM spritsail/fivem "/sbin/tini -- /usr/…" Up 2 minutes 30120/tcp, 30120/udp # View server logs docker logs FiveM # Server started successfully # Resources loaded: mapmanager, chat, spawnmanager, sessionmanager, fivem, hardcap, rconlog, scoreboard ``` -------------------------------- ### FiveM Server Configuration File (server.cfg) Source: https://context7.com/spritsail/fivem/llms.txt This snippet shows a sample server.cfg file for FiveM server customization. It includes essential configurations like network endpoints, required resources, RCON password, server information, and admin permissions. This file allows fine-tuning of the server's behavior and settings. ```cfg # server.cfg - Default configuration # Network endpoints (do not change unless multiple network interfaces) endpoint_add_tcp "0.0.0.0:30120" endpoint_add_udp "0.0.0.0:30120" # Essential resources that start automatically ensure mapmanager ensure chat ensure spawnmanager ensure sessionmanager ensure fivem ensure hardcap ensure rconlog ensure scoreboard # Allow scripthook plugins (0=disabled, 1=enabled) sv_scriptHookAllowed 0 # RCON password (auto-generated on first run) rcon_password {RCON_PASS} # Server information sv_hostname "My new Dockerized FXServer" # Optional banner images #sets banner_detail "https://url.to/image.png" #sets banner_connecting "https://url.to/image.png" # Hide from server browser (uncomment to disable) #sv_master1 "" # Server icon (96x96 PNG) #load_server_icon myLogo.png # Admin permissions add_ace group.admin command allow add_ace group.admin command.quit deny add_principal identifier.fivem:1 group.admin # Privacy settings sv_endpointprivacy true ``` -------------------------------- ### Drone CLI and Registry Commands Source: https://context7.com/spritsail/fivem/llms.txt This section provides commands for interacting with the Drone CI CLI and Docker registries. It includes triggering manual builds, checking build status, viewing logs, and pulling images from different container registries. ```bash # Trigger manual pipeline (requires drone CLI) drone build create spritsail/fivem --branch master # Check build status drone build ls spritsail/fivem # View build logs drone build logs spritsail/fivem 123 # Pull from different registries docker pull spritsail/fivem:latest # Docker Hub docker pull ghcr.io/spritsail/fivem:latest # GitHub Container Registry docker pull registry.spritsail.io/spritsail/fivem:latest # Spritsail Registry ``` -------------------------------- ### Docker Run Command with txAdmin (Bash) Source: https://context7.com/spritsail/fivem/llms.txt Launches the FiveM server in detached mode with the txAdmin web interface enabled. It maps ports and mounts volumes for persistent data. ```bash # Run with txAdmin enabled (no default config) docker run -d \ --name FiveM \ --restart=on-failure \ -e NO_DEFAULT_CONFIG=1 \ -p 30120:30120 \ -p 30120:30120/udp \ -p 40120:40120 \ -v /volumes/fivem:/config \ -v /volumes/txData:/txData \ -ti \ spritsail/fivem # Access txAdmin web interface # Navigate to: http://your-server-ip:40120 # First-time setup will prompt for: # - Admin PIN (displayed in container logs) # - License key (enter through web UI, not environment variable) # - Server configuration ``` -------------------------------- ### Basic Server Configuration (server.cfg) Source: https://context7.com/spritsail/fivem/llms.txt Sets the maximum number of clients and the Steam authentication API key. These are fundamental settings for any FiveM server. ```plaintext sv_maxclients 32 set steam_webApiKey "" ``` -------------------------------- ### Drone CI/CD Pipeline Configuration Source: https://context7.com/spritsail/fivem/llms.txt This YAML file defines a Drone CI pipeline for automating the build and deployment of FiveM Docker images. It includes steps for building the image and publishing it to multiple registries (Spritsail, GHCR, Docker Hub) based on branch and event triggers. ```yaml # .drone.yml - CI/CD configuration kind: pipeline name: default platform: os: linux arch: amd64 steps: - name: build pull: always image: registry.spritsail.io/spritsail/docker-build - name: publish-spritsail pull: always image: registry.spritsail.io/spritsail/docker-publish settings: registry: registry.spritsail.io login: {from_secret: spritsail_login} repo: spritsail/fivem tags: - latest - "%label org.opencontainers.image.version" delete: no when: branch: - master event: - push - name: publish-ghcr pull: never image: registry.spritsail.io/spritsail/docker-publish settings: registry: ghcr.io login: {from_secret: ghcr_login} repo: spritsail/fivem tags: - latest - "%label org.opencontainers.image.version" delete: no when: branch: - master event: - push - name: publish-dockerhub pull: never image: registry.spritsail.io/spritsail/docker-publish settings: login: {from_secret: docker_login} repo: spritsail/fivem tags: - latest - "%label org.opencontainers.image.version" when: branch: - master event: - push ``` -------------------------------- ### FiveM Server Configuration with Environment Variables Source: https://context7.com/spritsail/fivem/llms.txt This snippet illustrates various ways to configure a FiveM server using environment variables when running a Docker container. It covers setting the license key, custom RCON password, disabling OneSync, and using a license key from a config file. ```bash # Basic configuration with license key docker run -d \ --name FiveM \ -e LICENSE_KEY=your_license_key_here \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ spritsail/fivem # Custom RCON password (default is random 16 characters) docker run -d \ --name FiveM \ -e LICENSE_KEY=your_license_key_here \ -e RCON_PASSWORD=my_secure_password_123 \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ spritsail/fivem # Disable OneSync optimization docker run -d \ --name FiveM \ -e LICENSE_KEY=your_license_key_here \ -e NO_ONESYNC=1 \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ spritsail/fivem # Use license key from config file instead of environment docker run -d \ --name FiveM \ -e NO_LICENSE_KEY=1 \ -p 30120:30120 \ -p 30120:30120/udp \ -v /volumes/fivem:/config \ -ti \ spritsail/fivem ``` -------------------------------- ### Run FiveM Server with txAdmin Web UI Source: https://github.com/spritsail/fivem/blob/master/README.md This command runs a FiveM server with the txAdmin Web UI enabled. It includes additional port mapping for txAdmin's webserver and a separate volume for txAdmin's data. The NO_DEFAULT_CONFIG environment variable is used to disable default configurations, allowing txAdmin to take over. ```shell docker run -d \ --name FiveM \ --restart=on-failure \ -e LICENSE_KEY= \ -p 30120:30120 \ -p 30120:30120/udp \ -p 40120:40120 \ -v /volumes/fivem:/config \ -v /volumes/txData:/txData \ -ti \ spritsail/fivem ``` -------------------------------- ### Docker Compose for FiveM with txAdmin (YAML) Source: https://context7.com/spritsail/fivem/llms.txt Defines a FiveM service within a docker-compose.yml file, configuring ports, volumes, and environment variables for txAdmin deployment. ```yaml version: '3' services: fivem: image: spritsail/fivem container_name: fivem restart: always stdin_open: true tty: true volumes: - "/path/to/resources/folder:/config" - "/path/to/txData/folder:/txData" ports: - "30120:30120" - "30120:30120/udp" - "40120:40120" environment: NO_DEFAULT_CONFIG: "1" ``` -------------------------------- ### Check Port Binding with netstat Source: https://context7.com/spritsail/fivem/llms.txt Verifies if port 30120 is correctly bound and listening for TCP and UDP connections. This command is useful for confirming that the Docker container's port mapping is active. ```bash netstat -tulpn | grep 30120 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.