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.
Before you begin, ensure you have:
- โ Docker installed on your system.
- โ A stable internet connection to download dependencies.
FROM ubuntu:22.04- Uses Ubuntu 22.04 as the foundation for the container.
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)
- ๐
RUN echo "daemon off;" >> /etc/nginx/nginx.conf- Ensures Nginx runs in the foreground inside the container.
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.zipinside/var/www/html/.
RUN cd /var/www/html && unzip main.zip && mv 2048-Game-main/* . && rm -rf 2048-Game-main main.zip- Extracts
main.zipinto/var/www/html/. - Moves game files to the correct directory.
- Cleans up unnecessary files.
EXPOSE 80- Opens port 80 to allow external access.
CMD ["/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf"]- Runs Nginx as the primary process inside the container.
docker build -t 2048-game .- Builds a Docker image named
2048-game.
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.
- Open a browser and visit:
http://localhost:8080
docker ps # Find container ID
docker stop <container_id>docker rm <container_id>docker rmi 2048-game- 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! ๐ฎ๐
That screenshot is fake, by the way. I never reached 2048 ๐