forked from doubaniux/boofilsic
-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
199 changed files
with
8,726 additions
and
2,010 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,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 |
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,4 +1,4 @@ | ||
name: check | ||
name: code check | ||
|
||
on: [push, pull_request] | ||
|
||
|
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,21 +1,24 @@ | ||
name: Deployment | ||
name: preview deployment | ||
on: | ||
workflow_run: | ||
workflows: ["all tests"] | ||
branches: [main] | ||
workflows: ["docker image"] | ||
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: deployment to preview environment | ||
runs-on: ubuntu-latest | ||
environment: preview | ||
environment: ${{ vars.DEPLOY_ENV }} | ||
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 }} |
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
name: docker image | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["unit test"] | ||
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 }} |
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,55 @@ | ||
name: unit test | ||
|
||
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:[email protected]/test_neodb | ||
TAKAHE_DB_URL: postgres://testuser:[email protected]/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 |
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
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"] |
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.