You've already forked microservices
mirror of
https://github.com/ebosas/microservices.git
synced 2025-06-24 22:26:56 +02:00
updates to readme, dockerfiles
This commit is contained in:
44
README.md
44
README.md
@ -1,2 +1,42 @@
|
||||
# Microservices with Go and RabbitMQ
|
||||
As well as Docker, PostgreSQL, WebSocket and React.
|
||||
# Microservices
|
||||
|
||||
A basic example of microservice architecture which demonstrates communication between a few loosely coupled services. This includes messages between a server terminal and a web user interface with a database service in the middle.
|
||||
|
||||
Written in Go, this mainly showcases the exchange of information using RabbitMQ—between backend services—and WebSocket—between frontend and backend.
|
||||
|
||||
The services are built using Docker which includes a multistage build example. The whole application is served with Docker Compose.
|
||||
|
||||
## Running the code
|
||||
|
||||
To run the example, clone the Github repository and start the services with Docker Compose. Once Docker finishes downloading and building images, the front end is accessible by visiting `localhost:8080` in a browser.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/ebosas/microservices
|
||||
cd microservices
|
||||
```
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
### Back end
|
||||
|
||||
To access the back end service, attach to its docker container from a separate terminal window. Messages from the front end will show up here. Also, standart input from this service is sent to the front end to have communication both ways.
|
||||
|
||||
```bash
|
||||
docker attach microservices_backend
|
||||
```
|
||||
|
||||
### Database
|
||||
|
||||
To inspect the database, launch a new container that will connect to our Postgres database. Then enter the password `demopsw` (see the `.env` file).
|
||||
|
||||
```bash
|
||||
docker run -it --rm --network microservices_network postgres:13-alpine psql -h postgres -U postgres
|
||||
```
|
||||
|
||||
Select everything from the messages table:
|
||||
|
||||
```sql
|
||||
\c microservices
|
||||
select * from messages;
|
||||
```
|
||||
|
@ -1,4 +1,3 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
rabbitmq:
|
||||
image: "rabbitmq:3-management-alpine"
|
||||
@ -27,20 +26,10 @@ services:
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
|
||||
psql:
|
||||
image: "postgres:13-alpine"
|
||||
stdin_open: true
|
||||
tty: true
|
||||
command: ["psql", "-h", "postgres", "-U", "postgres"]
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
server:
|
||||
# container_name: server
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.server
|
||||
dockerfile: server.Dockerfile
|
||||
ports:
|
||||
- 8080:8080
|
||||
env_file:
|
||||
@ -51,9 +40,10 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
backend:
|
||||
container_name: microservices_backend
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.backend
|
||||
dockerfile: backend.Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
stdin_open: true
|
||||
@ -65,7 +55,7 @@ services:
|
||||
database:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.database
|
||||
dockerfile: database.Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
@ -73,3 +63,7 @@ services:
|
||||
condition: service_healthy
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: microservices_network
|
||||
|
Reference in New Issue
Block a user