Holly Cui
by Holly Cui

Tags

  • Cloud Computing
🚩 Keywords: Rust, Actix Web Framework, Docker Containerization, Web-based Game, Cargo Project Management GitLab

Diving into this project was like embarking on a coding adventure, full of anticipation and the thrill of building something cool. I decided to tackle creating a web-based “Rock-Paper-Scissors” game, but with a twist—using Rust and the Actix web framework. The real kicker? Getting it all wrapped up in Docker for that sweet, sweet easy deployment. It’s like Rust met web dev and decided to throw a party in the Docker container sea 🐳.

The project initiation phase involved setting up the Cargo project environment. This was achieved by executing cargo new <YOUR-PROJECT-NAME> within the desired directory, marking the first step towards project setup. Subsequent tasks included the integration of essential libraries such as actix-web and actix-files into the Cargo.toml file, laying the groundwork for the web server’s functionality. The development process further entailed the implementation of Rust functions within src/main.rs, which were essential in defining the game’s logic and integrating Actix structures for web requests handling. Additionally, the customization of HTML files was pivotal in creating an engaging user interface, facilitating an intuitive gameplay experience.

Transitioning to Docker integration, the project necessitated the installation and updating of Docker Desktop to ensure compatibility and ease of container management. The creation of a Dockerfile at the project’s root was critical, outlining the specifications for Docker image and container creation. Commands such as docker build -t <YOUR-IMAGE-NAME> . and docker run -d -p 8080:8080 <YOUR-IMAGE-NAME> were instrumental in building and deploying the application, respectively. This phase underscored the importance of Docker in providing a consistent and isolated environment for application deployment, thereby enhancing the portability and scalability of the web-based game.

Moreover, the Docker ecosystem facilitated efficient container management, enabling the inspection of running containers, termination of processes, and resource cleanup through commands like docker ps, docker stop <CONTAINER-ID>, and docker rm <CONTAINER-ID>. This level of control and management is essential in maintaining the operational integrity and resource efficiency of Docker-based applications.

Wrapping things up, Rust and Docker proved to be quite the dynamic duo, handling the complexities of serverless web development and deployment with grace. It’s been an exciting journey building this project and learning a new possibility along the way 🎉