Containing the Server

Now that your API server is ready, you can run it on your Raspberry Pi. Because Go is a compiled language, you could compile and run it di2ctly on the operating system. However, to increase the deployment flexibility, let’s package the API server into an application container. A container allows you to package an application with all of its dependencies, and to run them in isolation from other system processes. By doing this, you can run multiple instances of your application, or other applications on the same machine, even if they have conflicting dependencies or requirements, such as TCP ports.

Running the application as a container also allows you to take advantage of some features the Docker container engine provides. ...

Get Automate Your Home Using Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.