This project is designed to help students on how to build and run Docker containers using a simple version of the classic Asteroids game.
This repository contains a basic version of the Asteroids game implemented in HTML/JS with an FastAPI server as backend. The primary goal of this project is to provide a hands-on learning experience for building and running Docker containers.
The Docker image is available on Docker Hub at the following link: https://hub.docker.com/r/plofski/asteroids-game
Before you begin, ensure you have the following installed on your machine:
-
Clone the repository:
git clone https://github.com/yourusername/asteroids-docker.git cd asteroids-docker -
Build the Docker image for your system:
docker build -t asteroids-game .
-
Run the Docker container:
docker run -it -p 8000:8000 asteroids-game
-
Open your web browser and navigate to
http://localhost:8000to play the Asteroids game.
Want to build for other an other target platforms than yours?
- Build the docker image for the target platforms (using cross compilation)
docker buildx build --platform {{target_platform}} -t asteroids-game .
Want to build for multiple target platforms and directly push to docker hub ?
- create an builder (only need to do it once)
docker buildx create --use
- build for multiple target platforms and push to docker hub (Don't forget to login to docker hub first!)
platforms are seperated by a comma, for example: linux/amd64,linux/arm64
docker buildx build --platform {{platforms}} -t plofski/asteroids-game:latest --push .