Skip to content

Commit d9a2366

Browse files
committed
first commit
0 parents  commit d9a2366

File tree

195 files changed

+8261
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+8261
-0
lines changed

.github/workflows/deployment-aws.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Deploy to AWS
2+
on:
3+
push:
4+
branches: [ deployment-aws-production, deployment-aws-staging ]
5+
workflow_dispatch:
6+
inputs:
7+
target:
8+
description: 'Target'
9+
required: true
10+
default: 'production'
11+
type: choice
12+
options:
13+
- 'staging'
14+
- 'production'
15+
jobs:
16+
deploy:
17+
name: Deploy to AWS
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
with:
24+
submodules: recursive
25+
26+
- name: Setup Dart SDK
27+
uses: dart-lang/setup-dart@v1.3
28+
with:
29+
sdk: 2.18.1
30+
31+
- name: Configure AWS credentials
32+
uses: aws-actions/configure-aws-credentials@v1
33+
with:
34+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
35+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
36+
aws-region: us-west-2
37+
38+
- name: Create passwords file
39+
working-directory: mypod_server
40+
shell: bash
41+
env:
42+
SERVERPOD_PASSWORDS: ${{ secrets.SERVERPOD_PASSWORDS }}
43+
run: |
44+
pwd
45+
echo "$SERVERPOD_PASSWORDS" > config/passwords.yaml
46+
ls config/
47+
48+
- name: Get Dart packages
49+
working-directory: mypod_server
50+
run: dart pub get
51+
52+
- name: Compile server
53+
working-directory: mypod_server
54+
run: dart compile kernel bin/main.dart
55+
56+
- name: Create CodeDeploy Deployment
57+
id: deploy
58+
env:
59+
PROJECT_NAME: mypod
60+
AWS_NAME: mypod
61+
DEPLOYMENT_BUCKET: mypod-deployment-9307243
62+
TARGET: ${{ github.event.inputs.target }}
63+
run: |
64+
# Deploy server to AWS
65+
TARGET="${TARGET:=${GITHUB_REF##*-}}"
66+
echo "Deploying to target: $TARGET"
67+
mkdir -p vendor
68+
cp "${PROJECT_NAME}_server/deploy/aws/scripts/appspec.yml" appspec.yml
69+
zip -r deployment.zip .
70+
aws s3 cp deployment.zip "s3://${DEPLOYMENT_BUCKET}/deployment.zip"
71+
aws deploy create-deployment \
72+
--application-name "${AWS_NAME}-app" \
73+
--deployment-group-name "${AWS_NAME}-${TARGET}-group" \
74+
--deployment-config-name CodeDeployDefault.OneAtATime \
75+
--s3-location "bucket=${DEPLOYMENT_BUCKET},key=deployment.zip,bundleType=zip"

