A simple, interactive Tic Tac Toe game built with HTML, CSS, and JavaScript.
Site is live on: https://ajmalrasouli.github.io/tic-tac-toe-app/
- Project Description
- Features
- Project Structure
- How to Dockerize this app
- Prerequisites
- Deploy on AWS ECR
- License
This Tic Tac Toe game allows two players to play against each other. The game interface is user-friendly and displays the game board, player turns, and the game result (win or draw).
- Interactive game board
- Two-player mode
- Winning message display
- Restart game functionality
- Node.js and npm installed on your system
- Clone the repository:
git clone https://github.com/your-username/tic-tac-toe.git cd tic-tac-toe
Running the Game To run the game locally, open the index.html file in your web browser:
open index.htmlTIC-TAC-TOE/
βββ index.html
βββ script.js
βββ style.css
βββ Dockerfile
βββ docker-compose.yml
# Use the official Node.js image as the base image.
FROM node:16
# Set the working directory.
WORKDIR /usr/src/app
# Copy all the files to the working directory in the container.
COPY . .
# Install http-server globally.
RUN npm install -g http-server
# Expose port 8080 to the outside world.
EXPOSE 8080
# Command to run the app using http-server.
CMD [ "http-server", "-p", "8080" ]version: '3.8'
services:
tic-tac-toe-app:
build: .
image: tic-tac-toe
ports:
- "8080:8080"
container_name: tic-tac-toe-app
To build and run the application using Docker, use the following command:
docker-compose up --buildThen, open your browser and navigate to:
http://localhost:8080
You need to have Docker installed on your system before you can build and run your Tic-Tac-Toe application as a Docker container.
For Windows:
- Download Docker Desktop for Windows from Docker's official website.
- Run the installer and follow the on-screen instructions.
- After installation, Docker Desktop will launch automatically. Ensure it is running by checking for the Docker icon in the taskbar.
For Mac:
- Download Docker Desktop for Mac from Docker's official website.
- Open the downloaded
.dmgfile and drag the Docker icon to the Applications folder. - Launch Docker from the Applications folder and follow the setup instructions.
For Linux:
- Follow the instructions specific to your Linux distribution on the Docker installation page.
If your project is hosted on GitHub, you can clone it using the following command:
git clone https://github.com/yourusername/tic-tac-toe.git
cd tic-tac-toeBuild and Run the Docker Container
-
Navigate to your project directory:
cd /path/to/your/tic-tac-toe-project -
Build the Docker image and start the container using Docker Compose:
Copy codedocker-compose up --build
Access the Application
Once the container is running, open your browser and navigate to:
http://localhost:8080
You should see your Tic-Tac-Toe application running.
Deploying Tic-Tac-Toe application using Docker, AWS ECR, and AWS App Runner. The guide includes instructions for downloading the AWS CLI, configuring it, pushing your Docker image to AWS ECR, and deploying it with AWS App Runner.
-
Download and Install AWS CLI v2 Follow the instructions to download and install the AWS CLI v2 from the official AWS documentation.
-
Configure AWS CLI Configure the AWS CLI with your credentials:
aws configureEnter your access key ID and secret access key when prompted:
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]: us-wesr-1
Default output format [None]: json-
Push Docker Image to AWS ECR
-
Authenticate Docker to your Amazon ECR registry:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 804789588521.dkr.ecr.us-east-1.amazonaws.com -
Build your Docker image:
docker build -t tictactoe . -
Tag your Docker image:
docker tag tictactoe:latest 804789588521.dkr.ecr.us-east-1.amazonaws.com/tictactoe:latest
-
Push your Docker image to Amazon ECR:
docker push 804789588521.dkr.ecr.us-east-1.amazonaws.com/tictactoe:latest
-
-
Deploy with AWS App Runner Create a new service on AWS App Runner:
-
Open the AWS Management Console and navigate to AWS App Runner.
-
Create a new service:
- Select "Container registry".
- Choose "Amazon ECR".
- Click "Browse" and select the tictactoe image.
- Set "Deployment setting" to "Automatic".
- Create a new service role if prompted.
-
Configure the services:
- Service name: tictactoe
- Virtual CPU: 1 vCPU
- Virtual memory: 2GB
- Port: 8080
-
Create and deploy the service.
After deployment, you can access your application at the provided URL:
https://vqydsibd8m.us-east-1.awsapprunner.com- Update the Project and Redeploy
When you update your project in VSCode and need to redeploy, follow these steps:
- Build your Docker image:
docker build -t tictactoe . - Tag your Docker image:
docker tag tictactoe:latest 804789588521.dkr.ecr.us-east-1.amazonaws.com/tictactoe:latest
- Push your Docker image to Amazon ECR:
docker push 804789588521.dkr.ecr.us-east-1.amazonaws.com/tictactoe:latest
-
AWS App Runner will automatically detect the new image and deploy it.
By following these steps, you will be able to configure AWS CLI, push your Docker images to AWS ECR, and deploy your application using AWS App Runner. When you update your project, you can quickly rebuild and push the new image, and AWS App Runner will handle the deployment automatically.
This project is licensed under the MIT License.