Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
feat: bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
arein committed Jan 22, 2023
1 parent 8bda76a commit 3b319a5
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 102 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ body:
- type: markdown
attributes:
value: |
Thanks for taking the time to suggest a new feature for Rust HTTP Starter! ✨
Thanks for taking the time to suggest a new feature for Gilgamesh! ✨
- type: checkboxes
attributes:
label: Is there an existing issue for this?
Expand Down Expand Up @@ -35,4 +35,4 @@ body:
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false
required: false
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ jobs:
if: github.event_name == 'release'
with:
images: |
${{ steps.login-ecr.outputs.registry }}/rust-http-starter
ghcr.io/walletconnect/rust-http-starter
walletconnect/rust-http-starter,enable=false
${{ steps.login-ecr.outputs.registry }}/gilgamesh
ghcr.io/walletconnect/gilgamesh
walletconnect/gilgamesh,enable=false
flavor: |
latest=auto
tags: |
Expand Down
54 changes: 27 additions & 27 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "rust-http-starter"
name = "gilgamesh"
version = "0.1.0"
edition = "2021"
authors = [
"Harry Bairstow <[email protected]>"
"Derek <[email protected]>",
"Xav <[email protected]>"
]
build = "build.rs"

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
################################################################################
ARG base="rust:buster"
ARG runtime="debian:buster-slim"
ARG bin="rust-http-starter"
ARG bin="gilgamesh"
ARG version="unknown"
ARG sha="unknown"
ARG maintainer="WalletConnect"
Expand Down Expand Up @@ -49,7 +49,7 @@ COPY --from=plan /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json ${RELEASE}
# Build the local binary
COPY . .
RUN cargo build --bin rust-http-starter ${RELEASE}
RUN cargo build --bin gilgamesh ${RELEASE}

################################################################################
#
Expand All @@ -70,11 +70,11 @@ LABEL sha=${sha}
LABEL maintainer=${maintainer}

WORKDIR /app
COPY --from=build /app/target/${binpath:-debug}/rust-http-starter /usr/local/bin/rust-http-starter
COPY --from=build /app/target/${binpath:-debug}/gilgamesh /usr/local/bin/gilgamesh
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates libssl-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

USER 1001:1001
ENTRYPOINT ["/usr/local/bin/rust-http-starter"]
ENTRYPOINT ["/usr/local/bin/gilgamesh"]
49 changes: 2 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Rust HTTP Server Starter
# Gilgamesh

