-
-
Notifications
You must be signed in to change notification settings - Fork 226
Host and run free games claimer in the cloud periodically
In order to periodically run the free-games-claimer it's best to host it somewhere, so that you don't have to run it always manually from your local machine.
There are some free providers out there, one that allows you to run docker is Oracle Cloud.
Recently I was introduced Oracle cloud, and its free tier for an unlimited time. Check the supported always free services:
- 2 AMD based Compute VMs with 1/8 OCPU** and 1 GB memory each
- 4 Arm-based Ampere A1 cores and 24 GB of memory usable as one VM or up to 4 VMs
- 2 Block Volumes Storage, 200 GB total
- 10 GB Object Storage — Standard
- 10 GB Object Storage — Infrequent Access
- 10 GB Archive Storage
- Resource Manager: managed Terraform
- 5 OCI Bastions
As you can see they are very generous with their free tier, and we can do a lot with this.
Create an Oracle Cloud Infrastructure account (just follow this link).
Install terraform.
Install OCI CLI .
Configure OCI credentials.
As you can suspect by now, we are going to use terraform to provision our Docker service. Basically terraform will create one VM instance as big as the free tier allow us, and make it ready so we can ssh into the machine and have docker ready to start our containers.
-
Checkout remote-docker project with the terraform configuration and enter its directory.
-
Run
terraform initandterraform applyin that directory
If you get an error like this:
timeout -- last error: dial tcp IP_ADDRESS:22: connect: connection refusedtry to add the id_rsa generated by terraform to your ssh-agent ( ssh-add id_rsa ) and run terraform apply one (or more) more time(s), the id_rsa should be localized in the root of the project.
If you were able to reach this point, you now have a VM running that you can run whatever you want (check Oracle's terms and conditions for this service). At the end of the process terraform is configured to show the public IP of the newly created instance.
You will see something like this at the end of the terraform script when it ran successfully:
ssh-with-docker-user = "ssh -l docker -p 22 -i {SOMEIPADDRESS} # docker-1"you will need to slightly change the command in order for it to work:
ssh -l docker -p 22 -i {PATH_TO_id_rsa} {SOMEIPADDRESS}so let's say you are still in the folder where you ran terraform then the id_rsa file will be in the same folder - let's assume the IP is 123.456.789.0
ssh -l docker -p 22 -i id_rsa 123.456.789.0What you also can do is to add this IP to /etc/hosts so you don't need to call it by the IP address.
Connect to the remote server using the ssh command from above and run docker ps to check if docker is running as expected.
Now you can run
docker run --rm -it -p 6080:6080 -v fgc:/fgc/data --pull=always ghcr.io/vogler/free-games-claimerand watch the magic happen. You can simultaneously connect to your IP address http://123.456.789.0:6080 and observe that everything works as expected.
To periodically run things we are going to use a cronjob.
As described here you can add the above docker command with a slight change to crontab to run it at any given time.
Further down in the discussion you can also find a version that writes to a logfile - so you can check every now and then what happened.
- This was mostly copy & pasted from https://medium.com/codex/run-your-docker-containers-for-free-in-the-cloud-and-for-unlimited-time-361515cb0876
- Working through this tutorial and giving your financial information to Oracle is at own your own risk 😉