You can also see that we can use the environment variables defined in the docker-compose file for our pg_isready function. If that’s not the case, we wait two seconds and check the status of the server again. Inside the loop, we check if the Postgres server is already running. This is why we need to wait until our Postgres server starts via pg_isready - I’ll explain later how we can install it. You might ask yourself: We already defined the Postgres container as a dependency of our Phoenix container, so why do we need to wait? Yes, docker-compose will wait until the Postgres container has started, but this doesn’t mean that the Postgres server inside the container is already running. We now create our own Dockerfile in our Elixir root directory: The Elixir image itself uses an Erlang image as its base and extends it by installing the required Elixir dependencies. For our Elixir project, we can use the official Elixir Docker image as our base image. You can create your own images and start from a clean Linux distribution of your choice and install all required packages on your own, or you can use predefined images from Docker Hub. DockerfileĪ container is an instance of a Docker image. To get started with Docker, you first need to install it for your environment. Getting Startedįor the purpose of this post, I’ll assume you already have a Phoenix project that you now want to run within a Docker container. This not only makes it possible to run many more containers on a single machine compared to virtual machines, but there’s the added benefit that containers start instantly. ![]() A container is like a virtual machine, but while the virtual machine actually runs its own OS, a container can reuse the underlying Linux kernel while still running completely isolated from its surroundings. What Is Docker?ĭocker makes it possible to package your application and use it in development and production by running it in a container. For simplicity’s sake, we’ll use the Phoenix framework to serve a website from the Docker container. This is useful if you’re developing an API that your app developers are using: They don’t need to install Elixir rather, they can install Docker and run your container. In this blog post, I’ll explain how you can run your Elixir application inside Docker. We obviously don’t want them to have to install and maintain Elixir and other dependencies on their server, so we decided to go with Docker, which is software that provides an additional layer of abstraction of operating-system-level virtualization. It was clear from the beginning that our customers wanted to host PSPDFKit Server within their existing infrastructure to retain complete control over their data. ![]() ![]() PSPDFKit Server is written completely in Elixir, and it delivers magical real-time collaboration features to our Instant component. At PSPDFKit, we invested in Elixir very early.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |