Fixed Dockerfile

There is now a /data directory that contains the location.db, both
belonging to user app. This fixed permission issues and ensures
that the app does not try to write in a ro docker layer.
This commit is contained in:
Tim Staat 2026-05-20 17:45:52 +02:00
parent 0643f781a6
commit 21989f00cd
2 changed files with 6 additions and 3 deletions

View File

@ -5,10 +5,13 @@ WORKDIR /usr/local/app
COPY server/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY server/python_server.py
COPY server/python_server.py ./python_server.py
EXPOSE 8080
RUN useradd app
RUN useradd app && mkdir /data && touch /data/location.db && chown -R app /dataa
VOLUME /data
USER app
CMD ["gunicorn", "-w", "4", "python_server:app", "--bind", "0.0.0.0:8080"]

View File

@ -9,7 +9,7 @@ app = Flask(__name__)
bear_correction = False
with sqlite3.connect('location.db', check_same_thread=False) as conn:
with sqlite3.connect('/data/location.db', check_same_thread=False) as conn:
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS location_data (