Adding a location service to Compose
We have implemented the service and have been able to add locations and execute spatial queries. The next step is to package the application using Docker and run it through Compose.
The first step is to create the Dockerfile. The same steps we followed in the previous chapter also apply here:
- Adding a Dockerfile
- Building the image using Compose
This is the Dockerfile for the location service:
# syntax=docker/dockerfile:1 FROM golang:1.17-alpine RUN apk add curl WORKDIR /app COPY go.mod ./ COPY go.sum ./ RUN go mod download COPY *.go ./ RUN go build -o /location_service EXPOSE 8080 CMD [ "/location_service" ]
The Dockerfile is in place, and we can now proceed to run it through Compose. Now, to test the application, we need Redis and the image of the application to be built.
Our docker-compose.yaml
, at this stage, should look like this:
services: location-service: ...