Building and Deploying a Dockerized 2048-MathGame on AWS Elastic Beanstalk

Building and Deploying a Dockerized 2048-MathGame on AWS Elastic Beanstalk

Containerization and Cloud Deployment: A Comprehensive Guide to Building and Deploying a Dockerized 2048-MathGame on AWS Elastic Beanstalk

FLOW of this article:

  1. Title and description of project

  2. Creating docker file

  3. Host on the cloud using AWS Elastic Beanstalk

Title: 2048 Math Game — A Challenging Mathematical Puzzle 🎮

Description

2048 Math Game is an addictive and brain-teasing puzzle game inspired by the popular 1024 game. Put your mathematical skills to the test and challenge yourself in this exciting numbers-based game.

The objective is simple: combine tiles with the same numbers to reach the elusive 2048 tile. However, be prepared for a real mental workout as you strategize and plan your moves carefully. Each swipe will move all tiles in the selected direction, and new tiles will appear with each move. Your goal is to keep combining and doubling the numbers until you achieve the ultimate 2048 tile!

The game features a sleek and minimalist design that enhances the gameplay experience. With intuitive controls and smooth animations, you can easily immerse yourself in this addictive puzzle. It’s suitable for players of all ages, from math enthusiasts to casual gamers looking for a challenging and enjoyable pastime.

Key Features

  • Addictive gameplay: Exercise your brain with a captivating mathematical puzzle.

  • Strategic thinking: Plan your moves carefully to maximize your chances of success.

  • Simple controls: Swipe in four directions to move the tiles and combine numbers.

  • Minimalist design: Enjoy a visually pleasing and distraction-free interface.

  • Progress tracking: Keep track of your high scores and challenge yourself to improve.

Whether you’re a fan of number games or simply love a good puzzle, 2048 Math Game will provide hours of entertainment and mental stimulation. Download now and embark on a number-crunching adventure!

Screenshot

That screenshot is fake, by the way. I never reached 2048 😄

Github Repo Link : https://github.com/DevMankad1/2048-MathGame.git

Creating docker file

First create a folder named 2048 and in that folder just rightclick and open that folder on vs code. now create a file in that folder name it Dockerfile. We have to enter some commands in Dockerfile.writ

Dockerfile

Note : I will make a blog on docker commands explanation soon. so you can get the basic idea of all of this commands which is in my vscode screenshot.

Now after entering the commands open the terminal and write command for creating docker image from docker file.

command : docker build -t .

This command will create a docker image from dockerfile.

After creating image we run that image and running image is call container so to start a container from image we enter a command.

command : docker run -d -p 80:80 <image-id/image-name>

now after entering this command go to your local browser and write localhost:80 and press enter.

host game on localhost:80

So, game is created which means a docker container is running. you can play this game.

but right now this docker container is inyour local host so no one else is going to access it apart from you so this is why we have to host it on AWS cloud.

If you are currently following my blog i hope your container is running which is hosting 2048 game.

Host this on the cloud using AWS Elastic Beanstalk

open your aws console. you are here so i am expecting that you already have AWS account.

Now go to Elastic Beanstalk.

click on create application.

Create application using Elastic Beanstalk, Configure the environment

Now configure the environment.

Select Docker as platform

scroll down and in platform select docker as a platform.

Upload Dockerfile from pc

In application mode select Upload your code option.

Give a version label (Unique).

Select local file upload option and choose the docker file from your pc.

Now if you want to configure it more you caan continue otherwise skip the steps and click on create app.

Elastic Beanstalk is launching your environment.

You dont need to manage anything. you just need to push your code and elastic beanstalk will create your infrastructure like it will create your containers, load balancers, auto scaling groups everything that is necessary for this application to run will be created by Elastic Beanstalk.

Copy the domain link and paste it in new tab

When health gets Ok symbol. copy the domain link and paste it in new tab and now your application is globally accessible not only to a local host you can check it with another device or open in incognito tab.

Game Link 🎮 : http://2048-mathgame-env.eba-xmpyhfts.ap-south-1.elasticbeanstalk.com/

📈 If you have any questions, feedback, or simply want to connect, feel free to reach out to me at devmankad12@gmail.com or connect with me on linkedin — Dev Mankad. I’d love to hear from you!