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

Feature/147 Create a separate dockerized server #229

Merged
merged 9 commits into from
Aug 5, 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
348 changes: 114 additions & 234 deletions frosthaven_assistant/lib/services/network/server.dart

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions frosthaven_assistant/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.2.0"
frosthaven_assistant_server:
dependency: "direct main"
description:
path: "../frosthaven_assistant_server"
relative: true
source: path
version: "1.0.0"
get_it:
dependency: "direct main"
description:
Expand Down
2 changes: 2 additions & 0 deletions frosthaven_assistant/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ dependencies:
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/window_size
format: ^1.4.0
frosthaven_assistant_server:
path: ../frosthaven_assistant_server



Expand Down
8 changes: 8 additions & 0 deletions frosthaven_assistant_server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.dockerignore
Dockerfile
build/
.dart_tool/
.git/
.github/
.gitignore
.packages
15 changes: 15 additions & 0 deletions frosthaven_assistant_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.dart_tool/
build/

doc/api/

# IntelliJ
*.iml
*.ipr
*.iws
.idea/

# Mac
.DS_Store


24 changes: 24 additions & 0 deletions frosthaven_assistant_server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Specify the Dart SDK base image version using dart:<version> (ex: dart:2.12)
FROM dart:stable AS build

# Resolve app dependencies.
WORKDIR /app
COPY pubspec.* ./
RUN dart pub get

# Copy app source code and AOT compile it.
COPY . .
# Ensure packages are still up-to-date if anything has changed
RUN dart pub get --offline
RUN mkdir -p bin &&\
dart compile exe lib/main.dart --output=bin/server

# Build minimal serving image from AOT-compiled `/server` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/

# Start server.
EXPOSE 4567
CMD ["/app/bin/server"]
15 changes: 15 additions & 0 deletions frosthaven_assistant_server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Library and simple standalone dart server for X-Haven Assistant
I have pushed the container to Docker Hub here:
https://hub.docker.com/r/aschneem/x-haven-server

This is currently a manual process and may not be up-to-date

The pull command:
```
docker pull aschneem/x-haven-server
```

Running the container:
```
docker run -p 4567:4567 aschneem/x-haven-server
```
30 changes: 30 additions & 0 deletions frosthaven_assistant_server/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
34 changes: 34 additions & 0 deletions frosthaven_assistant_server/lib/connection_health.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class ConnectionHealth{
DateTime creation = DateTime.now();
int pingsSent = 0;
int pongsReceived = 0;
DateTime? lastMessageSent;
DateTime? lastMessageReceived;
int messageSent = 0;
int messageRecieved = 0;

logPing(){
pingsSent ++;
lastMessageSent = DateTime.now();
}

logPong(){
pongsReceived ++;
lastMessageReceived = DateTime.now();
}

logMessageSent(){
messageSent ++;
lastMessageSent = DateTime.now();
}

logMessageReceived(){
messageRecieved ++;
lastMessageReceived = DateTime.now();
}

@override
String toString() {
return "Created: $creation Sent: $lastMessageSent Recieved: $lastMessageReceived pings $pongsReceived/$pingsSent messages $messageSent | $messageRecieved";
}
}
Loading
Loading