SimpleApp — Containerization
Previous part, we added KrakenD API gateway templates. You can see it from here.
What is containerization?
A containerization is a form of virtualization where applications run in isolated user spaces, called containers while using the same shared operating system (OS)
Create Dockerfile in the root path.
FROM golang:1.16.3 AS builder
WORKDIR /opt
COPY . .
RUN go mod download
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main
FROM alpine:3.7
WORKDIR /app
COPY --from=builder /opt/configs/config.dev.yaml /app/
COPY --from=builder /opt/main /app/main
WORKDIR /app
ENTRYPOINT ["/app/main"]Update config.dev.yaml
Get Akın IŞIK’s stories in your inbox
Join Medium for free to get updates from this writer.
Note: I use windows so if I want to use my local network on docker, I need to use host.docker.internal instead of localhost.
docker build -t simpleapp .When the build succeeds run the following commands respectively.
docker run -d -p 5001:5001 simpleapp productapi --config "./config.dev.yaml"docker run -d -p 5000:5000 simpleapp categoryapi --config "./config.dev.yaml"
You will see our applications is running on docker.
categoryapi: port:5000
productapi: port:5001
When I go to localhsot:5000/all, I saw all categories which I added.
Next part, we’ll deploy applications to Kubernetes.











