quintende / redm-dev-containers

A Repository containing RedM (CitizenFx) devcontainer for usage with VS Code Remote - Containers extension and GitHub Codespaces

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RedM Development Container

Summary

An Ubuntu container configured for RedM Linux development. This devcontainer is based on the Microsoft Ubuntu devcontainer.

Metadata Value
Definition type Docker Compose
Available image variants ubuntu-22.04 / jammy, ubuntu-20.04 / focal, ubuntu-18.04 / bionic (full list)
Available CFX server variants latest-recommended, latest-optional, latest, <version_number> (full list)
Available CFX base resources variants latest, <commit_hash> (full list)
Works in Codespaces Yes
Container host OS support Linux, macOS, Windows
Container OS Ubuntu

Important Notes

This devcontainer only provides the CFX server and resource files. It does not contain a pre-configured and ready game server. For set-up and configuration please refer to the official documentation.

Do note that some configuration needs to be changed from the defaults in order for it to work with GitHub Codespaces. These are as followed:

Configuring endpoints in server.cfg

It seems that the default port (30120) that CFX server is already in use when trying to build the containers. Which is why we'll use a different port to prevent conflicting ports. In your server.cfg the following fields endpoint_add_tcp and endpoint_add_udp should contain the port 30125.

endpoint_add_tcp "0.0.0.0:30125"
endpoint_add_udp "0.0.0.0:30125"

Tunneling

It seems that GitHub Virtual Codespaces does not support forwarding UDP ports out of codespaces. This is why we'll use the Remote UDP Tunnel extension to forward our UDP ports. This extension comes pre-installed with the devcontainer. A port can be forwarded by running the Remote UDP Tunnel: Forward a Port command, which can be accessed via the Command Palette.

Press F1 1 and run Remote UDP Tunnel: Forward a Port, which in turn will give a prompt where you can fill the 30125 port in.

[1] Command Palette can also be accessed via ctrl + shift + p on Windows and + shift + p on Mac.

Connecting to the development server

When you have configured your server correctly and the additional configurations (as mentioned above) you should be able to connect in-game to the server by pressing F8 and running connect 127.0.0.1:30125.

Using this definition

While the definition itself works unmodified, you can select specify the version of Ubuntu, CFX server, CFX resources and CFX path in your container.

These can be changed by updating the values VARIANT, SERVER_VERSION, RESOURCES_VERSION and CFX_PATH args in the included devcontainer.json (and rebuilding if you've already created the container).

"args": { 
    "VARIANT": "ubuntu-18.04",
    "SERVER_VERSION": "latest-recommended",
    "RESOURCES_VERSION": "latest",
    "CFX_PATH": "/home/vscode/cfx"
 }

Besides the main Ubuntu container a MariaDb Container has also been configured, which can be accessed via:

mariadb -umariadb -pmariadb -h db

The MariaDb configuration such as username, password, database, etc.. can be changed in the docker-compose.yml file.

The Ubuntu container also includes git, node:12, pre-installed VS Code extensions for UDP tunneling and a non-root vscode user with sudo access, and a set of common dependencies for development.

Adding the definition to a project or codespace

  1. If this is your first time using a development container, please see getting started information on setting up Remote-Containers or creating a codespace using GitHub Codespaces.

  2. Build with this custom version of the image instead:

    1. Clone this repository locally.
    2. Start VS Code and open your project folder or connect to a codespace.
    3. Use your local operating system's file explorer to drag-and-drop the locally cloned copy of the .devcontainer folder for this definition into the VS Code file explorer for your opened project or codespace.
    4. Update .devcontainer/devcontainer.json to reference "dockerfile": "base.Dockerfile".
  3. After following step 2, the contents of the .devcontainer folder in your project can be adapted to meet your needs.

  4. Finally, press F1 and run Remote-Containers: Reopen Folder in Container or Codespaces: Rebuild Container to start using the definition.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE

About

A Repository containing RedM (CitizenFx) devcontainer for usage with VS Code Remote - Containers extension and GitHub Codespaces

License:MIT License


Languages

Language:Shell 68.8%Language:Dockerfile 31.2%