Skip to content

Sachin2815/2048-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ 2048 Game Deployment with Docker ๐Ÿš€

๐Ÿ“Œ Overview

This project sets up an Nginx web server inside a Docker container to serve the 2048 game. The Dockerfile automates the entire setup process, making deployment seamless and efficient.


๐Ÿ› ๏ธ Prerequisites

Before you begin, ensure you have:

  • โœ… Docker installed on your system.
  • โœ… A stable internet connection to download dependencies.

๐Ÿ—๏ธ Step-by-Step Process

1๏ธโƒฃ Pull the Base Image

FROM ubuntu:22.04
  • Uses Ubuntu 22.04 as the foundation for the container.

2๏ธโƒฃ Install Required Packages ๐Ÿ› ๏ธ

RUN apt-get update
RUN apt-get install -y nginx zip curl unzip
  • Updates package lists.
  • Installs essential tools:
    • ๐ŸŒ nginx (Web server)
    • ๐Ÿ“ฆ zip & unzip (For file extraction)
    • ๐Ÿ”„ curl (For file downloads)

3๏ธโƒฃ Configure Nginx โš™๏ธ

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
  • Ensures Nginx runs in the foreground inside the container.

4๏ธโƒฃ Download 2048 Game Source Code ๐ŸŽฎ

RUN curl -o /var/www/html/main.zip -L https://github.com/Sachin2815/2048-Game/archive/refs/heads/main.zip
  • Downloads the 2048 game source code from GitHub.
  • Saves it as main.zip inside /var/www/html/.

5๏ธโƒฃ Unzip and Organize Files ๐Ÿ“‚

RUN cd /var/www/html && unzip main.zip && mv 2048-Game-main/* . && rm -rf 2048-Game-main main.zip
  • Extracts main.zip into /var/www/html/.
  • Moves game files to the correct directory.
  • Cleans up unnecessary files.

6๏ธโƒฃ Expose Port 80 ๐ŸŒ

EXPOSE 80
  • Opens port 80 to allow external access.

7๏ธโƒฃ Start Nginx Server ๐Ÿš€

CMD ["/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf"]
  • Runs Nginx as the primary process inside the container.

๐Ÿš€ Running the Container

๐Ÿ”น Build the Docker Image

docker build -t 2048-game .
  • Builds a Docker image named 2048-game.

๐Ÿ”น Run the Container ๐Ÿƒโ€โ™‚๏ธ

docker run -d -p 8080:80 2048-game
  • Runs the container in detached mode (-d).
  • Maps port 80 in the container to port 8080 on the host.

๐Ÿ”น Access the Game ๐ŸŒ


โน๏ธ Stopping and Removing the Container

๐Ÿ”ธ Stop the container:

docker ps  # Find container ID
docker stop <container_id>

๐Ÿ”ธ Remove the container:

docker rm <container_id>

๐Ÿ”ธ Remove the image:

docker rmi 2048-game

๐ŸŽ‰ Conclusion

  • This Docker setup automates the deployment of the 2048 game.
  • Uses Nginx to serve the game on port 80.
  • Can be easily executed with a few Docker commands.

๐Ÿ”น Enjoy the game & have fun! ๐ŸŽฎ๐Ÿš€

Screenshot

That screenshot is fake, by the way. I never reached 2048 ๐Ÿ˜„

About

Dockerized 2048 game with Nginx. Simple setup, quick deployment, and ready to play! ๐Ÿš€

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published