https://github.com/matrixai/http-demo
Demo of an basic HTTP server wrapped up as Nix project
https://github.com/matrixai/http-demo
http http-server https https-server socat
Last synced: 10 months ago
JSON representation
Demo of an basic HTTP server wrapped up as Nix project
- Host: GitHub
- URL: https://github.com/matrixai/http-demo
- Owner: MatrixAI
- License: apache-2.0
- Created: 2020-07-30T15:00:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-15T02:25:01.000Z (almost 4 years ago)
- Last Synced: 2025-01-24T06:29:45.771Z (12 months ago)
- Topics: http, http-server, https, https-server, socat
- Language: Nix
- Homepage: https://matrix.ai
- Size: 12.7 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HTTP-Demo
## Installation
### Nix/NixOS
Building the package:
```sh
nix-build -E '(import ./pkgs.nix).callPackage ./default.nix {}'
```
Building the releases:
```sh
nix-build ./release.nix --attr application
nix-build ./release.nix --attr docker
```
Install into Nix user profile:
```sh
nix-env -f ./release.nix --install --attr application
```
### Docker
Install into Docker:
```sh
docker load --input "$(nix-build ./release.nix --attr docker)"
```
## Usage
```sh
http-demo 55555
curl http://localhost:55555/
```
Or after you have tagged your container image with `latest`:
```sh
docker run -it --rm --network=host http-demo:latest 55555
```
Or with port mapping:
```sh
docker run -it --rm -p 55555:55555 http-demo:INSERTYOURTAG 55555
```
## Deployment
### Deploying to AWS ECS:
First login to AWS ECR:
```sh
aws --profile=matrix ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin 015248367786.dkr.ecr.ap-southeast-2.amazonaws.com
```
Proceed to build the container image and upload it:
```sh
repo="015248367786.dkr.ecr.ap-southeast-2.amazonaws.com" && \
build="$(nix-build ./release.nix --attr docker)" && \
loaded="$(docker load --input "$build")" && \
name="$(cut -d':' -f2 <<< "$loaded" | tr -d ' ')" && \
tag="$(cut -d':' -f3 <<< "$loaded")" && \
docker tag "${name}:${tag}" "${repo}/http-demo:${tag}" && \
docker tag "${name}:${tag}" "${repo}/http-demo:latest" && \
docker push "${repo}/http-demo:${tag}" && \
docker push "${repo}/http-demo:latest"
```
Because the container is built with an `Entrypoint`, set the `Command` to only the parameters.