Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
zarnoevic committed Mar 6, 2024
1 parent 6a736b4 commit 5da39e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This allows for a scalable deployment of the services, as they can be run in par
Run the following command to start the service:

```shell
sudo docker-compose -f docker/rabbitClient.docker-compose.yaml --env-file .env up -d
docker-compose -f rabbitClient.docker-compose.yaml --env-file .env up -d
```

### Running the Client
Expand All @@ -53,15 +53,22 @@ Run the following command to start the Client on your machine:
go run src/cmd/client/main.go
```

#### With Docker

```shell
docker build -t client -f client.Dockerfile .
docker run --network="host" --env-file .env client
```

#### Scaling the Client

Run the following command to start the Client in a scalable way with docker compose:
Run the following command to start the Server in a scalable way with docker compose:

```shell
docker-compose -f docker/client.docker-compose.yaml --scale client=2 --env-file .env up -d
docker-compose -f client.docker-compose.yaml --env-file .env up -d --scale client=4
```

Change the `--scale client=2` parameter to any number of clients you'd want to run in parallel.
Change the `--scale client=4` parameter to any number of clients you'd want to run in parallel.

### Running the Server

Expand All @@ -85,10 +92,10 @@ docker run --network="host" --env-file .env server
Run the following command to start the Server in a scalable way with docker compose:

```shell
docker-compose -f server.docker-compose.yaml --env-file .env up -d --scale server=3
docker-compose -f server.docker-compose.yaml --env-file .env up -d --scale server=4
```

Change the `--scale server=3` parameter to any number of clients you'd want to run in parallel.
Change the `--scale server=4` parameter to any number of clients you'd want to run in parallel.

## File structure

Expand Down
14 changes: 4 additions & 10 deletions client.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ FROM --platform=linux/amd64 golang:1.22 as builder

WORKDIR /app

ADD docker /app
COPY . .

RUN go mod tidy && go build -o client_exec ./src/cmd/client/

FROM --platform=linux/amd64 alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /root/

COPY --from=builder /app/client_exec .
RUN go mod download
RUN go mod tidy
RUN go build -o client_exec ./src/cmd/client/

CMD ["./client_exec"]
3 changes: 2 additions & 1 deletion client.docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ version: '3.8'
services:
client:
build:
context: docker
context: .
dockerfile: client.Dockerfile
environment:
RABBITMQ_USER: ${RABBITMQ_USER}
RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}
RABBITMQ_AMQP_PORT: ${RABBITMQ_AMQP_PORT}
RABBITMQ_AMQP_HOST: ${RABBITMQ_AMQP_HOST}
COMMANDS_PATH: ${COMMANDS_PATH}
network_mode: host
volumes:
- ./resources:/resources

0 comments on commit 5da39e6

Please sign in to comment.