.github/workflows/deployment-gcp.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Deploy to GCP
2+
on:
3+
push:
4+
branches: [ deployment-gcp-production, deployment-gcp-staging ]
5+
workflow_dispatch:
6+
inputs:
7+
target:
8+
description: 'Target'
9+
required: true
10+
default: 'production'
11+
type: choice
12+
options:
13+
- 'staging'
14+
- 'production'
15+
16+
env:
17+
# TODO: Update with your Google Cloud project id. If you have changed the
18+
# region and zone in your Terraform configuration, you will need to change
19+
# it here too.
20+
PROJECT: "<PROJECT ID>"
21+
REGION: us-central1
22+
ZONE: us-central1-c
23+
24+
jobs:
25+
deploy:
26+
name: Deploy to Google Cloud Run
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
with:
33+
submodules: recursive
34+
35+
- name: Setting Target Mode from Input
36+
if: ${{ github.event.inputs.target != '' }}
37+
run: echo "TARGET=${{ github.event.inputs.target }}" >> $GITHUB_ENV
38+
39+
- name: Setting Target mode based on branch
40+
if: ${{ github.event.inputs.target == '' }}
41+
run: echo "TARGET=${GITHUB_REF##*-}" >> $GITHUB_ENV
42+
43+
- name: Set repository
44+
run: echo "REPOSITORY=serverpod-${{ env.TARGET }}-container" >> $GITHUB_ENV
45+
46+
- name: Set Image Name
47+
run: echo "IMAGE_NAME=serverpod" >> $GITHUB_ENV
48+
49+
- name: Set Service Name
50+
run: echo "SERVICE_NAME=$(echo $IMAGE_NAME | sed 's/[^a-zA-Z0-9]/-/g')" >> $GITHUB_ENV
51+
52+
- name: Test
53+
run: echo $SERVICE_NAME
54+
55+
56+
- id: "auth"
57+
name: "Authenticate to Google Cloud"
58+
uses: "google-github-actions/auth@v1"
59+
with:
60+
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}"
61+
62+
- name: Create passwords file
63+
working-directory: mypod_server
64+
shell: bash
65+
env:
66+
SERVERPOD_PASSWORDS: ${{ secrets.SERVERPOD_PASSWORDS }}
67+
run: |
68+
pwd
69+
echo "$SERVERPOD_PASSWORDS" > config/passwords.yaml
70+
ls config/
71+
72+
- name: Configure Docker
73+
working-directory: mypod_server
74+
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
75+
76+
- name: Build the Docker image
77+
working-directory: mypod_server
78+
run: "docker build -t $IMAGE_NAME ."
79+
80+
- name: Tag the Docker image
81+
working-directory: mypod_server
82+
run: docker tag $IMAGE_NAME ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT }}/${{ env.REPOSITORY }}/$IMAGE_NAME
83+
84+
- name: Push Docker image
85+
working-directory: mypod_server
86+
run: docker push ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT }}/${{ env.REPOSITORY }}/$IMAGE_NAME
87+
88+
# Uncomment the following code to automatically restart the servers in the
89+
# instance group when you push a new version of your code. Before doing
90+
# this, make sure that you have successfully deployed a first version.
91+
#
92+
# - name: Restart servers in instance group
93+
# run: |
94+
# gcloud compute instance-groups managed rolling-action replace serverpod-${{ env.TARGET }}-group \
95+
# --project=${{ env.PROJECT }} \
96+
# --replacement-method='substitute' \
97+
# --max-surge=1 \
98+
# --max-unavailable=1 \
99+
# --zone=${{ env.ZONE }}

mypod_client/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Files and directories created by pub
2+
.dart_tool/
3+
.packages
4+
5+
# Omit commiting pubspec.lock for library packages:
6+
# https://dart.dev/guides/libraries/private-files#pubspeclock
7+
pubspec.lock
8+
9+
# Conventional directory for build outputs
10+
build/
11+
12+
# Directory created by dartdoc
13+
doc/api/

mypod_client/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
- Initial version, created by Stagehand

mypod_client/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# mypod_client
2+
3+
This is your Serverpod client. The code in here is mostly generated by
4+
Serverpod, but you may want to make changes if you are adding modules to your
5+
project.

mypod_client/analysis_options.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Defines a default set of lint rules enforced for
2+
# projects at Google. For details and rationale,
3+
# see https://github.com/dart-lang/pedantic#enabled-lints.
4+
5+
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
6+
# Uncomment to specify additional rules.
7+
# linter:
8+
# rules:
9+
# - camel_case_types
10+
11+
analyzer:
12+
# exclude:
13+
# - path/to/excluded/files/**

