add git rev and build date to docker image
This commit is contained in:
parent
4cd1f6b10d
commit
c09e73e624
9 changed files with 22 additions and 119 deletions
|
@ -3,7 +3,6 @@
|
||||||
.venv
|
.venv
|
||||||
.vscode
|
.vscode
|
||||||
.github
|
.github
|
||||||
.git
|
|
||||||
.gitignore
|
.gitignore
|
||||||
.pre-commit-config.yaml
|
.pre-commit-config.yaml
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|
19
Dockerfile
19
Dockerfile
|
@ -6,18 +6,21 @@ ENV PYTHONUNBUFFERED=1
|
||||||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt apt-get update \
|
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
|
&& 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
|
WORKDIR /neodb
|
||||||
RUN python -m venv /neodb-venv
|
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
|
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
|
WORKDIR /takahe
|
||||||
RUN python -m venv /takahe-venv
|
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 --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
|
# runtime stage
|
||||||
FROM python:3.11-slim as runtime
|
FROM python:3.11-slim as runtime
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
@ -32,14 +35,16 @@ RUN busybox --install
|
||||||
|
|
||||||
# postgresql and redis cli are not required, but install for development convenience
|
# 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 --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
|
WORKDIR /neodb
|
||||||
COPY --from=build /neodb-venv /neodb-venv
|
COPY --from=build /neodb-venv /neodb-venv
|
||||||
RUN /neodb-venv/bin/python3 manage.py compilescss
|
RUN /neodb-venv/bin/python3 manage.py compilescss
|
||||||
RUN /neodb-venv/bin/python3 manage.py collectstatic --noinput
|
RUN /neodb-venv/bin/python3 manage.py collectstatic --noinput
|
||||||
|
|
||||||
RUN mv /neodb/neodb-takahe /takahe
|
COPY --from=build /takahe /takahe
|
||||||
WORKDIR /takahe
|
WORKDIR /takahe
|
||||||
COPY --from=build /takahe-venv /takahe-venv
|
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
|
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
|
WORKDIR /neodb
|
||||||
COPY misc/bin/* /bin/
|
COPY misc/bin/* /bin/
|
||||||
RUN mkdir -p /www
|
RUN mkdir -p /www
|
||||||
RUN useradd -U app
|
|
||||||
RUN rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
USER app:app
|
USER app:app
|
||||||
|
|
||||||
|
|
|
@ -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 "$@"
|
|
|
@ -1,35 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd /app
|
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
echo "Usage: start.sh <server|rq>"
|
|
||||||
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
|
|
BIN
favicon.ico
BIN
favicon.ico
Binary file not shown.
Before Width: | Height: | Size: 4.1 KiB |
|
@ -1,18 +1,21 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo '\033[0;35m====== Welcome to NeoDB ======\033[0m'
|
echo '\033[0;35m====== Welcome to NeoDB ======\033[0m'
|
||||||
|
cat /neodb/version
|
||||||
echo Your configuration is for ${NEODB_SITE_NAME} on ${NEODB_SITE_DOMAIN}
|
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
|
[[ -z "${NEODB_DEBUG}" ]] || env
|
||||||
echo Running some basic checks...
|
[[ -z "${NEODB_DEBUG}" ]] || echo Running some basic checks...
|
||||||
neodb-manage check
|
[[ -z "${NEODB_DEBUG}" ]] || 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}" ]] || 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 <<EOF
|
cat <<EOF
|
||||||
check complete
|
|
||||||
|
|
||||||
check Docker Compose version: docker compose version
|
check Docker Compose version: docker compose version
|
||||||
start NeoDB (root) shell: docker compose run -it <shell|root>
|
start NeoDB (root) shell: docker compose run <shell|root>
|
||||||
start NeoDB instance: docker compose --profile <production|dev> up -d
|
start NeoDB instance: docker compose --profile <production|dev> up -d
|
||||||
|
stop NeoDB instance: docker compose --profile <production|dev> down -d
|
||||||
|
update NeoDB instance: docker compose --profile <production|dev> 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
|
EOF
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo '\033[0;35m====== Welcome to NeoDB ======\033[0m'
|
echo '\033[0;35m====== Welcome to NeoDB ======\033[0m'
|
||||||
|
cat /neodb/version
|
||||||
echo Your configuration is for ${NEODB_SITE_NAME} on ${NEODB_SITE_DOMAIN}
|
echo Your configuration is for ${NEODB_SITE_NAME} on ${NEODB_SITE_DOMAIN}
|
||||||
[[ -z "${NEODB_DEBUG}" ]] || echo DEBUG is ON, show environment:
|
[[ -z "${NEODB_DEBUG}" ]] || echo DEBUG is ON, show environment:
|
||||||
[[ -z "${NEODB_DEBUG}" ]] || env
|
[[ -z "${NEODB_DEBUG}" ]] || env
|
||||||
|
|
|
@ -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
|
|
|
@ -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"
|
|
Loading…
Add table
Reference in a new issue