Add more complete containerization

This commit is contained in:
R. Miles McCain 2020-04-14 14:57:27 -04:00
parent db6dee5d69
commit 4041c3256d
No known key found for this signature in database
GPG Key ID: 91CB47BDDF2671A5
6 changed files with 126 additions and 4 deletions

3
.gitignore vendored
View File

@ -127,4 +127,7 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
# Secrets & env
secrets.yml
.vscode .vscode

View File

@ -2,6 +2,11 @@ FROM python:3
WORKDIR /usr/src/shynet WORKDIR /usr/src/shynet
# URL from https://github.com/shlinkio/shlink/issues/596 :)
RUN curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=G4Lm0C60yJsnkdPi&suffix=tar.gz" | tar -xvz -C /tmp
RUN curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=G4Lm0C60yJsnkdPi&suffix=tar.gz" | tar -xvz -C /tmp
RUN mv /tmp/GeoLite2*/*.mmdb /etc
RUN pip install pipenv RUN pip install pipenv
COPY Pipfile.lock ./ COPY Pipfile.lock ./
COPY Pipfile ./ COPY Pipfile ./

View File

@ -1,2 +1,4 @@
# shynet # Shynet
Minimalist, privacy-oriented, and self-hosted web analytics Shynet is a minimalist, privacy-focused web analytics tool.
I'll write real documentation soon (by May 2020). In the meantime, I'm making the repository public so that anyone can easily pull the docker images and deploy.

View File

@ -0,0 +1,86 @@
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "shynet-webserver"
namespace: "default"
labels:
app: "shynet-webserver"
spec:
replicas: 3
selector:
matchLabels:
app: "shynet-webserver"
template:
metadata:
labels:
app: "shynet-webserver"
spec:
containers:
- name: "covideo-webserver"
image: "docker.pkg.github.com/milesmcc/shynet/shynet:latest"
command: ["./webserver.sh"]
imagePullPolicy: Always
envFrom:
- secretRef:
name: django-settings
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "shynet-celeryworker"
namespace: "default"
labels:
app: "shynet-celeryworker"
spec:
replicas: 3
selector:
matchLabels:
app: "shynet-celeryworker"
template:
metadata:
labels:
app: "shynet-celeryworker"
spec:
containers:
- name: "covideo-celeryworker"
image: "docker.pkg.github.com/milesmcc/shynet/shynet:latest"
command: ["./celeryworker.sh"]
imagePullPolicy: Always
envFrom:
- secretRef:
name: django-settings
---
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
ports:
- port: 6379
name: redis
clusterIP: None
selector:
app: redis
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: redis
spec:
selector:
matchLabels:
app: redis
serviceName: redis
replicas: 1
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:latest
imagePullPolicy: Always
ports:
- containerPort: 6379
name: redis

View File

@ -0,0 +1,26 @@
apiVersion: v1
kind: Secret
metadata:
name: django-settings
type: Opaque
stringData:
# Django settings
DEBUG: "False"
ALLOWED_HOSTS: "*" # For better security, set this to your deployment's domain. Comma separated.
DJANGO_SECRET_KEY: ""
# Redis configuration (if you use the default Kubernetes config, this will work)
REDIS_CACHE_LOCATION: "redis://redis.default.svc.cluster.local/0"
CELERY_BROKER_URL: "redis://redis.default.svc.cluster.local/1"
# PostgreSQL settings
DB_NAME: ""
DB_USER: ""
DB_PASSWORD: ""
DB_HOST: ""
# Email settings
EMAIL_HOST_USER: ""
EMAIL_HOST_PASSWORD: ""
EMAIL_HOST: ""
SERVER_EMAIL: "Shynet <noreply@shynet.example.com>"

View File

@ -161,8 +161,8 @@ CELERY_REDIS_SOCKET_TIMEOUT = 15
# GeoIP # GeoIP
MAXMIND_CITY_DB = os.getenv("MAXMIND_CITY_DB") MAXMIND_CITY_DB = os.getenv("MAXMIND_CITY_DB", "/etc/GeoLite2-City.mmdb")
MAXMIND_ASN_DB = os.getenv("MAXMIND_ASN_DB") MAXMIND_ASN_DB = os.getenv("MAXMIND_ASN_DB", "/etc/GeoLite2-ASN.mmdb")
MESSAGE_TAGS = { MESSAGE_TAGS = {