File tree Expand file tree Collapse file tree 8 files changed +104
-17
lines changed Expand file tree Collapse file tree 8 files changed +104
-17
lines changed Original file line number Diff line number Diff line change
1
+ # See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
2
+
3
+ name : Fly Deploy
4
+ on :
5
+ push :
6
+ branches :
7
+ - main
8
+ jobs :
9
+ deploy :
10
+ name : Deploy app
11
+ runs-on : ubuntu-latest
12
+ concurrency : deploy-group # optional: ensure only one action runs at a time
13
+ steps :
14
+ - uses : actions/checkout@v4
15
+ - uses : superfly/flyctl-actions/setup-flyctl@master
16
+ - run : flyctl deploy --remote-only
17
+ env :
18
+ FLY_API_TOKEN : ${{ secrets.FLY_API_TOKEN }}
Original file line number Diff line number Diff line change @@ -6,21 +6,10 @@ WORKDIR /usr/src/app
6
6
7
7
COPY . .
8
8
RUN cargo build --bin monolith --release
9
+ ADD https://github.com/benbjohnson/litestream/releases/download/v0.3.8/litestream-v0.3.8-linux-amd64-static.tar.gz /tmp/litestream.tar.gz
10
+ RUN tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz
9
11
10
- # Build the chiselled filesystem based on the desired slices.
11
- FROM ubuntu:$UBUNTU_RELEASE AS chiselled
12
- ARG UBUNTU_RELEASE
13
- ARG TARGETARCH
14
-
15
- # Get chisel binary
16
- ADD https://github.com/canonical/chisel/releases/download/v0.9.1/chisel_v0.9.1_linux_$TARGETARCH.tar.gz chisel.tar.gz
17
- RUN tar -xvf chisel.tar.gz -C /usr/bin/
18
- RUN apt-get update \
19
- && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates
20
-
21
- WORKDIR /rootfs
22
-
23
- # RUN chisel cut --release ubuntu-$UBUNTU_RELEASE --root /rootfs \
12
+ # RUN chisel cut --release ubuntu-$UBUNTU_RELEASE --root /rootfs \
24
13
# base-files_base \
25
14
# base-files_release-info \
26
15
# ca-certificates_data \
@@ -36,6 +25,9 @@ RUN apt-get update \
36
25
COPY ./ai_manager_service/migrations /var/lib/db/migrations
37
26
EXPOSE 9000
38
27
# COPY --from=chiselled /rootfs /
28
+ COPY --from=builder /usr/local/bin/litestream /usr/local/bin/litestream
39
29
COPY --from=builder /usr/src/app/target/release/monolith /usr/local/bin/twitch-alerts
40
30
COPY ./frontend_api/assets /var/lib/assets/
41
- CMD ["/usr/local/bin/twitch-alerts" ]
31
+ COPY scripts/start.sh /scripts/start.sh
32
+ COPY scripts/litestream.yaml /etc/litestream.yml
33
+ CMD ["/scripts/start.sh" ]
Original file line number Diff line number Diff line change 62
62
# Start your application & Litestream to share a PVC data directory.
63
63
containers :
64
64
- name : twitch-alerts
65
- image : nullchannel/twitch-alerts:0.1.36
65
+ image : nullchannel/twitch-alerts:0.1.37
66
66
ports :
67
67
- name : httpport
68
68
containerPort : 8080
Original file line number Diff line number Diff line change
1
+ # fly.toml app configuration file generated for twitch-alerts on 2024-08-15T18:18:25-04:00
2
+ #
3
+ # See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4
+ #
5
+
6
+ app = ' twitch-alerts'
7
+ primary_region = ' atl'
8
+
9
+ [build ]
10
+
11
+ [[services ]]
12
+ protocol = " tcp"
13
+ internal_port = 9000
14
+ auto_stop_machines = true
15
+ auto_start_machines = true
16
+ min_machines_running = 0
17
+
18
+ [[services .ports ]]
19
+ port = 9000
20
+ handlers = [" tls" , " http" ]
21
+
22
+ [http_service ]
23
+ internal_port = 8080
24
+ force_https = true
25
+ auto_stop_machines = ' stop'
26
+ auto_start_machines = true
27
+ min_machines_running = 0
28
+ processes = [' app' ]
29
+
30
+ [env ]
31
+ FRONTEND_ASSETS = " /var/lib/assets"
32
+ HTTP_PORT = " 8080"
33
+ WEBSOCKET_HOST = " twitch-alerts.fly.dev"
34
+ CHANNEL_ID = " 99431252"
35
+ RUST_ENV = " production"
36
+ ENV = " production"
37
+ AI_MIGRATIONS_DIR = " /var/lib/db"
38
+
39
+ [[vm ]]
40
+ size = ' shared-cpu-1x'
Original file line number Diff line number Diff line change 13
13
14
14
< body >
15
15
< main class ="flex flex-row justify-center w-full ">
16
- < div hx-ext ="ws " ws-connect ="ws ://{{ hostname }}:{{ port }}/ ">
16
+ < div hx-ext ="ws " ws-connect ="wss ://{{ hostname }}:{{ port }}/ ">
17
17
< div id ="notifications "> </ div >
18
18
</ div >
19
19
</ main >
Original file line number Diff line number Diff line change 1
1
use serde:: { Deserialize , Serialize } ;
2
2
3
+ #[ derive( Serialize , Deserialize , Debug ) ]
4
+ pub enum EventMessage {
5
+ /// A new event message from Twitch.
6
+ TwitchEvent ( NewTwitchEventMessage ) ,
7
+ /// A new message to display.
8
+ YoutubeEvent ( YoutubeEventMessage ) ,
9
+ }
10
+
11
+ #[ derive( Serialize , Deserialize , Debug ) ]
12
+ pub struct YoutubeEventMessage {
13
+ pub event : YoutubeEvent ,
14
+ pub message_id : String ,
15
+ pub message_at : String ,
16
+ }
17
+
18
+ #[ derive( Serialize , Deserialize , Debug ) ]
19
+ pub enum YoutubeEvent {
20
+ Subscribe ( String ) ,
21
+ }
22
+
3
23
#[ derive( Serialize , Deserialize , Debug ) ]
4
24
pub struct NewTwitchEventMessage {
5
25
pub event : TwitchEvent ,
Original file line number Diff line number Diff line change
1
+ dbs :
2
+ - path : /data/db
3
+ replicas :
4
+ - url : s3://twitch-alerts.us-ord-1.linodeobjects.com/db
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ # Restore the database if it does not already exist.
5
+ if [ -f /data/db ]; then
6
+ echo " Database already exists, skipping restore"
7
+ else
8
+ echo " No database found, restoring from replica if exists"
9
+ litestream restore -v -if-replica-exists -o /data/db s3://twitch-alerts.us-ord-1.linodeobjects.com/db
10
+ fi
11
+
12
+ # Run litestream with your app as the subprocess.
13
+ exec litestream replicate -exec " /usr/local/bin/twitch-alerts --db-path /data/db"
You can’t perform that action at this time.
0 commit comments