diff --git a/.dockerignore b/.dockerignore index 22ed546c..211c6187 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,7 +3,6 @@ .venv .vscode .github -.git .gitignore .pre-commit-config.yaml __pycache__ diff --git a/Dockerfile b/Dockerfile index d2f1d237..09a3a005 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,18 +6,21 @@ 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 requirements.txt /neodb/ +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 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 -COPY neodb-takahe/requirements.txt /takahe/ 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 -RUN apt-get purge -y --auto-remove build-essential && rm -rf /var/lib/apt/lists/* - # runtime stage FROM python:3.11-slim as runtime ENV PYTHONDONTWRITEBYTECODE=1 @@ -32,14 +35,16 @@ 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 . /neodb +COPY --from=build /neodb /neodb WORKDIR /neodb COPY --from=build /neodb-venv /neodb-venv RUN /neodb-venv/bin/python3 manage.py compilescss RUN /neodb-venv/bin/python3 manage.py collectstatic --noinput -RUN mv /neodb/neodb-takahe /takahe +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 @@ -47,8 +52,6 @@ RUN TAKAHE_DATABASE_SERVER="postgres://x@y/z" TAKAHE_SECRET_KEY="t" TAKAHE_MAIN_ WORKDIR /neodb COPY misc/bin/* /bin/ RUN mkdir -p /www -RUN useradd -U app -RUN rm -rf /var/lib/apt/lists/* USER app:app diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100755 index a6bcc670..00000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o pipefail -set -o nounset - -python manage.py collectstatic --noinput -python manage.py makemigrations users books movies games music sync mastodon management collection -python manage.py makemigrations -python manage.py migrate users -python manage.py migrate - -exec "$@" diff --git a/docker/start.sh b/docker/start.sh deleted file mode 100755 index 1f30402e..00000000 --- a/docker/start.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -cd /app - -if [ $# -eq 0 ]; then - echo "Usage: start.sh " - exit 1 -fi - -PROCESS_TYPE=$1 - -if [ "$PROCESS_TYPE" = "server" ]; then - if [ "$DJANGO_DEBUG" = "true" ]; then - gunicorn \ - --reload \ - --bind 0.0.0.0:8000 \ - --workers 2 \ - --worker-class eventlet \ - --log-level DEBUG \ - --access-logfile "-" \ - --error-logfile "-" \ - boofilsic.wsgi - else - gunicorn \ - --bind 0.0.0.0:8000 \ - --workers 2 \ - --worker-class eventlet \ - --log-level DEBUG \ - --access-logfile "-" \ - --error-logfile "-" \ - boofilsic.wsgi - fi -elif [ "$PROCESS_TYPE" = "rq" ]; then - rqworker --with-scheduler doufen export mastodon -fi diff --git a/favicon.ico b/favicon.ico deleted file mode 100644 index 2f24c2dd..00000000 Binary files a/favicon.ico and /dev/null differ diff --git a/misc/bin/neodb-hello b/misc/bin/neodb-hello index 67df4ee6..17931bba 100755 --- a/misc/bin/neodb-hello +++ b/misc/bin/neodb-hello @@ -1,18 +1,21 @@ #!/bin/sh echo '\033[0;35m====== Welcome to NeoDB ======\033[0m' +cat /neodb/version echo Your configuration is for ${NEODB_SITE_NAME} on ${NEODB_SITE_DOMAIN} -[[ -z "${NEODB_DEBUG}" ]] || echo DEBUG is ON +[[ -z "${NEODB_DEBUG}" ]] || echo DEBUG is ON, showing environment variables: [[ -z "${NEODB_DEBUG}" ]] || env -echo Running some basic checks... -neodb-manage check -TAKAHE_DATABASE_SERVER="postgres://x@y/z" TAKAHE_SECRET_KEY="t" TAKAHE_MAIN_DOMAIN="x.y" takahe-manage check +[[ -z "${NEODB_DEBUG}" ]] || echo Running some basic checks... +[[ -z "${NEODB_DEBUG}" ]] || neodb-manage check +[[ -z "${NEODB_DEBUG}" ]] || TAKAHE_DATABASE_SERVER="postgres://x@y/z" TAKAHE_SECRET_KEY="t" TAKAHE_MAIN_DOMAIN="x.y" takahe-manage check +[[ -z "${NEODB_DEBUG}" ]] || echo check complete. cat < +start NeoDB (root) shell: docker compose run start NeoDB instance: docker compose --profile up -d +stop NeoDB instance: docker compose --profile down -d +update NeoDB instance: docker compose --profile pull -Please follow latest documentations on https://neodb.net to configure your instance before continuing. +Please follow instructions on https://neodb.net to configure and run your instance. EOF diff --git a/misc/bin/neodb-init b/misc/bin/neodb-init index 36e5fefe..03b5b150 100755 --- a/misc/bin/neodb-init +++ b/misc/bin/neodb-init @@ -1,5 +1,6 @@ #!/bin/sh echo '\033[0;35m====== Welcome to NeoDB ======\033[0m' +cat /neodb/version echo Your configuration is for ${NEODB_SITE_NAME} on ${NEODB_SITE_DOMAIN} [[ -z "${NEODB_DEBUG}" ]] || echo DEBUG is ON, show environment: [[ -z "${NEODB_DEBUG}" ]] || env diff --git a/misc/dev-reset.sh b/misc/dev-reset.sh deleted file mode 100755 index ecfd89b0..00000000 --- a/misc/dev-reset.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Reset databases and migrations, for development only - -[ -f manage.py ] || exit $1 - -echo "\033[0;31mWARNING: this script will destroy all neodb databases and migrations" -while true; do - read -p "Do you wish to continue? (yes/no) " yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - esac -done - -psql $* postgres -c "DROP DATABASE IF EXISTS neodb;" || exit $? - -psql $* postgres -c "DROP DATABASE IF EXISTS test_neodb;" || exit $? - -psql $* postgres -c "CREATE DATABASE neodb ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE template0;" || exit $? - -find -type d -name migrations | xargs rm -rf - -python3 manage.py makemigrations mastodon users management common catalog journal social legacy - -python3 manage.py migrate || exit $? - -psql $* neodb -c "CREATE DATABASE test_neodb WITH TEMPLATE neodb;" || exit $? - -python3 manage.py check diff --git a/misc/upgrade.sh b/misc/upgrade.sh deleted file mode 100755 index 9887bb28..00000000 --- a/misc/upgrade.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -[ -f manage.py ] || exit -echo Dry Run MakeMigrations: -python3 manage.py makemigrations --dry-run || exit $? -echo Planned Migrations: -python3 manage.py migrate --plan || exit $? - -while true; do - read -p "Do you wish to continue? (yes/no) " yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - esac -done - -echo "Generating static files..." -python3 manage.py compilescss || exit $? -python3 manage.py collectstatic --noinput || exit $? - -echo "Migrating database..." -python3 manage.py migrate || exit $? - -echo "Checking..." -python3 manage.py check || exit $? - -echo "Done. You may reload app, worker and cron"