Skip to content
Open
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
31 changes: 31 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Directories
**/bin
**/obj
**/out
**/TestResults
**/.vs
**/.vscode
.git
.github
.gitignore
.gitmodules

# Files
**/*.md
**/*.log
**/*.user
**/*.suo
**/*.userprefs
**/.DS_Store
**/Thumbs.db

# Exclude non-C# language folders
cpp/
python/
rust/
Settings/

# Keep only necessary files for build
!csharp/
!Dockerfile
!docker-compose.yml
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Use the .NET 6 SDK for building
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app

# Copy solution and project files
COPY csharp/Platform.Data.Doublets.Gql.sln ./
COPY csharp/Platform.Data.Doublets.Gql.Schema/Platform.Data.Doublets.Gql.Schema.csproj ./Platform.Data.Doublets.Gql.Schema/
COPY csharp/Platform.Data.Doublets.Gql.Server/Platform.Data.Doublets.Gql.Server.csproj ./Platform.Data.Doublets.Gql.Server/
COPY csharp/Platform.Data.Doublets.Gql.Tests/Platform.Data.Doublets.Gql.Tests.csproj ./Platform.Data.Doublets.Gql.Tests/

# Restore packages
RUN dotnet restore

# Copy source code
COPY csharp/ ./

# Build and publish the application
RUN dotnet publish Platform.Data.Doublets.Gql.Server/Platform.Data.Doublets.Gql.Server.csproj -c Release -o out --no-restore

# Use the .NET 6 runtime for the final image
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
WORKDIR /app

# Copy the published application
COPY --from=build /app/out .

# Create directory for database files
RUN mkdir -p /app/data

# Set environment variables
ENV ASPNETCORE_URLS=http://+:80
ENV ASPNETCORE_ENVIRONMENT=Production

# Expose port 80
EXPOSE 80

# Run the application with the database path in the data volume
ENTRYPOINT ["dotnet", "Platform.Data.Doublets.Gql.Server.dll", "/app/data/db.links"]
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ http://linksplatform.ddns.net:29018/v1/graphql

## Start locally

### Option 1: Using Docker (Recommended)

The easiest way to run the GQL server is using Docker:

```bash
# Build and run with docker-compose
docker-compose up -d

# Or build and run manually
docker build -t doublets-gql .
docker run -p 29018:80 -v $(pwd)/data:/app/data doublets-gql
```

Navigate to:
* http://localhost:29018/ui/playground
* http://localhost:29018/ui/graphiql
* http://localhost:29018/ui/altair
* http://localhost:29018/ui/voyager

Or make request at:
http://localhost:29018/v1/graphql

The database file will be stored in the `./data` directory on your host machine.

### Option 2: Using .NET directly

Execute:
```
cd csharp/Platform.Data.Doublets.Gql.Server
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.8'

services:
gql-server:
build: .
ports:
- "29018:80"
volumes:
- ./data:/app/data
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:80
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/ui/playground"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s