djbrown / spielerplus-calendar

1 stars 1 forks source link

Some questions #1

Closed odin568 closed 1 year ago

odin568 commented 1 year ago

Hi @djbrown Just stumbled on your repo. Seems exactly what I need. I want to get calendar events as ICS for my SpielerPlus Account. Do you have some documentation on how to use, especially how to configure? Managed to clone and start. Ended with missing config.json. Copied over the one from test - but not sure where to get the identity from... Thanks for your help!

djbrown commented 1 year ago

@odin568 glad to hear you find this project useful :)

The identity value for the config.json comes from the _identity cookie. You can access the cookie value from the the browser settings or DevTools (e.g. Firefox or Chrome).

Does this work for you? If yes, I would add this to the README.

odin568 commented 1 year ago

Thanks so far, got this one.

Anyhow, I'm still confused. What do I need to add as Server in the config? spielerplus.de? Can you perhaps share a template config?

I don't fully get the complete setup. I expect to run the server and access /team/0/ for example. So I am part of a team and want to access the calendar events - I would expect it then provides a download of the ics?

Thanks for helping me in this area :)

odin568 commented 1 year ago

Ah okay, I got it. The cookie is already encoded from the debugger. We need the decoded in the configuration :)

odin568 commented 1 year ago

What I would love to see is having some docker support. This makes it way easier to use it. I don't have so much python / poetry knowledge, but think this would work and only thing missing is injecting the config.json file.

FROM python:3.10-slim as python-base

# https://python-poetry.org/docs#ci-recommendations
ENV POETRY_VERSION=1.5.0
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv

# Tell Poetry where to place its cache and virtual environment
ENV POETRY_CACHE_DIR=/opt/.cache

# Create stage for Poetry installation
FROM python-base as poetry-base

# Creating a virtual environment just for poetry and install it with pip
RUN python3 -m venv $POETRY_VENV \
    && $POETRY_VENV/bin/pip install -U pip setuptools \
    && $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}

# Create a new stage from the base python image
FROM python-base as example-app

# Copy Poetry to app image
COPY --from=poetry-base ${POETRY_VENV} ${POETRY_VENV}

# Add Poetry to PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"

WORKDIR /app

# Copy Dependencies
COPY poetry.lock pyproject.toml ./

# [OPTIONAL] Validate the project is properly configured
RUN poetry check

# Install Dependencies
RUN poetry install --no-interaction --no-cache --without dev

# Copy Application
COPY ./spielerplus_calendar ./spielerplus_calendar

# Run Application
EXPOSE 5000
CMD [ "poetry", "run", "python", "-m", "flask", "--app=spielerplus_calendar/server.py", "run", "--host=0.0.0.0" ]

Built and executed with following commands

docker build . --tag sp:latest
docker run -p 5000:5000 -v ${pwd}/config.json:/app/config.json:ro sp:latest

Can you review if commands make sense? :) Of course would love to have it integrated otherwise will make a fork for it.

How to start it with gunicorn? Did not get that running.

Thanks a lot!

odin568 commented 1 year ago

--updated above comment --

odin568 commented 1 year ago

See fork with working pipeline. Requires only variables for dockerhub username and token: https://github.com/odin568/spielerplus-calendar

djbrown commented 1 year ago

I have added a descrition of how to configure the project see d126b45.

Merged your improvements regarding docker image see #2. Docker build is successfull locally as well as on GitHub Actions. Image from Docker Hub works locally. The runtime mount with ${pwd} didn't work for me, had to use $(pwd). I also added description of Docker usage to the docs see 8dab27e.

Does that work for you, do you need anything else?

odin568 commented 1 year ago

Thanks a lot - works fine! Perhaps you can mention that you need to provide the identity value from the cookie as decoded value. Developer console gives it to me encoded. Code then encodes it again which fails then.

Another thing: Can you help in making the docker container "production ready" by not using flask? I failed getting it running with gunicorn what I see you propose to do.

Thanks a lot for your effort and this brilliant tool :-)

djbrown commented 1 year ago

I have added some clarifying sentences regarding identity encoding see 1c46f68.

And also updated the docker image to use gunicorn see b8d2f27.

There are many other possible improvements to make the project more robust, but I don't think it's worth it at this stage and scope. I'll go ahead and close this issue. If you have other questions or improvements feel free to post them in new issues or pull requests 😉.