https://github.com/kohrongying/notes-backend
Notes taking app - backend
https://github.com/kohrongying/notes-backend
deno
Last synced: about 2 months ago
JSON representation
Notes taking app - backend
- Host: GitHub
- URL: https://github.com/kohrongying/notes-backend
- Owner: kohrongying
- Created: 2020-08-01T06:26:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-03T09:02:29.000Z (almost 5 years ago)
- Last Synced: 2025-01-27T22:14:26.991Z (4 months ago)
- Topics: deno
- Language: TypeScript
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
  
# Set up
Requirements
- Deno v1.2 (at least)
- Docker
- Terraform (to set up infra)Steps:
1. Create deno backend (simple api)
2. Create dockerfile and test if you can run deno in docker container locally:
```
docker build . -t web
docker run -p 8000:8000 web:latest// go to your localhost:8000/todos
```
3. Use terraform to create infrastructure
4. Use github actions# Terraform
1. Ensure you have `secrets.tfvars````
// secrets.tfvar
do_token = "" // Get from DO
github_token = "" // Get from Github personal access token
ssh_key_id = "" // Get from Github API
public_key = "" // Generate a pair yourself
```2. Run terraform commands:
```
terraform init
terraform apply -var-file=secrets.tfvars`
```3. Output:
A server with some pre-configured configurations
- Logging into the docker registry with the github token
- Adding the public key into `authorized_keys`. This key is the one where github actions will use to remote access# Deployment
## CI/CD with Docker and Github Actions
In layman terms of the github workflow#### Triggered by: On commit / PR
1. Job #1: push_to_registry
- Checkout the repository
- Build the app using the `Dockerfile`
- Tag and push it to github packages2. Job #2: update_server_image
- Remote ssh into server
- Pull latest image
- Stop current container and restart it in backgroundGo to Settings > Secrets and add the following secrets:
1. `PRIVATE_KEY`
2. `PROD_HOST`
3. `STAGING_HOST`Where the host follows ``
# Development
```
deno run --allow-net server.ts
OR
docker build . -t web
docker run -p 8000:8000 web:latest
```# Testing
```
deno test --allow-net
```