Skip to content

Database data resets everytime I restart the container. #20

@JoacoG

Description

@JoacoG

Describe the bug
I installed the webhook using the docker container. When I reset the container using docker compose ... down and docker compose ... up, data is wiped out.

To Reproduce
Steps to reproduce the behavior:

  1. Install the webhook using docker compose -f central/docker-compose.yml -f docker/central-webhook/compose.webhook.yml up -d
  2. Restart the container using docker compose -f central/docker-compose.yml -f docker/central-webhook/compose.webhook.yml down and then docker compose -f central/docker-compose.yml -f docker/central-webhook/compose.webhook.yml up -d again
  3. Data is wiped out in db

Expected behavior
Database to be the same each time central is restarted.

Screenshots
None

Additional context

I was looking at central folder. Here is the docker file for the PostgreSQL db there.

FROM postgres:14.10

COPY files/postgres14/start-postgres.sh /usr/local/bin/

# PGDATA is originally declared in the parent Dockerfile, but points
# to an anonymous VOLUME declaration in the same file:
#
#   ENV PGDATA /var/lib/postgresql/data
#   ...
#   VOLUME /var/lib/postgresql/data
#
# To ensure future accessibility, PGDATA must be stored _outside_ the
# anonymous volume.
ENV PGDATA=/var/lib/odk/postgresql/14/data

ENTRYPOINT []

I think the images you built for postgres do not have this configuration. See pgsql-http.dockerfile in central-webhook repo.

# Postgres v14
FROM postgres:14 AS pg-14

RUN apt-get update \
    && apt-get install -y postgresql-14-http \
    && rm -rf /var/lib/apt/lists/*

# Postgres v15
FROM postgres:15 AS pg-15

RUN apt-get update \
    && apt-get install -y postgresql-15-http \
    && rm -rf /var/lib/apt/lists/*

# Postgres v16
FROM postgres:16 AS pg-16

RUN apt-get update \
    && apt-get install -y postgresql-16-http \
    && rm -rf /var/lib/apt/lists/*

# Postgres v17
FROM postgres:17 AS pg-17

RUN apt-get update \
    && apt-get install -y postgresql-17-http \
    && rm -rf /var/lib/apt/lists/*

# Postgres v18
FROM postgres:18 AS pg-18

RUN apt-get update \
    && apt-get install -y postgresql-18-http \
    && rm -rf /var/lib/apt/lists/*

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions