Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add README.md (how to run) for Chat Sample #2104

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions samples/ChatSample/ChatSample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
# Build stage
##################################################

FROM mcr.microsoft.com/dotnet/core/sdk:8.0
FROM mcr.microsoft.com/dotnet/sdk:8.0

COPY ./ /home/signalr-src

WORKDIR /home/signalr-src/samples/ChatSample/ChatSample
RUN dotnet build && \
dotnet publish -r ubuntu.16.04-x64 -c Release -o /home/build/
dotnet publish -r linux-x64 -c Release -o /home/build/

##################################################
# Final stage
##################################################

FROM mcr.microsoft.com/dotnet/core/runtime:8.0
FROM mcr.microsoft.com/dotnet/aspnet:8.0

COPY --from=0 /home/build/ /home/SignalR

WORKDIR /home/SignalR

EXPOSE 5050

CMD ["./ChatSample"]
CMD ["./ChatSample", "--urls", "http://0.0.0.0:5050"]
80 changes: 80 additions & 0 deletions samples/ChatSample/ChatSample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Azure SignalR Service Chat Sample

This sample demonstrates how to use Azure SignalR Service with ASP.NET Core SignalR.

## Prerequisites

- .NET 8.0 SDK or later
- An Azure SignalR Service instance
- Git (for submodule dependencies)
- Docker (optional, for containerized deployment)

## Setup

1. Initialize the required submodules:

```bash
git submodule update --init --recursive
```

2. Configure your Azure SignalR Service connection string:

- Update `appsettings.json` by replacing the empty connection string:

```json
{
"Azure": {
"SignalR": {
"ConnectionString": "<your-connection-string>"
}
}
}
```

⚠️ **Important**: Make sure to set your connection string before building the Docker image or running the application.

## Running the Sample

### Option 1: Running Locally

1. Build and run the project:

```bash
dotnet build
dotnet run
```

You can also specify a custom port:

```bash
dotnet run --urls="http://localhost:5050"
```

### Option 2: Running with Docker

1. Build the Docker image:
```bash
docker build -t chat-app -f samples/ChatSample/ChatSample/Dockerfile .
```

2. Run the container:
```bash
docker run -d -p 5050:5050 chat-app
```

Additional Docker commands:
```bash
# View running containers
docker ps

# View container logs
docker logs <container_id>

# Stop the container
docker stop <container_id>
```

## Accessing the Application

To access the chat application, open your web browser and navigate to:
- `http://localhost:5050` (or the custom port you specified)
Loading