Simple DevOps Project: Deployment of 2048 Game on AWS using docker

Simple DevOps Project: Deployment of 2048 Game on AWS using docker

ยท

2 min read

Table of contents

Introduction

This application was deployed in the Ec2 instance of Ubuntu's Processor of T2 Micro with 8 GB of storage on it.

Setup:

  1. Launch an EC2 instance.

    • Sign in to the AWS Management Console.

    • Go to the EC2 Dashboard.

    • Click on "Launch Instance."

    • Choose an Amazon Machine Image (AMI) with Ubuntu, such as "Ubuntu Server" or "Ubuntu LTS."

    • Select an instance type, configure instance details, and add storage as needed.

    • Configure security groups to allow SSH (port 22) and any other required access.

    • Review and launch the instance, and create or choose an existing key pair to connect to the instance securely.

  2. Connect to the EC2 instance:

    Once your EC2 instance is running, you can connect to it using SSH. Replace your-key.pem with the actual name of your key pair file and your-instance-ip with the public IP of your instance:

     ssh -i your-key.pem ubuntu@your-instance-ip
    
  3. Update and Upgrade Packages:

    After connecting to the instance, it's a good practice to update and upgrade the system packages to ensure you have the latest software and security updates:

     sudo apt update
     sudo apt upgrade
    
  4. We have to install Docker.

     sudo apt install docker.io -y
    
  5. We have given permission to docker

  6. Then we will write a Dockerfile for our 2048 app

     FROM ubuntu:22.04
     RUN apt-get update
     RUN apt-get install -y nginx zip curl
     RUN echo "daemon off;">>/etc/nginx/nginx.conf
     RUN curl -o /var/www/html/master.zip -L https://codeload.github.com/jabir000/2048/zip/master
     RUN cd /var/www/html/ && unzip master.zip && mv 2048-master/* . && rm -rf 2048-master master.zip
     EXPOSE 80
     CMD ["/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf"]
    
    1. Execute the following commands in the new terminal

       pwd
      
       ls
      
       docker build -t <docker image name> .
      

       docker images
      

       docker run -d -p 80:80 <container id>
      

       docker ps
      

๐Ÿ˜Š Thank you so much for reading my blog! ๐Ÿ˜Š I hope you found it helpful and informative. If you did, please ๐Ÿ‘ give it a like and ๐Ÿ’Œ subscribe to my newsletter for more of this type of content. ๐Ÿ’Œ

I'm always looking for ways to improve my blog, so please feel free to leave me a comment or suggestion. ๐Ÿ’ฌ

Thanks again for your support! ๐Ÿ˜Š

ย