DEV Community

Marcus Rådell
Marcus Rådell

Posted on

Mother D*cker!

If you want to use containers to deploy something to the cloud, here's a simple way to get started without feeling like a sinking ship.

0 Build your code outside of a container

You first need to find out how to build your code. You might generate a .dll, .jar, or a folder of .js files.

1 Copy the code into a container image

Find a good base image to use to run your code.
Copy the built content into your container.
Expose the right port for your web server.
Set the command that starts the web server.

Here's a Dockerfile example for C# .NET v7:

FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY published/ ./

EXPOSE 5182

ENTRYPOINT ["dotnet", "LabApi.dll"]
Enter fullscreen mode Exit fullscreen mode

This will work across architectures for many languages, but not all. If it doesn't work locally, then it can still work in your CI/CD of choice, like GitHub Actions. And that's the only thing you need to get started!

Top comments (0)