You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A copy version of our web game project and remove its packages.
Configure the web builder in Program.cs to expose the web game in port 80 for production.
Change server port (Startup.cs) and client port (all JavaScript files that have fetch requests to server) from development to production.
Create a seed script so that you can initialize the database when you deploy.
Create a Dockerfile for the web game.
Create a docker-compose file so that you can easily combine the web game image, the PostgresSQL image and the seed script together then deploy it.
The port of the web game image in the docker-compose file should be point to 80 (default port of our AWS EC2 instance web server) so that the instance can display the web game if we deploy successfully.
AWS EC2 Setup
From AWS Dashboard, we will choose EC2 service.
Choose Launch instance to start creating new instance for deploying our web game.
Choose the first option Amazon Linux 2 (or another linux version that you prefer)
You just only need to choose the t2.micro (free tier) then skip through all the instance next setup (because our project is simple and doesn't need it). But when you reach the Configure Security Group setup, you will also need to add rule for HTTP type with Anywhere source. Finally, click next and launch the instance.
Create and download new key pair of the instance (or choose an existing key pair if you have).
Create an Elastic IP for the instance.
Configure the key pair to connect and copy the web game project to the instance.
# Give your key pair permission to read and copy the project
chmod 400 key-pair-name.pem
# Copy the project to the AWS EC2 instance
scp -r -i key-pair-name.pem ~/path/to/your/project/folder/from/root ec2-user@instance-ip:~/
# Connect to the AWS EC2 instance
ssh -i key-pair-name.pem ec2-user@instance-ip
Install Docker and docker-compose for the instance.