Deploying a Game in Production
This guide will show you the steps to deploy the backend and frontend of your game, so players can connect from the internet and play and interact.
Deploying a Game in a production environment requirements will depend on the amount of players, interactions, number of backups, and many other factors. This guide is a starting point to run your services. We will not go in depth of each command/setup and some configurations will depend on your providers and exact software versions.
We recommend using a cloud provider to create a virtual machine, as they will provide a server with a public IP.
Requirements
- Your game must be working locally.
- Server with:
- Ubuntu 24.04 LTS Linux
- Public IP
- Sudo Access
- SSH Access
- As an absolute minimum use a server with 2GB RAM / 1 CPU / 25GB Storage (These requirements will change depending on your specific project needs)
- DNS Provider
- Additional Software
Backend
Before starting we recommend you create a user, and do not use the root account.
We will be using a user called paima
for all examples.
Software Verification
ssh
Let's verify you can connect to your machine via ssh
.
From your terminal you must be able to connect your server.
For these examples, we will use the follow naming:
paima@10.0.0.1
as theserver public IP
. You must use your ownIP
.user-name
as the username. Must be updated with the machine's user-namemy-game
as the game's name.local $>
for commands that are ran in your local machineserver $>
for commands that are run in the remote server
local $> ssh paima@10.0.0.1
You should see something as:
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-31-generic x86_64)
...
paima@server-name:~$
ubuntu
Let's check you have Ubuntu
installed
server $> lsb_release -a
Shows the Linux Distribution and the Version Description: Ubuntu 24.04 LTS
nginx
To verify your nginx
setup run: (This might change depending on your nginx setup)
local $> curl http://10.0.0.1
The response will be a webpage that contains:
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
docker
To verify your docker
setup run
server $> docker run hello-world
You should see some message that contains Hello from Docker!
Great, now you have all the tools.
Installation
Before continuing, make sure you compiled your project first.
We will first need to create a folder
server $> cd $HOME
server $> mkdir my-game
Now let's copy the main files we will need
# Copy DB Files
local $> rsync db/migrations/init/init.sql paima@10.0.0.1:/home/paima/my-game
local $> rsync db/docker/docker-compose.yml paima@10.0.0.1:/home/paima/my-game
# Copy .env, config & extension files
local $> rsync .env.production paima@10.0.0.1:/home/paima/my-game
local $> rsync config.prod.yml paima@10.0.0.1:/home/paima/my-game
local $> rsync extensions.yml paima@10.0.0.1:/home/paima/my-game
# If your extensions.yml has ABI extensions, copy them as well
# For example:
local $> rsync contracts/evm/abi/@paima/evm-contracts/contracts/token/IInverseAppProjected1155.sol/IInverseAppProjected1155.json paima@10.0.0.1:/home/paima/my-game
# Copy Paima Engine
local $> rsync paima-engine-linux paima@10.0.0.1:/home/paima/my-game
# Finally copy your Game Files
local $> rsync -r packaged paima@10.0.0.1:/home/paima/my-game
Run Database
We will be running the database in a docker container.
First we will edit the docker-compose.yml
# Use your favorite editor (We are using vi)
server $> cd $HOME/my-game
server $> vi docker-compose.yml
and modify the service-postgres-volumes entry:
volumes:
- my-game-db:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
and root volumes entry:
volumes:
my-game-db: