Lago scaffold

This commit is contained in:
Jeremy Denquin 2022-02-28 11:03:13 +01:00
commit 5e9b9bb3ef
No known key found for this signature in database
GPG Key ID: 9E2B6D4E714D5CE0
6 changed files with 143 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/traefik/certs/*

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "front"]
path = front
url = git@github.com:getlago/lago-front.git
[submodule "api"]
path = api
url = git@github.com:getlago/lago-api.git

61
README.md Normal file
View File

@ -0,0 +1,61 @@
# Lago
## Requirements
- Git
- Docker
- [Docker for Ubuntu](https://docs.docker.com/engine/install/ubuntu/)
- [Docker Desktop for MacOS](https://www.docker.com/products/docker-desktop)
- Homebrew (macOS only)
```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
- OpenSSL
```shell
# Ubuntu/Debian
sudo apt update
sudo apt install openssl
# MAC OS
brew install openssl
```
## Local Environment Setup
- First of all, you need to clone the Lago repo on your machine, since we're using Git submodules, here is the good command to do it
```shell
git clone --recurse-submodules git@github.com:getlago/lago.git
cd lago
# If you're not using bash, replace .bashrc with your shell rc, ei: ~/.zshrc
echo "export LAGO_PATH=${PWD}" >> ~/.bashrc
echo 'alias lago="docker-compose -f $LAGO_PATH/docker-compose.dev.yml"' >> ~/.bashrc
source ~/.bashrc
```
- Install `mkcert` and generate some certs for TLS usage
```shell
brew install mkcert nss
mkcert -install
cd $LAGO_PATH/traefik
mkdir certs
cd certs
mkcert -cert-file lago.dev.pem -key-file lago.dev-key.pem lago.dev "*.lago.dev"
```
- Add all custom domains to your `/etc/hosts` file
```
127.0.0.1 traefik.lago.dev
127.0.0.1 api.lago.dev
127.0.0.1 app.lago.dev
```
## Local Environment Commands
- Start your local environment
```shell
lago up -d db redis traefik
lago up app api
```
- Start enjoying your local Lago at https://app.lago.dev

50
docker-compose.dev.yml Normal file
View File

@ -0,0 +1,50 @@
version: "3.8"
volumes:
app_node_modules:
app_dist:
postgres_data:
redis_data:
services:
traefik:
image: "traefik:v2.5.4"
container_name: lago_traefik
ports:
- 80:80
- 443:443
volumes:
- ./traefik/traefik.yml:/etc/traefik/traefik.yml
- ./traefik/dynamic.yml:/etc/traefik/dynamic.yml
- ./traefik/certs:/etc/certs
- "/var/run/docker.sock:/var/run/docker.sock:ro"
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`traefik.lago.dev`)"
- "traefik.http.routers.traefik.entrypoints=web,websecure"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
db:
image: postgres:14.0-alpine
container_name: lago_db
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-lago}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /data/postgres
volumes:
- postgres_data:/data/postgres
ports:
- 5432:5432
redis:
image: redis:6.2-alpine
container_name: lago_redis
restart: unless-stopped
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:-changeme}
volumes:
- redis_data:/data
ports:
- 6379:6379

4
traefik/dynamic.yml Normal file
View File

@ -0,0 +1,4 @@
tls:
certificates:
- certFile: "/etc/certs/lago.dev.pem"
keyFile: "/etc/certs/lago.dev-key.pem"

21
traefik/traefik.yml Normal file
View File

@ -0,0 +1,21 @@
logs:
level: debug
providers: # You can add more than one provider if needed
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false # Only expose explicitly enabled containers
file:
filename: /etc/traefik/dynamic.yml
watch: true
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
api:
dashboard: true
insecure: true