Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up rss-bridge service #2788

Merged
merged 1 commit into from
Feb 2, 2022
Merged

Conversation

dbelokon
Copy link
Contributor

@dbelokon dbelokon commented Feb 1, 2022

Issue This PR Addresses

#2728 This PR sets up the microservice that will provide the Twitch RSS feed

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

This PR adds a 3rd party microservice, which generates RSS feeds of Twitch channels. This will be used further to close #2728.

Steps to test the PR

  • pnpm run services:start -> builds the service
  • Go to localhost:3123 -> a webpage of rss-bridge should appear
  • Write a Twitch user name
  • Press the Atom button
  • You should be able to download/preview the feed generated from the Twitch channel

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@gitpod-io
Copy link

gitpod-io bot commented Feb 1, 2022

@dbelokon
Copy link
Contributor Author

dbelokon commented Feb 1, 2022

I would need some help to set up the microservice properly, as I have no idea how it is supposed to be set up. I tried to check how other services are set up, but I don't have a clue how they work.

If anybody would like to help, the documentation for rss-bridge can be found here. I followed their Docker installation.

@sirinoks sirinoks added the help wanted Extra attention is needed label Feb 1, 2022
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Some changes to make this usable in our system.

config/rss-bridge/config.ini.php Outdated Show resolved Hide resolved
config/rss-bridge/config.ini.php Outdated Show resolved Hide resolved
docker/docker-compose.yml Show resolved Hide resolved
volumes:
- ../config/rss-bridge:/config
ports:
- 3123:80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't bind this to port 80 on the host, as this is occupied by Traefik (our API router). Traefik is responsible for routing all requests to our services via a unified URL structure (e.g., Posts service is at /v1/posts, the Search service is at /v1/search, etc.)

This new RSS-Bridge service can be made to follow the same pattern, if we add Traefik routing information to the container. We do that with custom labels. In docker/docker-compose.yml do this:

  rss-bridge:
    image: rssbridge/rss-bridge:2022-01-20
    container_name: 'rss-bridge'
    volumes:
      - ../config/rss-bridge:/config
    depends_on:
      - traefik
    labels:
      # Enable Traefik
      - 'traefik.enable=true'
      # Traefik routing for the rss-bridge service at /v1/rss-bridge
      - 'traefik.http.routers.search.rule=PathPrefix(`/${API_VERSION}/rss-bridge`)'
      # Specify the RSS-Bridge service port
      - 'traefik.http.services.search.loadbalancer.server.port=3123'
      # Add middleware to this route to strip the /v1/rss-bridge prefix
      - 'traefik.http.middlewares.strip_rss_bridge_prefix.stripprefix.prefixes=/${API_VERSION}/rss-bridge'
      - 'traefik.http.middlewares.strip_rss_bridge_prefix.stripprefix.forceSlash=true'
      - 'traefik.http.routers.rss_bridge.middlewares=strip_search_prefix'

Then in docker/production.yml add this (to have the container auto-restart if it crashes):

rss-bridge:
  restart: unless-stopped

Now when you start the services (pnpm services:start) you should have http://localhost/v1/rss-bridge available, and similarly on api.telescope.cdot.systems/v1/rss-bridge in production and dev.api.telescope.cdot.systems/v1/rss-bridge in staging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one small problem.

So, I was testing whether the service is working fine, but it seems that it is lacking some static files. Instead of hitting localhost/v1/rss-bridge/static, the requests hit at localhost/v1/static. Is there a way to change that with traefik?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you push up the code you have so I can see it? I notice I have a typo above:

- 'traefik.http.routers.rss_bridge.middlewares=strip_search_prefix'

should be:

- 'traefik.http.routers.rss_bridge.middlewares=strip_rss_bridge_prefix'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will push what I have

@aserputov
Copy link
Contributor

@humphd could you please take a look on this one?

@humphd
Copy link
Contributor

humphd commented Feb 2, 2022

@humphd could you please take a look on this one?

Made a PR to fix it dbelokon#1

aserputov
aserputov previously approved these changes Feb 2, 2022
docker/docker-compose.yml Outdated Show resolved Hide resolved
# Traefik routing for the rss-bridge service at /v1/rss-bridge
- 'traefik.http.routers.rss_bridge.rule=PathPrefix(`/${API_VERSION}/rss-bridge`)'
# Specify the RSS-Bridge service port
- 'traefik.http.services.rss_bridge.loadbalancer.server.port=80'
Copy link
Contributor

@cindyorangis cindyorangis Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can use port 80 because it's being used by something else. Let's define the port as an environment variable like {RSS_BRIDGE_PORT} and bind it here instead of hardcoding it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port 80 is the port used inside the container, not in the host, I believe. In the rss-bridge docker installation instructions, it says something along those lines. If I change it to another port number, it gives a Bad Gateway response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the port 80 in the host is used by nginx, by the way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you have to set the port of the running container here, which in the case of rss-bridge is 80, since it runs Apache. This is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification, guys :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the Traefik docs 100% crystal clear...once I've spent 4 hours being lost reading them :). It always takes me half-a-day to relearn how it works.

I should probably add a doc to the new doc system...

# Traefik routing for the rss-bridge service at /v1/rss-bridge
- 'traefik.http.routers.rss_bridge.rule=PathPrefix(`/${API_VERSION}/rss-bridge`)'
# Specify the RSS-Bridge service port
- 'traefik.http.services.rss_bridge.loadbalancer.server.port=80'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you have to set the port of the running container here, which in the case of rss-bridge is 80, since it runs Apache. This is correct.

@aserputov aserputov merged commit f80b0b9 into Seneca-CDOT:master Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Start an MVP for including Twitch streams in Telescope
5 participants