Skip to content

Commit

Permalink
add git rev and build date to docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Aug 27, 2023
1 parent 6d7295f commit 9fe58ad
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 119 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.venv
.vscode
.github
.git
.gitignore
.pre-commit-config.yaml
__pycache__
Expand Down
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,23 +35,23 @@ 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

WORKDIR /neodb
COPY misc/bin/* /bin/
RUN mkdir -p /www
RUN useradd -U app
RUN rm -rf /var/lib/apt/lists/*

USER app:app

Expand Down
13 changes: 0 additions & 13 deletions docker/entrypoint.sh

This file was deleted.

35 changes: 0 additions & 35 deletions docker/start.sh

This file was deleted.

Binary file removed favicon.ico
Binary file not shown.
17 changes: 10 additions & 7 deletions misc/bin/neodb-hello
Original file line number Diff line number Diff line change
@@ -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 <<EOF
check complete
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
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
1 change: 1 addition & 0 deletions misc/bin/neodb-init
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 0 additions & 29 deletions misc/dev-reset.sh

This file was deleted.

26 changes: 0 additions & 26 deletions misc/upgrade.sh

This file was deleted.

0 comments on commit 9fe58ad

Please sign in to comment.