{"id":2266,"date":"2023-05-16T10:44:37","date_gmt":"2023-05-16T10:44:37","guid":{"rendered":"https:\/\/www.workfall.com\/learning\/blog\/?p=2266"},"modified":"2025-09-17T04:16:35","modified_gmt":"2025-09-17T04:16:35","slug":"deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions","status":"publish","type":"post","link":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/","title":{"rendered":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"576\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15-1024x576.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2268\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15-1024x576.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15-300x169.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15-768x432.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15-1536x864.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15-1160x653.png 1160w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15-600x338.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-15.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">When Rust compiles code, you get an executable if you created the application using the <strong><code>--bin<\/code><\/strong> command. In this blog, we shall look at how we can create a Dockerfile to create an image with this executable. We shall then deploy this image on EC2 using GitHub Actions which will be set on our repository <a href=\"https:\/\/github.com\/workfall\/workfall-rocket-rs\">https:\/\/github.com\/workfall\/workfall-rocket-rs<\/a> which also has the source code for our web application.<\/p>\n\n\n\n<p>In this blog, we will cover:<\/p>\n\n\n\n<ul><li>Docker<\/li><li>AWS EC2<\/li><li>Hands-on<\/li><li>Conclusion<\/li><\/ul>\n\n\n\n<h2>Docker<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">We are going to containerize our application using Docker to make it easier to deploy on different target platforms. A container is created from an image and an image is simply a list of dependencies required to run a certain software on a target platform.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker<\/a> is an open-source platform that automates the deployment and management of applications inside lightweight, portable containers. A container is a standalone unit that packages an application&#8217;s code, dependencies, and runtime environment, ensuring that the application runs consistently across different computing environments.<\/p>\n\n\n\n<h2>AWS EC2<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">We are going to use <a href=\"https:\/\/www.workfall.com\/learning\/blog\/deploy-a-yew-rust-application-on-an-aws-ec2-ubuntu-instance-nginx\/\" target=\"_blank\" rel=\"noreferrer noopener\">Elastic Cloud Compute service with Ubuntu OS<\/a> to deploy our application. Amazon Elastic Compute Cloud (EC2) is a web service that provides resizable compute capacity in the cloud.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><a href=\"https:\/\/www.workfall.com\/learning\/blog\/15-awsome-years-of-amazon-ec2-and-still-going-strong\/\" target=\"_blank\" rel=\"noreferrer noopener\">EC2<\/a> allows users to launch and manage virtual machines (called instances) on demand, providing a flexible and scalable environment for running applications and workloads. EC2 instances can be tailored to meet various performance, storage, and networking requirements.<\/p>\n\n\n\n<h2>Hands-on<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"576\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18-1024x576.png\" alt=\"\" class=\"wp-image-2271\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18-1024x576.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18-300x169.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18-768x432.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18-1536x864.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18-1160x653.png 1160w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18-600x338.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-18.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3>AWS EC2<\/h3>\n\n\n\n<p>We will start by creating an EC2 instance. Click on the search bar and search for EC2.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"517\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-14-1024x517.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2267\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-14-1024x517.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-14-300x151.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-14-768x388.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-14-600x303.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-14.png 1248w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"541\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-17-1024x541.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2270\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-17-1024x541.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-17-300x158.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-17-768x406.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-17-1536x811.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-17-600x317.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-17.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Enter the application name.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"541\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-16-1024x541.png\" alt=\"\" class=\"wp-image-2269\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-16-1024x541.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-16-300x158.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-16-768x406.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-16-1536x811.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-16-600x317.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-16.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Choose Ubuntu OS AMI and also an instance type (advisable to select the free tier eligible).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"541\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-1024x541.png\" alt=\"\" class=\"wp-image-2273\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-1024x541.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-300x158.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-768x406.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-1536x811.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-600x317.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Select a login key pair from the existing one or create a new pair. This provides your instance with a public and private key which you can only view\/download once. Remember to save it somewhere.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"541\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-1024x541.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2272\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-1024x541.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-300x158.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-768x406.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-1536x811.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19-600x317.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-19.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">To login into your instance use the command <strong><code>ssh -i your-key-pair.pem ec2-user@your-instance-public-ip<\/code><\/strong>. You can do basic installations like docker. Also, ensure that you add your user to the docker group to avoid using <strong>sudo<\/strong> which may require password prompts. To achieve this, run the following commands:<\/p>\n\n\n\n<p><strong><code>sudo groupadd docker<\/code><\/strong><\/p>\n\n\n\n<p><strong><code>sudo usermod -aG docker $USER<\/code><\/strong><\/p>\n\n\n\n<h3>Code<\/h3>\n\n\n\n<p>The Dockerfile will appear as follows:<\/p>\n\n\n\n<p class=\"has-text-align-justify\">We are going to package our application to run on Ubuntu OS using Ubuntu as the base image. In the future, we might look at deploying smaller binaries since Rust is cross-platform.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"640\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-20-1024x640.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2274\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-20-1024x640.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-20-300x188.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-20-768x480.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-20-1536x960.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-20-600x375.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-20.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong><code>.github\/workflows\/main.yml(1):<\/code><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">In this GitHub Actions config file, we \u201ctell\u201d GitHub to trigger our workflow any time a push is done to the main or a pull request to the main is received.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"595\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-21-1024x595.png\" alt=\"\" class=\"wp-image-2275\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-21-1024x595.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-21-300x174.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-21-768x446.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-21-1536x893.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-21-600x349.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-21.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong><code>.github\/workflows\/main.yml(2):<\/code><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">In this section of the file, we deploy to our EC2 instance using SSH. To log in to our instance, we use either a password (not recommended) or using SSH private key(recommended). In this blog, we shall use passwords but in future blogs, we shall cover how to use securely connect using SSH private key.&nbsp;<\/p>\n\n\n\n<p class=\"has-text-align-justify\">In the script section, we run docker commands in the EC2 instance. First, we stop the running container by its name, next, remove the dangling container, remove\/prune any dangling images, pull the latest image, and run a new container with the provided name.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"639\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-24-1024x639.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2278\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-24-1024x639.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-24-300x187.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-24-768x479.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-24-1536x958.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-24-600x374.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-24.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In your GitHub repository, you are required to set all the required variables\/secrets that will be used by<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"593\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-23-1024x593.png\" alt=\"\" class=\"wp-image-2277\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-23-1024x593.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-23-300x174.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-23-768x445.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-23-1536x890.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-23-600x348.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-23.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">To enable SSH, we have to run the command <strong><code>ssh -i your-key-pair.pem ec2-user@your-instance-public-ip<\/code><\/strong> to login into your EC2 instance first, then type the following command <strong><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/strong>. This command will open the config file below. You can enable the values as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"593\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-22-1024x593.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2276\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-22-1024x593.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-22-300x174.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-22-768x445.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-22-1536x890.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-22-600x348.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-22.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can also enable password authentication as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"593\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-25-1024x593.png\" alt=\"\" class=\"wp-image-2279\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-25-1024x593.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-25-300x174.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-25-768x445.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-25-1536x890.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-25-600x348.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-25.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Once you have these settings configured, you can push your code and submit a Pull Request which will automatically start your deployment pipeline.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">All the steps should run successfully as shown below. In case the pipeline fails to run, please check that you have followed the above instructions to the latter or check if the <em>yml<\/em> file is valid syntax-wise.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"538\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-26-1024x538.png\" alt=\"\" class=\"wp-image-2280\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-26-1024x538.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-26-300x158.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-26-768x404.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-26-1536x807.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-26-600x315.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-26.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">As a good practice, you may split these steps into smaller jobs so that in case of a failure, you won\u2019t have to unnecessarily rerun all steps. After the deployment is complete, you can go back to the AWS EC2 console and access the public IP via your web browser.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"538\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-27-1024x538.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2281\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-27-1024x538.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-27-300x158.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-27-768x404.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-27-1536x807.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-27-600x315.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-27.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Click on the open address and remember to use HTTP instead of HTTPS unless you have configured an SSL certificate.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"538\" src=\"https:\/\/www.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-28-1024x538.png\" alt=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\" class=\"wp-image-2282\" srcset=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-28-1024x538.png 1024w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-28-300x158.png 300w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-28-768x404.png 768w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-28-1536x807.png 1536w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-28-600x315.png 600w, https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/image-28.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this blog, we looked at how we can deploy a Rocket Rust REST API to an AWS EC2 instance using GitHub Actions and Docker. In this blog, we used password authentication but in the future, we shall look at SSH private key authentication and why it is the more secure option. We will come up with more such use cases in our upcoming blogs.<\/p>\n\n\n\n<p><strong>Meanwhile\u2026<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">If you are a Rust &amp; EC2 Lover and want to explore more about the above topics, here are a few of our blogs for your reference:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-build-a-rust-webassembly-frontend-app-with-yew-framework\/\">How to Build a Rust WebAssembly Frontend App with Yew Framework?<\/a><\/li><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/aws-is-in-love-with-rust-and-you-should-be-too\/\">AWS is in love with RUST and you should be too!<\/a><\/li><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/15-awsome-years-of-amazon-ec2-and-still-going-strong\/\">15 AWSome years of Amazon EC2 and still going strong!<\/a><\/li><\/ul>\n\n\n\n<p>Stay tuned to get all the updates about our upcoming blogs on the cloud and the latest technologies.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Keep Exploring -> Keep Learning -> Keep Mastering\u00a0<\/strong><br>At <a href=\"https:\/\/www.workfall.com\/\">Workfall<\/a>, we strive to provide the best tech and pay opportunities to kickass coders around the world. If you\u2019re looking to work with global clients, build cutting-edge products, and make big bucks doing so, give it a shot at <a href=\"https:\/\/www.workfall.com\/partner\/\">workfall.com\/partner<\/a> today!<\/p>\n\n\n<style type=\"text\/css\"><\/style><section id='' \n                class='helpie-faq accordions faq-toggle open-first groupSettings-497__enabled' \n                data-collection='' \n                data-pagination='0' \n                data-search='0' \n                data-pagination-enabled='0'\n                role='region'\n                aria-label='FAQ Section'\n                aria-live='polite'><h3 class=\"collection-title\">Frequently Asked Questions:<\/h3><article class=\"accordion \"><div class='helpie-faq-row'><div class='helpie-faq-col helpie-faq-col-12' ><ul><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2775\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2775\"\r\n                data-id=\"post-2775\" \r\n                data-item=\"hfaq-post-2775\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q: What is Rocket in Rust, and why use it for REST APIs?<\/div><\/div><div id=\"accordion-content-post-2775\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2775\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>A:<\/strong> Rocket is a web framework for Rust that makes creating REST endpoints more ergonomic. The tutorial uses it to build a REST API and then deploys that API reliably. Using Rust + Rocket ensures performance, type safety, and minimal overhead.<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2776\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2776\"\r\n                data-id=\"post-2776\" \r\n                data-item=\"hfaq-post-2776\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q: Why containerize with Docker before deploying to EC2?<\/div><\/div><div id=\"accordion-content-post-2776\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2776\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>\u00a0A:<\/strong> Docker helps package the application with all its dependencies so that it runs the same way across environments. It simplifies deployment to servers like EC2 and avoids \u201cit works on my machine\u201d problems.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2777\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2777\"\r\n                data-id=\"post-2777\" \r\n                data-item=\"hfaq-post-2777\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q: How are GitHub Actions used in this flow?<\/div><\/div><div id=\"accordion-content-post-2777\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2777\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>\u00a0A:<\/strong> The blog shows using GitHub Actions CI\/CD pipelines so that when code is pushed to main (or PRs), Docker image is built, then deployed to the EC2 instance via SSH (or similar). This automates shipping new versions.<\/span><span style=\"font-weight: 400\"><br \/>\n<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2778\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2778\"\r\n                data-id=\"post-2778\" \r\n                data-item=\"hfaq-post-2778\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q: What initial setup is required on the AWS EC2 instance?<\/div><\/div><div id=\"accordion-content-post-2778\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2778\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>A:<\/strong> The steps include launching an EC2 instance (Ubuntu OS), installing Docker, adding your user to the Docker group so you can run Docker without sudo, and configuring the server (e.g. SSH access with a key or password).<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2779\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2779\"\r\n                data-id=\"post-2779\" \r\n                data-item=\"hfaq-post-2779\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q: What are the security considerations in this deployment?<\/div><\/div><div id=\"accordion-content-post-2779\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2779\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>\u00a0A:<\/strong> Some include: using SSH via keys rather than weak password auth, ensuring only necessary ports are open, handling secrets (e.g. in GitHub Actions), and likely using least privilege access. The blog mentions they used password auth but plan to look at SSH key auth for better security.<\/span><\/p>\n<\/div><\/li><\/ul><\/div><\/div><\/article><\/section>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> When Rust compiles code, you get an executable if you created the application using the &#8211;bin command. In this blog, we shall look at how we can create a Dockerfile to create an image with this executable. We shall then deploy this image on EC2 using GitHub Actions which will be set on our repository [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2283,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[288],"tags":[3,7,201,15,11,13,262,418,359,202,6],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions - The Workfall Blog<\/title>\n<meta name=\"description\" content=\"EC2 allows users to launch and manage virtual machines on demand, providing a flexible and scalable environment for running applications.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions - The Workfall Blog\" \/>\n<meta property=\"og:description\" content=\"EC2 allows users to launch and manage virtual machines on demand, providing a flexible and scalable environment for running applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/\" \/>\n<meta property=\"og:site_name\" content=\"The Workfall Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/workfall\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-16T10:44:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-17T04:16:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@workfall\" \/>\n<meta name=\"twitter:site\" content=\"@workfall\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Workfall\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\",\"name\":\"Workfall - Hire #Kickass Coders On Demand\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/workfall\/\",\"https:\/\/www.linkedin.com\/company\/workfall\/\",\"https:\/\/facebook.com\/workfall\",\"https:\/\/twitter.com\/workfall\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"contentUrl\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"width\":400,\"height\":400,\"caption\":\"Workfall - Hire #Kickass Coders On Demand\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"name\":\"The Workfall Blog\",\"description\":\"#Tech #Remote #Jobs\",\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#primaryimage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png\",\"width\":1200,\"height\":628,\"caption\":\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#webpage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/\",\"name\":\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions - The Workfall Blog\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#primaryimage\"},\"datePublished\":\"2023-05-16T10:44:37+00:00\",\"dateModified\":\"2025-09-17T04:16:35+00:00\",\"description\":\"EC2 allows users to launch and manage virtual machines on demand, providing a flexible and scalable environment for running applications.\",\"breadcrumb\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learning.workfall.com\/learning\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#webpage\"},\"author\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\"},\"headline\":\"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions\",\"datePublished\":\"2023-05-16T10:44:37+00:00\",\"dateModified\":\"2025-09-17T04:16:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#webpage\"},\"wordCount\":940,\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png\",\"keywords\":[\"AWS\",\"AWS EC2\",\"AWS Rust\",\"docker\",\"ec2\",\"ec2instance\",\"github\",\"Rocket REST API\",\"rust\",\"Rust Programming\",\"workfall\"],\"articleSection\":[\"Backend Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\",\"name\":\"Workfall\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"caption\":\"Workfall\"},\"sameAs\":[\"https:\/\/www.workfall.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions - The Workfall Blog","description":"EC2 allows users to launch and manage virtual machines on demand, providing a flexible and scalable environment for running applications.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/","og_locale":"en_US","og_type":"article","og_title":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions - The Workfall Blog","og_description":"EC2 allows users to launch and manage virtual machines on demand, providing a flexible and scalable environment for running applications.","og_url":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/","og_site_name":"The Workfall Blog","article_publisher":"https:\/\/facebook.com\/workfall","article_published_time":"2023-05-16T10:44:37+00:00","article_modified_time":"2025-09-17T04:16:35+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@workfall","twitter_site":"@workfall","twitter_misc":{"Written by":"Workfall","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization","name":"Workfall - Hire #Kickass Coders On Demand","url":"https:\/\/learning.workfall.com\/learning\/blog\/","sameAs":["https:\/\/www.instagram.com\/workfall\/","https:\/\/www.linkedin.com\/company\/workfall\/","https:\/\/facebook.com\/workfall","https:\/\/twitter.com\/workfall"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","contentUrl":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","width":400,"height":400,"caption":"Workfall - Hire #Kickass Coders On Demand"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website","url":"https:\/\/learning.workfall.com\/learning\/blog\/","name":"The Workfall Blog","description":"#Tech #Remote #Jobs","publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#primaryimage","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png","width":1200,"height":628,"caption":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions"},{"@type":"WebPage","@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#webpage","url":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/","name":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions - The Workfall Blog","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#primaryimage"},"datePublished":"2023-05-16T10:44:37+00:00","dateModified":"2025-09-17T04:16:35+00:00","description":"EC2 allows users to launch and manage virtual machines on demand, providing a flexible and scalable environment for running applications.","breadcrumb":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learning.workfall.com\/learning\/blog\/"},{"@type":"ListItem","position":2,"name":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions"}]},{"@type":"Article","@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#article","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#webpage"},"author":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a"},"headline":"Deploying a Rust Rocket REST API on AWS EC2 with Docker and GitHub Actions","datePublished":"2023-05-16T10:44:37+00:00","dateModified":"2025-09-17T04:16:35+00:00","mainEntityOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#webpage"},"wordCount":940,"publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/deploying-a-rust-rocket-rest-api-on-aws-ec2-with-docker-and-github-actions\/#primaryimage"},"thumbnailUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png","keywords":["AWS","AWS EC2","AWS Rust","docker","ec2","ec2instance","github","Rocket REST API","rust","Rust Programming","workfall"],"articleSection":["Backend Development"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a","name":"Workfall","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","caption":"Workfall"},"sameAs":["https:\/\/www.workfall.com"]}]}},"jetpack_featured_media_url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-1.png","jetpack-related-posts":[{"id":2167,"url":"https:\/\/learning.workfall.com\/learning\/blog\/deploy-a-yew-rust-application-on-an-aws-ec2-ubuntu-instance-nginx\/","url_meta":{"origin":2266,"position":0},"title":"Deploy a Yew Rust Application on an AWS EC2 Ubuntu Instance & Nginx","date":"May 4, 2023","format":false,"excerpt":"After you've finished developing your Yew Rust application, it's time to make it available to your users. It is expected to be placed on a server someplace, either on a Cloud service provider or an on-premises server, for this purpose. This blog will go over how to launch your Yew\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"Deploy a Yew Rust Application on an AWS EC2 Ubuntu Instance & Nginx","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":215,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-containers-on-amazon-ec2-instance\/","url_meta":{"origin":2266,"position":1},"title":"How to install and run Docker Containers on Amazon EC2 Instance?","date":"October 27, 2021","format":false,"excerpt":"While running Docker on AWS, developers and admins can build, ship, and run highly reliable distributed applications at any scale.\u00a0\u00a0In this blog, we will demonstrate how to install, build and run docker containers on Amazon EC2 instances. Refer to Part 1 of the blog here: How To Install And Run\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Insrall and Run Docker on Amazon EC2 - Workfall","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/docker.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2287,"url":"https:\/\/learning.workfall.com\/learning\/blog\/reverse-proxy-mastery-deploying-a-full-stack-application-with-multi-container-docker-and-nginx\/","url_meta":{"origin":2266,"position":2},"title":"Reverse Proxy Mastery: Deploying a Full-Stack Application with Multi-Container Docker and Nginx","date":"May 23, 2023","format":false,"excerpt":"Sometimes, developing a full-stack application is not the end of the journey for a web developer. Let us take a case scenario whereby, you have a backend, a frontend, and also a database. For such a setup, we would like to make it easy to replicate our application in different\u2026","rel":"","context":"In &quot;Frontend Development&quot;","img":{"alt_text":"Reverse Proxy Mastery: Deploying a Full-Stack Application with Multi-Container Docker and Nginx","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":125,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-train-a-deep-learning-model-with-aws-deep-learning-containers-on-amazon-ec2\/","url_meta":{"origin":2266,"position":3},"title":"How to train a Deep Learning model with AWS Deep Learning Containers on Amazon EC2?","date":"October 26, 2021","format":false,"excerpt":"Data scientists, machine learning engineers, and practitioners must devote significant time and resources to developing, testing, updating, and optimizing Docker images for deep learning. Instead of concentrating on developing and enhancing models, practitioners are forced to divert valuable resources to unrelated tasks. Installing packages, resolving compatibility concerns, performance optimization, and\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Train a Deep Learning model with AWS Deep Learning Containers on Amazon EC2","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/CoverImages_1200x628px-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":399,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-and-mount-an-amazon-efs-file-system-using-amazon-ec2-launch-instance-wizard\/","url_meta":{"origin":2266,"position":4},"title":"How to create and mount an Amazon EFS file system using Amazon EC2 Launch Instance Wizard?","date":"November 3, 2021","format":false,"excerpt":"Sizing, configuring, and deploying AWS resources for third-party applications, such as SAP or SQL server is always challenging for you. Are you looking for a wizard who can help you with these challenging tasks?\u00a0 AWS Launch Wizard can help you in simplifying these tasks by offering a guided way of\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"How to create and mount an Amazon EFS file system using Amazon EC2 Launch Instance Wizard","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/Launch-Wizard.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":635,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-install-and-run-docker-container-on-amazon-ec2-instance-part-1\/","url_meta":{"origin":2266,"position":5},"title":"How to install and run Docker Container on Amazon EC2 Instance (Part 1)?","date":"November 11, 2021","format":false,"excerpt":"The fast rise in interest and use of container-based solutions has necessitated the development of industry standards for container technology and the packaging of software code. Docker is currently one of the most well-known and widely utilized container engines on the market. Docker was launched in 2013 by a company\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Running Docker on Amazon EC2","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/CoverImages_1200x628px-4.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/2266"}],"collection":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/comments?post=2266"}],"version-history":[{"count":4,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/2266\/revisions"}],"predecessor-version":[{"id":2782,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/2266\/revisions\/2782"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media\/2283"}],"wp:attachment":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media?parent=2266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/categories?post=2266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/tags?post=2266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}