• Stars
    star
    109
  • Rank 317,207 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Skeleton web stack using Docker Compose, PostgreSQL, PostgREST, Nginx and Auth0.

Postgrest Skeleton

Stack:

Setting up a server

Assuming an Ubuntu Xenial 16.04 server.

sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get purge lxc-docker
sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) git curl docker-engine openssl
curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
sudo chmod +x /usr/local/bin/docker-compose
sudo service docker start
sudo docker run hello-world
docker-compose --version
sudo gpasswd -a $USER docker
sudo mkdir -p /srv/live.git /srv/live/certificates /srv/backups
sudo chown -R :adm /srv/live.git /srv/live /srv/backups
sudo chmod -R g+rwx /srv/live.git /srv/live /srv/backups
git init --bare /srv/live.git
openssl dhparam -out /srv/live/certificates/dhparam.pem 4096
crontab -e # Add '00 00 * * * /srv/live/make-backup'

git remote add staging staging.example.com:/srv/live.git
scp post-receive staging.example.com:/srv/live.git/hooks
nano site.conf
scp site.conf staging.example.com:/srv/live.git/
git push staging

Local testing

docker-compose start

Staging

source site.conf
export DOMAIN CERT_EMAIL JWT_SECRET POSTGRES_PASSWORD AUTHENTICATOR_PASSWORD
alias dc=docker-compose -f docker-compose.yml -f live.yml 
dc stop; dc rm -f; dc create; dc start; dc logs

Production

docker-compose -f docker-compose.yml -f staging.yml  -f production.yml start

Using

Staging

Deployment

docker-compose -f docker-compose.yml -f production.yml start

Dependencies

Make sure you have a recent version of docker, at least version 1.10.0.

https://docs.docker.com/engine/installation/linux/ubuntulinux/

Make sure you have a recent version of docker-compose, at least version 1.6.

curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
sudo chmod +x /usr/local/bin/docker-compose

To recompile the javascript you need Google Closure.

closure-compiler --language_out ECMASCRIPT5_STRICT --js js/*.js > www/min.js

Starting

docker-compose up

To start with a clean build

docker-compose stop
sudo rm -rf data/data
docker-compose rm -f
docker-compose create
docker-compose start

Raw database access

docker exec -ti -u postgres example_dbm_1 psql -d example -P pager=off

Dump database for backups

docker exec -ti -u postgres example_dbm_1 pg_dump -a --insert example

JWT token:

Example token (with signature removed):

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoiYXV0aG9yIiwidXNlcmlkIjoiYXV0aDB8NTZkZWEwYjM4MWRlMjkyZTBjYjc1OTY1IiwiaXNzIjoiaHR0cHM6Ly9vcGVuZXRoLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1NmRlYTBiMzgxZGUyOTJlMGNiNzU5NjUiLCJhdWQiOiJBWm10a0JONXpER0VSSmVzRlpHRlM4dllKWXlaVHJEbyIsImV4cCI6MTQ1NzQ4NjM5MywiaWF0IjoxNDU3NDUwMzkzfQ.2DIZz2bf19Jr9UaNA3DLl263JqzXvrAUky3Vr_ZgIbQ
{
	"role": "author",
	"userid": "auth0|56dea0b381de292e0cb75965",
	"iss": "https://example.auth0.com/",
	"sub": "auth0|56dea0b381de292e0cb75965",
	"aud": "AZmtkBN5zDGERJesFZGFS8vYJYyZTrDo",
	"exp": 1457486393,
	"iat": 1457450393
}

The role gets mapped to a PostgreSQL role, sub is used to uniquely identify users.

Regenerating Diffie-Hellman parameters

Goal:

https://www.owasp.org/index.php/List_of_useful_HTTP_headers

https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html

openssl dhparam -out certificates/dhparam.pem 4096

Content Security Policy

More Repositories

1

uint

Rust Uint crate using const-generics
Rust
169
star
2

yul

Rust
101
star
3

cria

Tiny inference-only implementation of LLaMA
Python
91
star
4

experiment-solexp

Fixed point solidity exponentiation.
Jupyter Notebook
74
star
5

goldilocks

A library for fast NTTs over the Goldilocks prime field
Rust
71
star
6

pc-bench

Benchmarking Polynomial Commitments
Jupyter Notebook
47
star
7

rust-service-template

Rust
22
star
8

cli-batteries

Batteries included command line interfaces.
Rust
21
star
9

evm-groth16

Groth16 verifier in EVM
Solidity
19
star
10

binius

Fork of binius
Rust
19
star
11

kzg-ceremony-coordinator

Moved to https://github.com/ethereum/kzg-ceremony-sequencer
Rust
17
star
12

XCompile

Specify compose key sequences in a simple language.
Python
9
star
13

zkp-u256

Rust 256-bit unsigned integers.
Rust
9
star
14

rust-static-build

Rust build image to create statically compiled binaries.
Dockerfile
8
star
15

proto-ecdsa-plonky2

Rust
8
star
16

mpc-iris-code

Rust
7
star
17

delegated-spartan

Mobile delegated R1CS proving using SpartanNIZK
Rust
6
star
18

proto-goldilocks-webgpu

Prototype WebGPU compute implementation of Goldilocks
Rust
5
star
19

dancing-cells

Rust
4
star
20

fhe-iris-code

Rust
4
star
21

Codecup-2014-Poly-Y

My entry for the 2014 Codecup Poly-Y competition. See http://www.codecup.nl/intro.php.
C++
3
star
22

EntropyCoder

Library for optimal compression using entropy/arithmetic/range coding.
C++
3
star
23

Codecup-2013-Symple

My entry for the 2013 Codecup competition. See http://archive.codecup.nl/2013/.
C++
2
star
24

shardtoken

Ethereum token contract for a post-state-rent, post-sharding world.
JavaScript
2
star
25

BitGovPrototype

BitGov prototype interface
CSS
1
star
26

remgo

Computer Go player using MCTS and HashLife inspired information sharing
C++
1
star
27

Codecup-2015-Ayu

C++
1
star
28

Principia

Futuristic programming, reasoning and proof language
C++
1
star
29

cotracker

Tool to fetch Aranet4 data
Rust
1
star
30

khinchin

Computes Khinchin's constant
Rust
1
star
31

extended-postgresql

Docker image of PostgreSQL with popular extensions
Makefile
1
star
32

pookie-bouncer

ESP32+TMC2209+NEMA17 motor controller for bouncing pookies.
C++
1
star