-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
pub_stats_collector
and proxy
to this project
- Loading branch information
Showing
30 changed files
with
2,153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.dart_tool/ | ||
.dockerignore | ||
.git/ | ||
.github/ | ||
.gitignore | ||
.idea/ | ||
.packages | ||
Dockerfile | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.gcloudignore | ||
.git | ||
.gitignore | ||
#!include:.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Files and directories created by pub. | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build output. | ||
build/ | ||
|
||
# macOS | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Official Dart image: https://hub.docker.com/_/dart | ||
# Specify the Dart SDK base image version using dart:<version> (ex: dart:2.14) | ||
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 dart compile exe bin/server.dart -o 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 8080 | ||
ENTRYPOINT ["/app/bin/server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Template for creating Google Cloud Run applications in Dart. Based on documentation from https://github.com/GoogleCloudPlatform/functions-framework-dart. | ||
|
||
The functions framework is nice for very simple applications, but isn't great if you want more control over your server behavior. | ||
|
||
## Prerequisites | ||
- Have a general idea how to set up Cloud Run. This is not comprehensive documentation. | ||
|
||
## Usage | ||
1. Create a new project based on this template | ||
2. Compose your server in `bin/server.dart` | ||
3. Edit `deploy.sh` to use the desired parameters | ||
4. Run `deploy.sh` to deploy your application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:rexios_lints/dart/core.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'dart:io'; | ||
import 'package:shelf/shelf.dart'; | ||
import 'package:shelf/shelf_io.dart' as shelf_io; | ||
import 'package:shelf_cors_headers/shelf_cors_headers.dart'; | ||
import 'package:shelf_proxy/shelf_proxy.dart'; | ||
import 'package:shelf_router/shelf_router.dart'; | ||
|
||
final pubHandler = Pipeline() | ||
.addMiddleware( | ||
corsHeaders( | ||
originChecker: | ||
originOneOf(['https://pubstats.dev', 'https://beta.pubstats.dev']), | ||
), | ||
) | ||
.addHandler( | ||
proxyHandler('https://pub.dartlang.org', proxyName: 'proxy.pubstats.dev'), | ||
); | ||
|
||
void main(List<String> arguments) async { | ||
final app = Router()..mount('/pub', pubHandler); | ||
|
||
final port = Platform.environment.containsKey('PORT') | ||
? int.parse(Platform.environment['PORT']!) | ||
: 8080; | ||
final server = await shelf_io.serve(app.call, '0.0.0.0', port); | ||
|
||
print('Listening on :${server.port}'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# gcloud run deploy NAME \ # the Cloud Run service name | ||
# --source=PATH \ # can use $PWD or . for current dir | ||
# --project=PROJECT \ # the Google Cloud project ID | ||
# --region=REGION \ # ex: us-central1 | ||
# --platform=managed \ # for Cloud Run | ||
# --allow-unauthenticated # for public access | ||
|
||
# ex: gcloud run deploy my-service --source=. --project=my-project --region=us-central1 --platform=managed --allow-unauthenticated | ||
gcloud run deploy pub-stats-collector-nginx --source=. --project=pub-stats-collector --region=us-central1 --platform=managed --allow-unauthenticated |
Oops, something went wrong.