4 Commits

Author SHA1 Message Date
9ec5ed1d3f chore: publish 0.1.0+0.1.0 release 2022-09-30 22:18:34 +02:00
e4c18a4826 fully working with e-mail support 2022-09-30 17:16:26 +02:00
45fbf25a19 healthcheck 2022-09-30 17:29:19 +02:00
bd554f3342 first working commit 2022-09-29 19:33:06 +02:00
8 changed files with 73 additions and 101 deletions

View File

@ -1,16 +1,26 @@
TYPE=karrot
DOMAIN=karrot.example.com
LETS_ENCRYPT_ENV=production
# account id for maxmind (for GeoIP)
MAXMIND_ACCOUNT_ID=
# License key for maxmind
MAXMIND_LICENSE_KEY=
# if I set this it fails with:
# TypeError: SelectorEventLoop required, instead got: <uvloop.Loop running=False closed=False debug=False>
#LISTEN_CONCURRENCY=4
SITE_NAME=karrot dev
SITE_LOGO=https://user-images.githubusercontent.com/31616/36565633-517373a4-1821-11e8-9948-5bf6887c667e.png
# postal,smtp,console
EMAIL_BACKEND=console
# only set those when using SMTP
#EMAIL_FROM=
# SMTP USER and EMAIL_FROM are usually the same
#SMTP_USER=
#SMTP_PASSWORD=
#SMTP_HOST=
#SMTP_USE_SLL=
#SMTP_USE_TLS=true
#SMTP_PORT=587
SECRET_DB_PASSWORD_VERSION=v1
SITE_URL=https://${DOMAIN}
LETS_ENCRYPT_ENV=production

29
README.md Normal file
View File

@ -0,0 +1,29 @@
# karrot
Karrot is a free and open-source tool for grassroots initiatives and groups of people that want to coordinate face-to-face activities on a local, autonomous and voluntary basis.
<!-- metadata -->
* **Category**: Utilities
* **Status**: 3, stable
* **Image**: [`karrot-backend`](https://hub.docker.com/r/vlafvlaf/karrot_backend),4,upstream
* **Healthcheck**: Yes
* **Backups**: No
* **Email**: Yes
* **Tests**: No
* **SSO**: No
<!-- endmetadata -->
## Basic usage
1. Set up Docker Swarm and [`abra`]
2. `abra app new karrot`
3. `abra app config <karrot app name>`
4. `abra app deploy <karrot app name>`
## Configuration options
`MAXMIND_ACCOUNT_ID` and `MAXMIND_ACCOUNT_KEY` are API credentials from maxmind.com. You need an account there to get GeoIP data for Karrot.
[`abra`]: https://git.coopcloud.tech/coop-cloud/abra

View File

@ -1,13 +0,0 @@
FROM python:3.7-buster
WORKDIR /app
RUN apt-get update && \
apt-get install -y gdal-bin
COPY ./karrot-backend.pyz /app/karrot-backend.pyz
RUN sed -i -e's/ main/ main contrib non-free/g' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y libmaxminddb0 libmaxminddb-dev geoipupdate

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@ version: "3.8"
services:
web:
image: "vlafvlaf/karrot_frontend:0.0.3"
image: "vlafvlaf/karrot_frontend:0.1.0"
configs:
- source: nginx_config
target: /etc/nginx/conf.d/default.conf
@ -11,10 +11,11 @@ services:
environment:
- DOMAIN
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/"]
interval: 30s
test: ["CMD", "curl", "-f", "http://localhost/api/bootstrap"]
interval: 15s
timeout: 3s
retries: 30
retries: 2
start_period: 45s
networks:
- internal
- proxy
@ -30,10 +31,9 @@ services:
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
- "coop-cloud.${STACK_NAME}.version=0.0.1+testing"
app:
image: "vlafvlaf/karrot_backend:test"
image: "vlafvlaf/karrot_backend:0.1.0"
networks:
- internal
depends_on:
@ -46,7 +46,17 @@ services:
environment:
- MAXMIND_ACCOUNT_ID
- MAXMIND_LICENSE_KEY
- SITE_URL=http://localhost:8000
- EMAIL_BACKEND
- EMAIL_FROM
- SMTP_USER
- SMTP_PASSWORD
- SMTP_HOST
- SMTP_USE_SLL
- SMTP_USE_TLS
- SMTP_PORT
- SITE_URL
- SITE_NAME
- SITE_LOGO
- LISTEN_HOST=0.0.0.0
- LISTEN_SERVER=uvicorn
- SECRET_KEY=foobar
@ -60,9 +70,13 @@ services:
- REDIS_DB=0
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/"]
interval: 30s
interval: 15s
timeout: 3s
retries: 90
retries: 2
start_period: 45s
deploy:
labels:
- "coop-cloud.${STACK_NAME}.version=0.1.0+0.1.0"
command: >
sh -c "
echo 'EditionIDs GeoLite2-City GeoLite2-Country' > /etc/GeoIP.conf &&
@ -75,7 +89,7 @@ services:
python karrot-backend.pyz server
"
worker:
image: "vlafvlaf/karrot_backend:test"
image: "vlafvlaf/karrot_backend:0.1.0"
depends_on:
# shiv + geoip data gets loaded on the first run of the app
# so to ensure it's available in the worker too, we need to wait
@ -86,7 +100,7 @@ services:
networks:
- internal
environment:
- SITE_URL=http://localhost:8000
- SITE_URL
- LISTEN_HOST=0.0.0.0
- LISTEN_SERVER=uvicorn
- SECRET_KEY=foobar
@ -137,10 +151,10 @@ services:
- POSTGRES_DB=karrot
secrets:
db_password:
external: true
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
#secrets:
# db_password:
# external: true
# name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
configs:
nginx_config:

View File

@ -1,4 +0,0 @@
FROM nginx:1.20.1-alpine
RUN curl https://download.karrot.world/karrot-frontend-production.zip -o karrot-frontend.zip && \
unzip -o karrot-frontend.zip -d /usr/share/nginx/html

View File

@ -1,64 +0,0 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name web;
root /usr/share/nginx/html;
location / {
try_files $uri /index.html;
if_modified_since off;
expires off;
etag off;
# TODO: csp headers
}
location /css {
expires max;
}
location /js {
expires max;
}
location /img {
expires max;
}
location /fonts {
expires max;
}
# /app/uploads
location /media/ {
alias /app/uploads/;
expires max;
}
location /community_proxy/ {
proxy_pass https://community.foodsaving.world/;
}
location ^\/(api(\-auth)?|docs|silk)\/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
# this port is whatever port 80 is mapped to outside the container
proxy_set_header Host $host:8080;
proxy_pass http://app:8000;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
proxy_set_header Sec-WebSocket-Protocol $http_sec_websocket_protocol;
proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
}
}