This is a templated based on [Echo Server](https://github.com/WalletConnect/echo-server) and [Bat Cave](https://github.com/WalletConnect/bat-cave) that
contains the basic setup of a rust HTTP Server with telemetry and a postgres database.

There is also a basic terraform config included to be built upon.
HTTP service managing users' e2e encrypted message histories.

This project also includes the standard CI/CD:
- Release
Expand All @@ -19,45 +16,3 @@ This project also includes the standard CI/CD:
* Test: `cargo test`
* Run: `docker-compose-up`
* Integration test: `yarn install` (once) and then `yarn integration:local(dev/staging/prod)`



## Required Values to Change
Any reference to `rust-http-starter` should be changed to your project name as well as all the below list:

- [ ] `README.md`
Replace this file with a Readme for your project
- [ ] `Cargo.toml`
Change package name and authors, then build the project to re-gen the `Cargo.lock`
- [ ] `/terraform/main.tf`
Change `app_name` to the repo's name
- [ ] `/terraform/main.tf`
Setup a new hosted zone in the [infra repository](https://github.com/WalletConnect/infra/blob/master/terraform/main.tf#L123)
- [ ] `/terraform/variables.tf`
Change the default value of `public_url`
- [ ] `/terraform/backend.tf`
Change the `key` for the `s3` backend to your project's name
- [ ] `/.github/workflows/cd.yml`
Ensure any URLs for health checks and environments match the terraform files
- [ ] `/.github/workflows/intake.yml`
This is specific to WalletConnect, feel free to remove or modify for your own needs
- [ ] `/.github/ISSUE_TEMPLATE/feature_request.yml`
Change any references to Rust HTTP Starter\
- [ ] `/.github/workflows/release.yml`
On line 95-97 there are references to the registry name on ECR/GHCR ensure you change this
- [ ] `/.github/integration/integration.tests.ts`
Update the URLs

### WalletConnect Specific

- [ ] `/.github/workflows/**/*.yml`
Change the `runs-on` to the `ubuntu-runners` group

## GitHub Secrets
Required GitHub secrets for Actions to run successfully
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `PAT` Personal Access Token for Github to commit releases

### WalletConnect Specific
- `ASSIGN_TO_PROJECT_GITHUB_TOKEN`
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
environment:
- POSTGRES_PASSWORD=root

rust-http-starter:
gilgamesh:
build: .
depends_on:
- jaeger
Expand All @@ -22,4 +22,4 @@ services:
- LOG_LEVEL=INFO
- DATABASE_URL=postgres://postgres:root@postgres:5432/postgres
- TELEMETRY_ENABLED=true
- TELEMETRY_GRPC_URL=http://jaeger:4317
- TELEMETRY_GRPC_URL=http://jaeger:4317
8 changes: 4 additions & 4 deletions integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ declare let process: {
}

const BASE_URLS = new Map<string, string>([
['prod', 'https://http-starter.walletconnect.com'],
['staging', 'https://staging.http-starter.walletconnect.com'],
['dev', 'https://dev.http-starter.walletconnect.com'],
['prod', 'https://history.walletconnect.com'],
['staging', 'https://staging.history.walletconnect.com'],
['dev', 'https://dev.history.walletconnect.com'],
['local', 'http://localhost:3000'],
])

const TEST_TENANT = process.env.TEST_TENANT_ID_APNS

const BASE_URL = BASE_URLS.get(process.env.JEST_ENV)

describe('http-starter', () => {
describe('Gilgamesh', () => {
describe('Health', () => {
const url = `${BASE_URL}/health`

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rust-http-starter-integration-tests",
"name": "gilgamesh-integration-tests",
"version": "1.0.0",
"description": "Integration tests for Rust HTTP Starter",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Configurati

opentelemetry::global::set_meter_provider(meter_provider.provider());

let meter = opentelemetry::global::meter("rust-http-starter");
let meter = opentelemetry::global::meter("gilgamesh");
let example_counter = meter
.i64_up_down_counter("example")
.with_description("This is an example counter")
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
dotenv::dotenv,
rust_http_starter::{config::Configuration, Result},
gilgamesh::{config::Configuration, Result},
tokio::sync::broadcast,
};

Expand All @@ -10,5 +10,5 @@ async fn main() -> Result<()> {
dotenv().ok();

let config = Configuration::new().expect("Failed to load config!");
rust_http_starter::bootstap(shutdown, config).await
gilgamesh::bootstap(shutdown, config).await
}
4 changes: 2 additions & 2 deletions terraform/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ terraform {
region = "eu-central-1"
bucket = "opz"
workspace_key_prefix = "infra/env"
key = "apps/rust-http-starter.tfstate"
key = "apps/gilgamesh.tfstate"

force_path_style = true
}
}
}
2 changes: 1 addition & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
app_name = "rust-http-starter"
app_name = "gilgamesh"
fqdn = terraform.workspace == "prod" ? var.public_url : "${terraform.workspace}.${var.public_url}"
latest_release_name = data.github_release.latest_release.name
version = coalesce(var.image_version, substr(local.latest_release_name, 1, length(local.latest_release_name)))
Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variable "azs" {

variable "public_url" {
type = string
default = "http-starter.walletconnect.com"
default = "history.walletconnect.com"
}

variable "grafana_endpoint" {
Expand Down
4 changes: 2 additions & 2 deletions tests/context/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
rust_http_starter::config::Configuration,
gilgamesh::config::Configuration,
std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, TcpListener},
tokio::{
runtime::Handle,
Expand Down Expand Up @@ -36,7 +36,7 @@ impl RustHttpStarter {
is_test: true,
};

rust_http_starter::bootstap(shutdown, config).await
gilgamesh::bootstap(shutdown, config).await
})
.unwrap();
});
Expand Down
2 changes: 1 addition & 1 deletion tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ pub enum TestError {
Elapsed(#[from] tokio::time::error::Elapsed),

#[error(transparent)]
RustHttpStarter(#[from] rust_http_starter::error::Error),
RustHttpStarter(#[from] gilgamesh::error::Error),
}

0 comments on commit 3b319a5

Please sign in to comment.