-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
278 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
MAX_WORKERS=1 | ||
LOGURU_LEVEL=info | ||
DATA_PATH=./data/ | ||
CONF_PATH=./conf/ | ||
WEB_PORT=8000 | ||
ADMIN_SECRET=changeme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: images build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'app/**' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
build-and-push-images: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: pre-commit | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/action@v3.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ __pycache__ | |
|
||
static_pages/ | ||
data/ | ||
conf/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
repos: | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.3.0 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter. | ||
- id: ruff-format | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: 'v1.9.0' | ||
hooks: | ||
- id: mypy | ||
# add types-requests | ||
additional_dependencies: [ 'types-PyYAML' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11 | ||
|
||
COPY ./requirements.txt /app/ | ||
RUN pip install --no-cache-dir -r /app/requirements.txt | ||
|
||
COPY ./app/ /app/ | ||
COPY ./template/ /app/template/ | ||
WORKDIR /app/ | ||
|
||
VOLUME /app/data | ||
VOLUME /app/conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Landing generator | ||
|
||
Generate landing pages wih email collection in minutes. | ||
|
||
## Run it | ||
|
||
First, set up the configuration with: | ||
|
||
```shell | ||
mkdir -p ./conf | ||
cp config.example.yaml ./conf/config.yaml | ||
# edit the config file to add or change the default landing pages | ||
``` | ||
|
||
|
||
### Docker | ||
|
||
```shell | ||
docker run -it --rm \ | ||
-p 8000:80 \ | ||
--name landing_generator \ | ||
-v ./conf/:/app/conf/:ro \ | ||
-v ./data/:/app/data/ \ | ||
-e ADMIN_SECRET=secret \ | ||
ghcr.io/m0wer/landing_generator:master | ||
``` | ||
|
||
### Docker compose | ||
|
||
```shell | ||
cp .env.example .env | ||
# edit the .env file | ||
docker compose up -d --build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#! /usr/bin/env bash | ||
|
||
cd /app | ||
python scripts/render_sites.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Module to render the template for the configured sites.""" | ||
|
||
import yaml | ||
from pathlib import Path | ||
import shutil | ||
from jinja2 import Environment, FileSystemLoader | ||
from loguru import logger | ||
|
||
TEMPLATE_SRC: Path = Path("./template/src/") | ||
CONF_PATH: Path = Path("./conf/config.yaml") | ||
STATIC_PAGES_DIR: Path = Path("./static_pages") | ||
|
||
if __name__ == "__main__": | ||
with open(CONF_PATH, "r") as conf_file: | ||
conf = yaml.safe_load(conf_file) | ||
|
||
for site in conf["sites"]: | ||
page_identifier = site["page_identifier"] | ||
logger.info(f"Rendering site: {page_identifier}") | ||
site_path: Path = STATIC_PAGES_DIR / page_identifier | ||
|
||
# recursive copy of template files to site directory | ||
shutil.copytree(TEMPLATE_SRC, site_path) | ||
|
||
# replace jinja variables in index.html | ||
env = Environment(loader=FileSystemLoader(site_path)) | ||
template = env.get_template("index.html") | ||
rendered = template.render(**site) | ||
|
||
with open(site_path / "index.html", "w") as f: | ||
f.write(rendered) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
|
||
sites: | ||
- page_identifier: landing_generator | ||
title: Landing Generator | ||
tagline: Generate landing pages wih email collection in minutes. | ||
description: Generate landing pages wih email collection in minutes. | ||
item_1_title: Validate your idea | ||
item_1_description: Create a landing page to validate your idea. | ||
item_2_title: Collect emails | ||
item_2_description: You will have an audience ready for when you launch. | ||
item_3_title: Self hosted | ||
item_3_description: Host your landing page on your own server. | ||
item_4_title: Secure | ||
item_4_description: Your data is safe and secure and not shared with anyone. | ||
button_text: Get more info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
services: | ||
|
||
backend: | ||
image: ghcr.io/m0wer/landing_generator:master | ||
container_name: landing-generator | ||
build: | ||
context: . | ||
environment: | ||
ROOT_PATH: "/api" | ||
MAX_WORKERS: ${MAX_WORKERS:-1} | ||
LOGURU_LEVEL: ${LOGURU_LEVEL:-INFO} | ||
ADMIN_SECRET: ${ADMIN_SECRET:-admin} | ||
volumes: | ||
- ${DATA_PATH:-./data/}:/app/data/ | ||
- ${CONF_PATH:-./conf/}:/app/conf/ | ||
ports: | ||
- ${WEB_PORT:-8000}:80 | ||
restart: unless-stopped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
email-validator | ||
fastapi | ||
gunicorn | ||
Jinja2 | ||
loguru | ||
pydantic | ||
pyyaml | ||
uvicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.