Skip to content

Commit

Permalink
change nginx to envoy
Browse files Browse the repository at this point in the history
  • Loading branch information
warycat committed Jun 6, 2022
1 parent cdcad10 commit 3cb8a1a
Show file tree
Hide file tree
Showing 41 changed files with 731 additions and 676 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[target.armv7-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-ld"
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
93 changes: 0 additions & 93 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@ jobs:
run: cargo install cargo-make --verbose
- name: Install wasm-pack
uses: jetli/[email protected]
- name: Create ignore.env
run: touch infra/ignore.env
- name: Run wasm test
run: cargo make wasm-test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pkg/
*.sqlite
*.tar.gz
stream/
data/
data/
bundle.tar
37 changes: 31 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 39 additions & 34 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
env_files = ["infra/ignore.env", "infra/const.env"]
env_files = ["scripts/ignore.env", "scripts/const.env"]

[config]
default_to_workspace = false
Expand Down Expand Up @@ -28,28 +28,24 @@ script = [
"cargo run --bin openvgdb"
]

[tasks.wasm-pack]
script = "wasm-pack build wasm --target no-modules --out-dir ../pkg"

[tasks.bin-pack]
script = ["cargo build --release", "tar -czvf bin.tar.gz -T infra/bin.txt"]

[tasks.archive-wasm]
script = "tar -czvf pkg.tar.gz pkg"
[tasks.wasm]
command = "wasm-pack"
args = ["build", "wasm", "--target", "no-modules", "--out-dir", "../pkg"]

[tasks.archive-static]
script = "tar -czvf static.tar.gz static"
[tasks.release]
command = "cargo"
args = ["build", "--release", "--target", "x86_64-unknown-linux-musl"]

[tasks.watch-wasm]
run_task = { name = ["wasm-pack"] }
watch = { postpone = true, watch = ["./wasm", "./msg", "./consts", "./nes"] }

[tasks.watch-server]
script = "cargo watch -w server -w msg -w consts -x 'run --bin rustgym-server'"
dependencies = ["wasm-pack"]
dependencies = ["wasm"]

[tasks.sonic]
script = "sonic -c infra/sonic.cfg"
script = "sonic -c config/sonic.cfg"

[tasks.dev]
run_task = { name = ["sonic", "watch-server", "watch-wasm"], parallel = true }
Expand All @@ -58,30 +54,39 @@ run_task = { name = ["sonic", "watch-server", "watch-wasm"], parallel = true }
command = "wasm-pack"
args = ["test", "--chrome", "--headless", "wasm"]

[tasks.build-mini]
command = "cargo"
[tasks.create-instance]
command = "gcloud"
args = [
"build",
"--release",
"--target",
"aarch64-apple-darwin",
"--bin",
"${APP_NAME}"
"compute",
"instances",
"create",
"${VM_NAME}",
"--machine-type",
"${MACHINE_TYPE}",
"--zone",
"${ZONE}",
"--tags",
"http-server,https-server,stun-server"
]

[tasks.copy-mini]
[tasks.ssh]
command = "ssh"
args = ["${VM_NAME}.us-central1-a.${PROJECT}"]

[tasks.bundle]
command = "tar"
args = ["-cvvf", "bundle.tar", "-T", "bundle.txt"]
dependencies = ["release", "wasm"]

[tasks.deploy]
command = "scp"
args = [
"./target/aarch64-apple-darwin/release/${APP_NAME}",
"mini:~/${APP_NAME}"
]
dependencies = ["build-mini"]
args = ["bundle.tar", "${VM_NAME}.us-central1-a.${PROJECT}:~"]
dependencies = ["bundle"]

[tasks.run-mini]
command = "ssh"
args = ["mini", "./${APP_NAME}"]
dependencies = ["copy-mini"]
[tasks.copy-scripts]
command = "scp"
args = ["-r", "scripts", "${VM_NAME}.us-central1-a.${PROJECT}:~"]

[tasks.run-local]
command = "cargo"
args = ["run", "--release", "--bin", "${APP_NAME}"]
[tasks.copy-config]
command = "scp"
args = ["-r", "config", "${VM_NAME}.us-central1-a.${PROJECT}:~"]
9 changes: 9 additions & 0 deletions bundle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
target/x86_64-unknown-linux-musl/release/openvgdb
target/x86_64-unknown-linux-musl/release/rustgym-server
target/x86_64-unknown-linux-musl/release/rustgym-readme
target/x86_64-unknown-linux-musl/release/rustgym-ingest
config/
scripts/
pkg/
data/
static/
55 changes: 55 additions & 0 deletions config/envoy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
admin:
address:
socket_address: { address: 127.0.0.1, port_value: 9901 }

static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 443 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: some_service }
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
upgrade_configs:
- upgrade_type: websocket
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificates:
- certificate_chain:
filename: /etc/letsencrypt/live/rustgym.com/fullchain.pem
private_key:
filename: /etc/letsencrypt/live/rustgym.com/privkey.pem

clusters:
- name: some_service
connect_timeout: 0.25s
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: some_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080
File renamed without changes.
4 changes: 0 additions & 4 deletions infra/bin.txt

This file was deleted.

Loading

0 comments on commit 3cb8a1a

Please sign in to comment.