commit 5e9b9bb3ef2dc0be63427d8dd2e46172ea2eeb58 Author: Jeremy Denquin Date: Mon Feb 28 11:03:13 2022 +0100 Lago scaffold diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d7e9b8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/traefik/certs/* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..30906b0 --- /dev/null +++ b/.gitmodules @@ -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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d6a8b08 --- /dev/null +++ b/README.md @@ -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 \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..965be2f --- /dev/null +++ b/docker-compose.dev.yml @@ -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 \ No newline at end of file diff --git a/traefik/dynamic.yml b/traefik/dynamic.yml new file mode 100644 index 0000000..b2d91f3 --- /dev/null +++ b/traefik/dynamic.yml @@ -0,0 +1,4 @@ +tls: + certificates: + - certFile: "/etc/certs/lago.dev.pem" + keyFile: "/etc/certs/lago.dev-key.pem" \ No newline at end of file diff --git a/traefik/traefik.yml b/traefik/traefik.yml new file mode 100644 index 0000000..e8c19ba --- /dev/null +++ b/traefik/traefik.yml @@ -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 \ No newline at end of file