liveBook · Manning

Cloud-native architecture

As explained in Go in Practice, Second Edition

A cloud-native application is software designed to exploit programmatic cloud infrastructure for on-demand scaling, failure recovery, and composition from distributed services.

Cloud-native architecture uses programmatic cloud infrastructure to scale applications with additional instances, recover from failures, and combine distributed services into larger systems. Containers provide a fast-starting deployment model that shares the host kernel while isolating applications from one another. section 12.1.2

A practical cloud-native deployment emphasizes:

  • Containerizing applications so deployment abstracts away many bare-metal details. section 12.1.2
  • Scaling with additional instances when demand requires it. section 12.1.2
  • Correcting failures so that many infrastructure problems remain invisible to end users. section 12.1.2
  • Generalizing infrastructure assumptions so applications remain easier to develop, test locally, and operate across environments. section 12.0 section 12.4

Multistage Go container build

Compile the Go application inside a build stage based on golang:1.22, copy the resulting binary into a separate ubuntu:mantic runtime stage, and start it with CMD. This lets Docker cache build steps and reduces transferred data. Multiple Dockerfiles can also support init or sidecar processes in a clustering environment such as Kubernetes. section 12.1.2

Figure 12.2 Comparing containers to VMs
figure

Compare containers with virtual machines to see how kernel sharing, isolation, resource assignment, and startup behavior differ. section 12.1.2

Listing 12.1 A simple multistage Docker build for Go
FROM golang:1.22 as build

RUN useradd --create-home --shell /bin/bash appbuild  #1
RUN mkdir /home/appbuild/bin
COPY * /home/appbuild  #2

WORKDIR /home/appbuild
RUN go build -o /home/appbuild/bin/app /var/appbuild/
main.go  #3

FROM ubuntu:mantic
RUN useradd --create-home --shell /bin/bash apprun

COPY --from=build /home/appbuild/bin/app /home/apprun  #4
CMD ["/home/apprun/app"]  #5

Inspect a complete multistage Dockerfile showing Go compilation, artifact transfer, runtime-user creation, and container startup. section 12.1.2

How Go in Practice, Second Edition covers it

How deep it goes
Explains container and virtual-machine differences and demonstrates a multistage build, while deferring clustered multi-container interactions.
Examples
Uses a container-versus-VM comparison and a Go multistage Dockerfile targeting separate build and runtime images.
What it assumes
Assumes application-development knowledge but teaches container fundamentals, deployment isolation, and unknown-environment pitfalls.
What you can do after
Build it from scratch by compiling Go inside a multistage Docker image and prepare applications for variable cloud environments.
How it connects
Connects containers, virtual machines, microservices, Docker, Kubernetes, cross-compilation, and cloud-environment detection.

Also explained in

Compare how 6 books explain cloud-native architecture →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Practice, Second Edition. The section links point to the parts of the book it draws on.