mirror of
https://github.com/arkorty/Osborne.git
synced 2026-03-17 16:51:44 +00:00
init
This commit is contained in:
2
server/.gitignore
vendored
Normal file
2
server/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.db
|
||||
uploads/
|
||||
30
server/Dockerfile
Normal file
30
server/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
||||
# Stage 1: Build the Go binary
|
||||
FROM golang:alpine AS builder
|
||||
|
||||
# Set up dependencies and install SQLite development files
|
||||
RUN apk add --no-cache build-base git sqlite-dev
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /server
|
||||
|
||||
# Copy the Go module files and download dependencies
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy the source code
|
||||
COPY . .
|
||||
|
||||
# Build the server binary with CGO enabled
|
||||
RUN CGO_ENABLED=1 go build -o server server.go
|
||||
|
||||
# Stage 2: Run the server
|
||||
FROM alpine:latest
|
||||
|
||||
# Copy the server binary from the builder stage
|
||||
COPY --from=builder /server/server /server
|
||||
|
||||
# Expose the port
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the server
|
||||
CMD ["/server"]
|
||||
49
server/README.md
Normal file
49
server/README.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# room-server
|
||||
|
||||
This project implements the backend server for a collaborative text editor using WebSockets, allowing multiple users to edit text in real-time within designated rooms.
|
||||
|
||||
## Features
|
||||
|
||||
- Real-time text updates among clients.
|
||||
- Join and leave functionality for collaborative editing sessions.
|
||||
- Automatic cleanup of inactive rooms.
|
||||
- Persistent storage of room content.
|
||||
|
||||
## Technologies Used
|
||||
|
||||
- WebSockets
|
||||
- SQLite
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Go
|
||||
- SQLite
|
||||
|
||||
### Usage
|
||||
|
||||
1. Clone the repository.
|
||||
2. Deploy using Docker Compose.
|
||||
|
||||
### Using the Application
|
||||
|
||||
- Connect to the WebSocket endpoint.
|
||||
- Send a JSON message to join a room.
|
||||
- Send text updates in JSON format.
|
||||
|
||||
### Room Cleanup
|
||||
|
||||
- Inactive rooms are automatically deleted after a specified duration.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please fork the repository and create a pull request.
|
||||
|
||||
## License
|
||||
|
||||
This project is open-source and available under the [MIT License](LICENSE).
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
- Thanks to Me!
|
||||
12
server/compose.yml
Normal file
12
server/compose.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8083:8080"
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./uploads:/app/uploads
|
||||
environment:
|
||||
- FILES_DIR=/app/uploads
|
||||
9
server/go.mod
Normal file
9
server/go.mod
Normal file
@@ -0,0 +1,9 @@
|
||||
module server
|
||||
|
||||
go 1.23.2
|
||||
|
||||
require (
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/mattn/go-sqlite3 v1.14.24
|
||||
)
|
||||
6
server/go.sum
Normal file
6
server/go.sum
Normal file
@@ -0,0 +1,6 @@
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
|
||||
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
1133
server/main.go
Normal file
1133
server/main.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user