New WaitingListEntry #33

Merged
valberg merged 10 commits from benjaoming/membersystem:waiting-list into main 2024-07-31 22:49:48 +00:00
7 changed files with 21 additions and 51 deletions
Showing only changes of commit b366bc2499 - Show all commits

View file

@ -7,7 +7,6 @@ steps:
- name: docker - name: docker
image: plugins/docker image: plugins/docker
environment: environment:
DJANGO_ENV: production
BUILD: "${DRONE_COMMIT_SHA}" BUILD: "${DRONE_COMMIT_SHA}"
settings: settings:
repo: docker.data.coop/membersystem repo: docker.data.coop/membersystem
@ -17,7 +16,6 @@ steps:
password: password:
from_secret: DOCKER_PASSWORD from_secret: DOCKER_PASSWORD
build_args_from_env: build_args_from_env:
- DJANGO_ENV
- BUILD - BUILD
tags: tags:
- "${DRONE_BUILD_NUMBER}" - "${DRONE_BUILD_NUMBER}"

View file

@ -6,4 +6,3 @@ DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
# Use something along the the following if you are not using docker # Use something along the the following if you are not using docker
# DATABASE_URL=postgres://postgres:postgres@localhost:5432/datacoop_membersystem # DATABASE_URL=postgres://postgres:postgres@localhost:5432/datacoop_membersystem
DEBUG=True DEBUG=True
DJANGO_ENV=development

View file

@ -7,16 +7,12 @@ ENV PYTHONFAULTHANDLER=1 \
PIP_NO_CACHE_DIR=off \ PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \ PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 PIP_DEFAULT_TIMEOUT=100
ARG DJANGO_ENV
ARG BUILD ARG BUILD
ENV BUILD ${BUILD} ENV BUILD ${BUILD}
WORKDIR /app WORKDIR /app
RUN groupadd -g 1000 www && useradd -u 1000 -ms /bin/bash -g www www RUN groupadd -g 1000 www && useradd -u 1000 -ms /bin/bash -g www www \
COPY --chown=www:www . .
RUN mkdir /app/src/static \
&& chown www:www /app/src/static \
&& apt-get update \ && apt-get update \
&& apt-get install -y \ && apt-get install -y \
binutils \ binutils \
@ -29,8 +25,14 @@ RUN mkdir /app/src/static \
libgdk-pixbuf2.0-0 \ libgdk-pixbuf2.0-0 \
libffi-dev \ libffi-dev \
shared-mime-info \ shared-mime-info \
gettext \ gettext
&& pip install . \
COPY --chown=www:www . .
RUN mkdir /app/src/static \
&& chown www:www /app/src/static
RUN pip install . \
&& django-admin compilemessages && django-admin compilemessages
ENTRYPOINT ["./entrypoint.sh"] ENTRYPOINT ["./entrypoint.sh"]

View file

@ -1,6 +1,5 @@
DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose DOCKER_COMPOSE = COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose
DOCKER_RUN = ${DOCKER_COMPOSE} run -u `id -u` DOCKER_RUN = ${DOCKER_COMPOSE} run -u `id -u`
DOCKER_BUILD = DOCKER_BUILDKIT=1 docker build
DOCKER_CONTAINER_NAME = backend DOCKER_CONTAINER_NAME = backend
MANAGE_EXEC = python /app/src/manage.py MANAGE_EXEC = python /app/src/manage.py
MANAGE_COMMAND = ${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} ${MANAGE_EXEC} MANAGE_COMMAND = ${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} ${MANAGE_EXEC}
@ -10,12 +9,6 @@ init: setup_venv pre_commit_install migrate
run: run:
${DOCKER_COMPOSE} up ${DOCKER_COMPOSE} up
setup_venv:
rm -rf venv
python3.11 -m venv venv;
venv/bin/python -m pip install wheel setuptools;
venv/bin/python -m pip install pre-commit boto3 pip-tools;
pre_commit_install: pre_commit_install:
venv/bin/pre-commit install venv/bin/pre-commit install
@ -37,22 +30,5 @@ shell:
manage_command: manage_command:
${MANAGE_COMMAND} ${ARGS} ${MANAGE_COMMAND} ${ARGS}
add_dependency: build_dev_docker_image:
${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} poetry add --lock ${DEPENDENCY}
add_dev_dependency:
${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} poetry add -D --lock ${DEPENDENCY}
poetry_lock:
${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} poetry lock --no-update
poetry_command:
${DOCKER_RUN} ${DOCKER_CONTAINER_NAME} poetry ${COMMAND}
build_dev_docker_image: compile_requirements
${DOCKER_COMPOSE} build ${DOCKER_CONTAINER_NAME} ${DOCKER_COMPOSE} build ${DOCKER_CONTAINER_NAME}
compile_requirements:
./venv/bin/pip-compile --output-file requirements/base.txt requirements/base.in
./venv/bin/pip-compile --output-file requirements/test.txt requirements/test.in
./venv/bin/pip-compile --output-file requirements/dev.txt requirements/dev.in

