Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
A Developer's Essential Guide to Docker Compose

You're reading from   A Developer's Essential Guide to Docker Compose Simplify the development and orchestration of multi-container applications

Arrow left icon
Product type Paperback
Published in Oct 2022
Publisher Packt
ISBN-13 9781803234366
Length 264 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Emmanouil Gkatziouras Emmanouil Gkatziouras
Author Profile Icon Emmanouil Gkatziouras
Emmanouil Gkatziouras
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Part 1: Docker Compose 101
2. Chapter 1: Introduction to Docker Compose FREE CHAPTER 3. Chapter 2: Running the First Application Using Compose 4. Chapter 3: Network and Volumes Fundamentals 5. Chapter 4: Executing Docker Compose Commands 6. Part 2: Daily Development with Docker Compose
7. Chapter 5: Connecting Microservices 8. Chapter 6: Monitoring Services with Prometheus 9. Chapter 7: Combining Compose Files 10. Chapter 8: Simulating Production Locally 11. Chapter 9: Creating Advanced CI/CD Tasks 12. Part 3: Deployment with Docker Compose
13. Chapter 10: Deploying Docker Compose Using Remote Hosts 14. Chapter 11: Deploying Docker Compose to AWS 15. Chapter 12: Deploying Docker Compose to Azure 16. Chapter 13: Migrating to Kubernetes Configuration Using Compose 17. Index 18. Other Books You May Enjoy

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:

  1. Adding a Dockerfile
  2. 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: 
  ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime