DEV Community

Cover image for Seamless Docker Container Deployment on AWS Using Amazon Copilot
Rafa Rafael
Rafa Rafael

Posted on

Seamless Docker Container Deployment on AWS Using Amazon Copilot

I was developing a project built with FastAPI and Langchain. As I progressed, I needed to create a demo of the application and share it, allowing others to easily test its functionality. To fulfill this requirement, I decided to deploy it to the cloud.

Given that my projects were already containerized using Docker, I sought a solution that would facilitate this process, and thus I opted for AWS as the provider to effortlessly attain my goal.

Before we dive into the Docker deploying extravaganza, let’s make sure you’ve got the essentials lined up — think of it as gathering the ingredients before a culinary masterpiece, but with fewer spills and more tech wizardry.

Prerequisites:

  1. .Dockerfile that contains your image composition
  2. Amazon Acount
  3. Non root User with AdministratorAccess
  4. Amazon CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
  5. Amazon Copilot: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Copilot.html

Then hopped onto the amazon copilot train (think of it as the gcloud deploy’s cool cousin) — it’s like having a personal assistant for your Docker escapades. From crafting your container masterpiece to chauffeuring it into ECR, conjuring up ECS clusters and tasks, and even sorting out roles and infrastructure, it’s a magical ride!

Alright, let’s kick off this tech tango! Imagine we’re about to embark on a digital adventure — one where Docker containers frolic and AWS plays host. Buckle up, because things are about to get geeky-fun!

Set the stage for AWS enchantment with your very own credentials configuration.

Before you start, ensure you have your access keys readily available, as they will be requested in the configuration process.

Skip this part if you’re already strutting around with a non-root alter ego. But if you’re like, ‘What’s an Access Key, and do I need a secret map to find it?’ — then read on, my friend!

  1. In the search bar type IAM and under Services choose IAM
  2. Under IAM resource click the number on the Users column
  3. On the upper right, click Add User button
  4. Fill up the necessary fields. And don’t forget to assign a group policy.
  5. After being redirected to users list, click the new user’s name
  6. Click the Security Credentials tab
  7. Scroll down and under the Access keys card, click Create access key button
  8. Under Use case, choose Command Line Interface (CLI) and click next 9 And click Create access key

Subsequently, execute the command aws configure to initiate the process, during which you’ll be prompted to provide the credentials individually.

Harness the enchanting capabilities of ECS Copilot!

Within the confines of your project directory, initiate the command-line interface and execute the subsequent commands.

  1. Now, let’s summon the Amazon Copilot wizard with a swift copilot init command — it’s like giving your project a backstage pass to the cloud party! 🎩🪄
  2. Time to work some more Amazon Copilot magic! 🧙‍♂️ Just type copilot env init and watch as it conjures up an environment like a chef pulling a rabbit out of a hat. Voila! 🐇✨ Your app’s new playground is just a command away!
  3. Get ready to hit the launch button on your digital rocket ship! 🚀 Type in copilot env deploy — name your_app_name and watch as Amzon Copilot sprinkles its fairy dust over your app, sending it soaring into the cloud like a majestic unicorn with a jetpack! 🦄💨✨
  4. It’s showtime, folks! 🎉 Cue the confetti cannons by entering the legendary copilot deploy command. Think of it as your app’s grand entrance on the cloud’s red carpet — complete with virtual paparazzi and applause from servers! 🌟🎤🌐

And just like that, a little victory dance from your screen — a success message that reads something like the digital version of a high-five! 🎉🙌And you will see a success message like below:

✔ Deployed service chat-gpt-test-service.
Recommended follow-up action:
  - You can access your service at http://your-app.us-east-2.elb.amazonaws.com over the internet.
Enter fullscreen mode Exit fullscreen mode

So there you have it, your journey from Docker dreams to cloud reality is complete! Now you’re armed with the power to effortlessly deploy Docker containers on AWS like a tech-savvy sorcerer. Whether your app’s a world-changer or just a digital playground, remember, with a little Amazon Copilot guidance and a sprinkle of humor, the cloud’s the limit! Happy coding! 🚀🌩️🌟

Enjoy

Top comments (0)