Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ActivityPub support #345

Merged
merged 38 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
35803cb
takahe integration
Jul 21, 2023
663d8b9
cleanup migration
Aug 13, 2023
06e78f1
fetch remote identity
Aug 13, 2023
082a73c
federated follow/block/mute
Aug 14, 2023
4d68d93
support createsuperuser command
Aug 14, 2023
642624e
tweak user profile
Aug 14, 2023
e702e1d
reply; emoji
Aug 15, 2023
b400933
init db with nodename
Aug 16, 2023
542d84b
add takahe as submodule
Aug 17, 2023
1be0a0c
multi-staged docker build
Aug 19, 2023
1415655
add init command to ensure settings post migration
Aug 20, 2023
d14fb92
sync site config during boot; customize site logo
Aug 20, 2023
840fdf9
fix follower list
Aug 20, 2023
5f6531c
share to mastodon = reboost
Aug 20, 2023
597c336
add profile(production|dev) to docker setup
Aug 21, 2023
9e9d22c
edit nickname/icon/etc
Aug 22, 2023
16cd2ff
search fedi peers
Aug 22, 2023
0c1d020
fix test
Aug 23, 2023
5870cb9
make venv path configurable in docker
Aug 23, 2023
fbfceee
more configurable
Aug 24, 2023
826d283
remove opencc #346
Aug 24, 2023
72204fc
enable multiple posts associate with one piece
Aug 26, 2023
501a7a6
add git rev and build date to docker image
Aug 26, 2023
c26c16f
minor code and doc fix
Aug 29, 2023
f9de4b3
add dev tips for migration
Aug 29, 2023
014ff52
allow domain change but show warning if it is done after user creation
Sep 2, 2023
591f7e3
add config for invite-only mode
Sep 3, 2023
82b1334
upgrade some deps
Sep 15, 2023
5c13b82
improve type check
Sep 16, 2023
7050aaf
subscribe to default relay unless disabled in config
Sep 3, 2023
3cd1add
load settings from env/.env/neodb.conf
Sep 25, 2023
c733bd9
default DEBUG ON
Sep 25, 2023
3f5ff89
sync takahe
Sep 25, 2023
b31284c
publish after tests, deploy after publish
Sep 26, 2023
a0c34b5
use compose.yml
Oct 5, 2023
149a931
NEODB_SITE_INTRO and more documentation
Oct 20, 2023
7dd42d7
use rq for cron tasks
Oct 21, 2023
f7b4174
prepare for merge
Oct 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DS_Store
.env
.venv
.vscode
.github
.gitignore
.pre-commit-config.yaml
__pycache__
/compose.yml
/compose.override.yml
/Dockerfile
/doc
/media
/static
/test_data
/neodb
/neodb-takahe/doc
/neodb-takahe/docker
/neodb-takahe/static-collected
/neodb-takahe/takahe/local_settings.py
File renamed without changes.
11 changes: 7 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
name: Deployment
name: deployment
on:
workflow_run:
workflows: ["all tests"]
branches: [main]
workflows: ["publish"]
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
deployment:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Deployment
name: Preview Deployment
runs-on: ubuntu-latest
environment: preview
steps:
- name: ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: ${{ vars.DEPLOY_SCRIPT }}
44 changes: 0 additions & 44 deletions .github/workflows/django.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: publish

on:
workflow_run:
workflows: ["tests"]
branches:
- main
- activitypub
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build_and_push_image:
name: build image and push to Docker Hub
if: ${{ github.event.workflow_run.conclusion == 'success' }}
# if: github.repository_owner == 'neodb-social'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: 'true'

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: neodb/neodb

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: "linux/amd64,linux/arm64"
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: tests

on:
push:
pull_request:
branches: [ "main" ]

jobs:
django:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
db:
image: postgres
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: test_neodb
ports:
- 5432:5432
db2:
image: postgres
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: test_neodb_takahe
ports:
- 15432:5432
strategy:
max-parallel: 4
matrix:
python-version: ['3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install Dependencies
run: |
pip install -r requirements.txt
- name: Run Tests
env:
NEODB_DB_URL: postgres://testuser:testpass@127.0.0.1/test_neodb
TAKAHE_DB_URL: postgres://testuser:testpass@127.0.0.1/test_neodb_takahe
NEODB_REDIS_URL: redis://127.0.0.1:6379/0
NEODB_SITE_NAME: test
NEODB_SITE_DOMAIN: test.domain
NEODB_SECRET_KEY: test
run: |
python manage.py test
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "neodb-takahe"]
path = neodb-takahe
url = https://github.com/neodb-social/neodb-takahe.git
branch = neodb
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ repos:
rev: 22.12.0
hooks:
- id: black
language_version: python3.11

- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.32.1
Expand Down
75 changes: 51 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,58 @@
# syntax=docker/dockerfile:1
FROM python:3.11-slim-bullseye
FROM python:3.11-slim as build
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN --mount=type=cache,sharing=locked,target=/var/cache/apt apt-get update \
&& apt-get install -y --no-install-recommends build-essential libpq-dev python3-venv git

COPY . /neodb

RUN echo neodb-`cd /neodb && git rev-parse --short HEAD`-`cd /neodb/neodb-takahe && git rev-parse --short HEAD`-`date -u +%Y%m%d%H%M%S` > /neodb/version
RUN rm -rf /neodb/.git /neodb/neodb-takahe/.git

RUN mv /neodb/neodb-takahe /takahe

WORKDIR /neodb
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
RUN python -m venv /neodb-venv
RUN --mount=type=cache,sharing=locked,target=/root/.cache /neodb-venv/bin/python3 -m pip install --upgrade -r requirements.txt

WORKDIR /takahe
RUN python -m venv /takahe-venv
RUN --mount=type=cache,sharing=locked,target=/root/.cache /takahe-venv/bin/python3 -m pip install --upgrade -r requirements.txt

# runtime stage
FROM python:3.11-slim as runtime
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN --mount=type=cache,sharing=locked,target=/var/cache/apt-run apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev \
busybox \
postgresql-client \
nginx \
opencc \
git
COPY misc/nginx.conf.d/* /etc/nginx/conf.d/
RUN echo >> /etc/nginx/nginx.conf
RUN echo 'daemon off;' >> /etc/nginx/nginx.conf
RUN python3 -m pip install --no-cache-dir --upgrade -r requirements.txt
RUN apt-get purge -y --auto-remove \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*

RUN python3 manage.py compilescss \
&& python3 manage.py collectstatic --noinput
RUN cp -R misc/www /www
RUN mv static /www/static

# invoke check by default
CMD [ "python3", "/neodb/manage.py", "check" ]
gettext-base
RUN busybox --install

# postgresql and redis cli are not required, but install for development convenience
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt-run apt-get install -y --no-install-recommends postgresql-client redis-tools
RUN useradd -U app
RUN rm -rf /var/lib/apt/lists/*

COPY --from=build /neodb /neodb
WORKDIR /neodb
COPY --from=build /neodb-venv /neodb-venv
RUN NEODB_SECRET_KEY="t" NEODB_SITE_DOMAIN="x.y" NEODB_SITE_NAME="z" /neodb-venv/bin/python3 manage.py compilescss
RUN NEODB_SECRET_KEY="t" NEODB_SITE_DOMAIN="x.y" NEODB_SITE_NAME="z" /neodb-venv/bin/python3 manage.py collectstatic --noinput

COPY --from=build /takahe /takahe
WORKDIR /takahe
COPY --from=build /takahe-venv /takahe-venv
RUN TAKAHE_DATABASE_SERVER="postgres://x@y/z" TAKAHE_SECRET_KEY="t" TAKAHE_MAIN_DOMAIN="x.y" /takahe-venv/bin/python3 manage.py collectstatic --noinput

WORKDIR /neodb
COPY misc/bin/* /bin/
RUN mkdir -p /www

USER app:app

CMD [ "neodb-hello"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Boofilsic/NeoDB is an open source project and free service to help users manage,
* eligible items, e.g. podcasts and albums, are playable in feed
+ link Fediverse account and import social graph
+ share collections and reviews to Fediverse ~~and Twitter~~ feed
+ ActivityPub support is under development, a pre-alpha version is available for developers as [docker image](https://hub.docker.com/r/neodb/neodb)
+ ActivityPub support is under active development
- Other
+ i18n/language support are planned

Expand Down
Loading