mypod_client/lib/mypod_client.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export 'src/protocol/protocol.dart';
2+
export 'package:serverpod_client/serverpod_client.dart';
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
2+
/* To generate run: "serverpod generate" */
3+
4+
// ignore_for_file: library_private_types_in_public_api
5+
// ignore_for_file: public_member_api_docs
6+
// ignore_for_file: implementation_imports
7+
8+
// ignore_for_file: no_leading_underscores_for_library_prefixes
9+
import 'package:serverpod_client/serverpod_client.dart' as _i1;
10+
import 'dart:async' as _i2;
11+
import 'dart:io' as _i3;
12+
import 'protocol.dart' as _i4;
13+
14+
class _EndpointExample extends _i1.EndpointRef {
15+
_EndpointExample(_i1.EndpointCaller caller) : super(caller);
16+
17+
@override
18+
String get name => 'example';
19+
20+
_i2.Future<String> hello(String name) => caller.callServerEndpoint<String>(
21+
'example',
22+
'hello',
23+
{'name': name},
24+
);
25+
}
26+
27+
class Client extends _i1.ServerpodClient {
28+
Client(
29+
String host, {
30+
_i3.SecurityContext? context,
31+
_i1.AuthenticationKeyManager? authenticationKeyManager,
32+
}) : super(
33+
host,
34+
_i4.Protocol(),
35+
context: context,
36+
authenticationKeyManager: authenticationKeyManager,
37+
) {
38+
example = _EndpointExample(this);
39+
}
40+
41+
late final _EndpointExample example;
42+
43+
@override
44+
Map<String, _i1.EndpointRef> get endpointRefLookup => {'example': example};
45+
@override
46+
Map<String, _i1.ModuleEndpointCaller> get moduleLookup => {};
47+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
2+
/* To generate run: "serverpod generate" */
3+
4+
// ignore_for_file: library_private_types_in_public_api
5+
// ignore_for_file: public_member_api_docs
6+
// ignore_for_file: implementation_imports
7+
8+
// ignore_for_file: no_leading_underscores_for_library_prefixes
9+
import 'package:serverpod_client/serverpod_client.dart' as _i1;
10+
11+
class Example extends _i1.SerializableEntity {
12+
Example({
13+
required this.name,
14+
required this.data,
15+
});
16+
17+
factory Example.fromJson(
18+
Map<String, dynamic> jsonSerialization,
19+
_i1.SerializationManager serializationManager,
20+
) {
21+
return Example(
22+
name: serializationManager.deserialize<String>(jsonSerialization['name']),
23+
data: serializationManager.deserialize<int>(jsonSerialization['data']),
24+
);
25+
}
26+
27+
String name;
28+
29+
int data;
30+
31+
@override
32+
Map<String, dynamic> toJson() {
33+
return {
34+
'name': name,
35+
'data': data,
36+
};
37+
}
38+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
2+
/* To generate run: "serverpod generate" */
3+
4+
// ignore_for_file: library_private_types_in_public_api
5+
// ignore_for_file: public_member_api_docs
6+
// ignore_for_file: implementation_imports
7+
8+
library protocol; // ignore_for_file: no_leading_underscores_for_library_prefixes
9+
10+
import 'package:serverpod_client/serverpod_client.dart' as _i1;
11+
import 'example.dart' as _i2;
12+
export 'example.dart';
13+
export 'client.dart';
14+
15+
class Protocol extends _i1.SerializationManager {
16+
Protocol._();
17+
18+
factory Protocol() => _instance;
19+
20+
static final Map<Type, _i1.constructor> customConstructors = {};
21+
22+
static final Protocol _instance = Protocol._();
23+
24+
@override
25+
T deserialize<T>(
26+
dynamic data, [
27+
Type? t,
28+
]) {
29+
t ??= T;
30+
if (customConstructors.containsKey(t)) {
31+
return customConstructors[t]!(data, this) as T;
32+
}
33+
if (t == _i2.Example) {
34+
return _i2.Example.fromJson(data, this) as T;
35+
}
36+
if (t == _i1.getType<_i2.Example?>()) {
37+
return (data != null ? _i2.Example.fromJson(data, this) : null) as T;
38+
}
39+
return super.deserialize<T>(data, t);
40+
}
41+
42+
@override
43+
String? getClassNameForObject(Object data) {
44+
if (data is _i2.Example) {
45+
return 'Example';
46+
}
47+
return super.getClassNameForObject(data);
48+
}
49+
50+
@override
51+
dynamic deserializeByClassName(Map<String, dynamic> data) {
52+
if (data['className'] == 'Example') {
53+
return deserialize<_i2.Example>(data['data']);
54+
}
55+
return super.deserializeByClassName(data);
56+
}
57+
}

0 commit comments

Comments
 (0)