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
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