View file

@ -56,7 +56,7 @@ Activate the venv
Install requirements Install requirements
$ pip install -r requirements/dev.txt $ pip install .
Run migrations Run migrations

View file

@ -1,5 +1,3 @@
version: '3.7'
services: services:
backend: backend:
@ -13,7 +11,8 @@ services:
volumes: volumes:
- ./:/app/ - ./:/app/
depends_on: depends_on:
- postgres postgres:
condition: service_healthy
env_file: env_file:
- .env - .env
@ -25,6 +24,13 @@ services:
- 5432:5432 - 5432:5432
env_file: env_file:
- .env - .env
# This healthcheck has a large number of retries, this is currently based on the number of
# retries necessary to get the database running in GitHub Actions.
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres -d postgres" ]
interval: 5s
timeout: 5s
retries: 30
benjaoming marked this conversation as resolved Outdated

@valberg this is where I added the healthcheck 🤦

@valberg this is where I added the healthcheck 🤦

Roger - the thing is that this compose file is for development, whereas the one we use for production is placed in https://git.data.coop/data.coop/ansible/src/branch/main/roles/docker/templates/compose-files/membersystem.yml.j2

With the current entrypoint one does not have to keep this health check in mind.

Roger - the thing is that this compose file is for development, whereas the one we use for production is placed in https://git.data.coop/data.coop/ansible/src/branch/main/roles/docker/templates/compose-files/membersystem.yml.j2 With the current entrypoint one does not have to keep this health check in mind.

Aaaah, I get that now. This was intended to simplify things, but of course that's not the case when the deployment could benefit from the other method 👍 thanks for explaining! I took this method from a setup where Docker Compose was also for deployment :)

Aaaah, I get that now. This was intended to simplify things, but of course that's not the case when the deployment could benefit from the other method 👍 thanks for explaining! I took this method from a setup where Docker Compose was also for deployment :)

Reverted!

Reverted!

You're welcome! We could put in the work to make it work for both. But since the membersystem is pretty much a single deployment project, I'm unsure of the benefit of doing said work 😊

You're welcome! We could put in the work to make it work for both. But since the membersystem is pretty much a single deployment project, I'm unsure of the benefit of doing said work 😊

I think the main priority should be that all our data.coop services are somehow deployed in the same/similar way... but then their development environment can be allowed to drift.

Reasoning would be that we could have many people doing deployment/ops, and they should be required minimal familiarity with each project that we deploy?

So in this case, I think your choice was 💯 - i.e. make entrypoint.sh fit with the deployment, then let aspects of development setup come secondary.

I think the main priority should be that all our data.coop services are somehow deployed in the same/similar way... but then their development environment can be allowed to drift. Reasoning would be that we could have many people doing deployment/ops, and they should be required minimal familiarity with each project that we deploy? So in this case, I think your choice was 💯 - i.e. make entrypoint.sh fit with the deployment, then let aspects of development setup come secondary.
volumes: volumes:
postgres_data: postgres_data:

View file

@ -1,16 +1,5 @@
#!/bin/sh #!/bin/sh
echo "Waiting for postgres..."
POSTGRES_PORT=${POSTGRES_PORT:-5432}
POSTGRES_HOST=${POSTGRES_HOST:-localhost}
while ! nc -z "$POSTGRES_HOST" "$POSTGRES_PORT"; do
sleep 0.1
done
echo "PostgreSQL started"
# Only migrate, collectstatic and compilemessages if we are NOT in development # Only migrate, collectstatic and compilemessages if we are NOT in development
if [ -z "$DEBUG" ]; then if [ -z "$DEBUG" ]; then
python src/manage.py migrate; python src/manage.py migrate;