2048-Devops-Project
This is a Mini Devops Project
This repository provides a Dockerfile for setting up an Ubuntu 23.04-based container with Nginx and the popular game 2048.
Instructions
To build the Docker image and run the container, follow these steps:
-
Install Docker on your machine if you haven't already.
-
Clone this repository or create a new directory for your project and create a new file called
Dockerfile
. -
Open the
Dockerfile
in a text editor and copy the following content into it:FROM ubuntu:23.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/gabrielecirulli/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"]
-
Save the
Dockerfile
. -
Open a terminal or command prompt and navigate to the directory containing the
Dockerfile
. -
Build the Docker image by running the following command:
docker build -t 2048-game .
This command will create a Docker image with the name
2048-game
based on theDockerfile
in the current directory. -
Once the image is built, you can run a container based on it using the following command:
docker run -d -p 80:80 2048-game
This command will start a container in the background (
-d
flag) and map port 80 of the container to port 80 of your local machine (-p 80:80
flag). -
Open a web browser and visit http://localhost. You should see the 2048 game running.
It would look somewhat like this -
Notes
- The Dockerfile starts with the
ubuntu:23.04
base image, updates the package lists, and installs Nginx, zip, and curl. - It then modifies the Nginx configuration to run in the foreground.
- Next, it downloads the
master.zip
file from the GitHub repository of the 2048 game and extracts it into the/var/www/html
directory. - Finally, it exposes port 80 and starts Nginx using the modified configuration file.
Feel free to customize the Dockerfile or explore different versions of Ubuntu or Nginx based on your requirements.
A docker file is created which form the image.
When your docker file is successfully created and can be seen on your localhost. It is ready to be hosted.
I used AWS Elastic BeanStalk to host it.
It can be done in few easy steps -
-
Sign in to the AWS Management Console and open the Elastic Beanstalk service.
-
Click on "Create a new environment" or "Create Environment" to start the environment creation process.
-
Select "Web server environment" as the environment tier.
- Fill out the Application name and Enviroment information choose Docker as the platform.
-
In Application Code Section add Version Lable (example - 2048-game-v1)
-
Select Upload code in Application Code Section. Click Local File and Click on Choose File then upload your Docker file.
-
Choose your desired Preset.
-
Create your Service Access.
-
For now just skip to review if you don't wnat to configure anything else.
-
Click "Submit" to start the environment creation process. Elastic Beanstalk will now create the necessary resources and deploy your Docker image.
-
Once the environment is successfully created and running, Elastic Beanstalk will provide you with a URL to access your application.
-
Open a web browser and visit the provided URL. You should be able to see the 2048 game running.
2048 game cloned from the repository - https://github.com/gabrielecirulli/2048