~oyvindsk/rss-web-reader

ref: ea6bffa83a74846c5152b333f149c699ef41ccb3 rss-web-reader/README.adoc -rw-r--r-- 4.4 KiB
ea6bffa8 — Øyvind Skaar sourcehut build, take1 (broken) 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
A simple RSS reader I made for myself. 

Github repo could be lagging, it's a mirror of https://git.sr.ht/~oyvindsk/rss-web-reader . 

Feature aka why?? :
 
 - Usable on all devices with a web browser 
 - It always knows what articles (items) you have read already. Therefore it's easy to use on multiple devices.
 - Never misses anything, even when I don't use it. Updates all RSS feeds "in the background". (Articles/items usually disappear from a feed after a while)
 - Use the web browser (not a separate program) so it's fast to bookmark etc


== Running locally
You need the Google Cloud Platform tooling installed and working. That is, `gcloud auth list` should list at least 1 account. If you use the Datastore Emulator you probably do not need to authenticate.  

You also need to create a config file and call it whatever (I use `SECRET-config.sh` so it's git ignored). Set the first variables, see `example-config.sh`. 

When you have a config file, run `source SECRET-config.sh` before running any scripts. Run scripts from the "root" `rss-web-reader` folder, they might point to other files with relative urls.


=== Run with Datastore Emulator

*Start the emulator:*

It simpley calls a gcloud command: `./development/locally/run-datastore-emulator.sh`

*Start the go program:*
`./development/locally/run-with-datastore-emulator.sh`

=== Run using the real Google Cloud Datastore
This is the default. You need to set a real PROJECT in your config file. 

Also you probably have to run `gcloud auth application-default login` and log in in the web browser. This is so the go lib can authenticate with Google Cloud services when running locally. 

*Start the go program:*
`./development/locally/run.sh`


== Deploying to Google Cloud Run
(Testet on Linux)

You need the Google Cloud Platform tooling installed and working. That is, `gcloud auth list` should list at least 1 account. 

You also need to create a `SECRET-config.sh` and set all variables, see `example-config.sh`. `RSS_FEED_URL` must be set after you know if, that is, after the first deply to Cloud Run (step 3) I guess ..

When you have a config file, run `source config.sh` before running any scripts. Run scripst from the "root" `rss-web-reader` folder, they might point to other files with relative urls.

Basically Cloud Run takes a Docker images from Google Container Registry and runs it. There are 4 steps to a full deploy:

1. Buid a Docker image. Use Docker locally, Google Cloud Build, or .. whatever
2. Push the image to Google Container Registry
3. Deploy it to Cloud Run
4. Create a Google Cloud Scheduler trigger to refresh all the RSS feeds (POST to /refresh)  

=== Build a Docker image

Keep in mind that the image contains your "secrets" like the config settings and the feeds file. 

*Using Docker locally:*

`./deployment/build-docker-image-locally.sh`

It uses sudo. Modify it if you don't want that.

*Using Google Cloud Build:*

TODO: fix script



=== Push the image to Google Container Registry
`./deployment/push-local-image-to-google-container-registry.sh`

Takes  a while =( 

TODO: Either make the image smaller or try to find a way to deploy without a Docker image or with a standard one .. or .. 


=== Deploy it to Cloud Run
`./deployment/deploy-from-google-container-registry.sh`
Should just work and finish in 15 seconds or so (?) Confirm in the web console. If it does not work the logging in the web console under Cloud Run => [revision] => Logs is helpful. 
 

=== Create a Google Cloud Scheduler trigger
To refresh all the RSS feeds (POST to /refresh). The default is to trigger it 7 minutes over every hour.

`./deployment/create-google-cloud-scheduler-trigger.sh`

Should just work and print some useful info. Also see Cloud Scheduler in the web console: https://console.cloud.google.com/cloudscheduler







== Plan
=== 1st version:
* Fetch all feeds periodically [OK]
* Remember seen, don't add the same article/item twice [OK]
* Show them:
** Just the title, date, and link [OK]
** Order by reversed pub date[ OK]

=== 2nd version:
 - Password! [OK]
 - Remember seeen [OK]

=== 3rd version:
 * Nicer templates
 * Clean up code
 * Put username/password in a file or something, for all the scripts too [OK]
 * Fix scrips [OK]
 
=== 4th version:
 * Optimize datastore calls, use *multi


== Echo

=== Quirks:

* Template Render() always succeeds and return 200, no error message if Render returns an error =/
* How to log in included funcs ad packages? Pass Echo context along.. ? Ufgr