Added data persistance to memory server

This commit is contained in:
DustyPullRequest 2025-04-07 14:09:42 -04:00 committed by GitHub
parent 608ec8fd72
commit 451c207592
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View File

@ -9,9 +9,13 @@ services:
context: ./servers/memory
ports:
- 8082:8000
volumes:
- memory:/app/data:rw
time-server:
build:
context: ./servers/time
ports:
- 8083:8000
volumes:
memory:

View File

@ -38,8 +38,11 @@ RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
python -m pip install -r requirements.txt
# Change the ownership of /app directory and its contents to appuser
RUN chown -R ${UID}:${UID} /app
# Change the ownership of /app/data directory and its contents to appuser
RUN mkdir -p /app/data && touch /app/data/memory.json && chown -R ${UID}:${UID} /app/data
# Set a flag for the location of the database
ENV MEMORY_FILE_PATH="/app/data/memory.json"
# Switch to the non-privileged user to run the application.
USER appuser

View File

@ -4,4 +4,9 @@ services:
context: .
ports:
- 8000:8000
volumes:
- memory:/app/data:rw
volumes:
memory: