diff --git a/Dockerfile b/Dockerfile index 34a6cc6..c1ce59e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,11 @@ COPY --from=pybuilder /code /dist # copy the frontend static files from the builder COPY --from=builder ./dist /dist/ WORKDIR /dist +# create dir for save +RUN mkdir save EXPOSE 5001 ENV PATH=/root/.local/bin:${PATH} +VOLUME /dist/save ENTRYPOINT ["python", "/dist/server.py"] diff --git a/backend/server.py b/backend/server.py index 2c5a2b6..d726ab2 100644 --- a/backend/server.py +++ b/backend/server.py @@ -813,13 +813,13 @@ def save_games(): while True: sio.sleep(2) if not save_lock: - with open('games.pickle', 'wb') as f: + with open('./save/games.pickle', 'wb') as f: pickle.dump([g for g in games if g.started and not g.is_replay and not g.is_hidden], f) if __name__ == '__main__': - if os.path.exists('games.pickle'): + if os.path.exists('./save/games.pickle'): try: - with open('games.pickle', 'rb') as file: + with open('./save/games.pickle', 'rb') as file: games = pickle.load(file) for g in games: for p in g.players: