chore: update feeds ports
4af7e6dd
4 file(s) · +14 −80
| 33 | 33 | RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* |
|
| 34 | 34 | WORKDIR /app |
|
| 35 | 35 | COPY --from=builder /app/target/release/feeds ./feeds |
|
| 36 | - | EXPOSE 4555 |
|
| 36 | + | EXPOSE 3000 |
|
| 37 | 37 | CMD ["./feeds"] |
| 87 | 87 | ||
| 88 | 88 | ```bash |
|
| 89 | 89 | cargo run |
|
| 90 | - | # Server running on http://localhost:4555 |
|
| 90 | + | # Server running on http://localhost:3000 |
|
| 91 | 91 | ``` |
|
| 92 | 92 | ||
| 93 | 93 | ## Project Structure |
|
| 114 | 114 | ||
| 115 | 115 | Since Feeds compiles to a single binary, deployment is straightforward on any platform. |
|
| 116 | 116 | ||
| 117 | - | ### Self Hosting |
|
| 118 | - | ||
| 119 | - | If you are running a VPS or your own hardware like a Raspberry Pi, you can use a basic `systemd` service to manage the instance. |
|
| 120 | - | ||
| 121 | - | 1. Clone the repo and build |
|
| 122 | - | ||
| 123 | - | ```bash |
|
| 124 | - | git clone https://github.com/stevedylandev/feeds |
|
| 125 | - | cd feeds |
|
| 126 | - | cargo build --release |
|
| 127 | - | ``` |
|
| 128 | - | ||
| 129 | - | 2. Create a systemd service |
|
| 130 | - | ||
| 131 | - | The location of where these files are located might depend on your linux distribution, but most commonly they can be found at `/etc/systemd/system`. Create a new file called `feeds.service` and edit it with `nano` or `vim`. |
|
| 132 | - | ||
| 133 | - | ```bash |
|
| 134 | - | cd /etc/systemd/system |
|
| 135 | - | touch feeds.service |
|
| 136 | - | sudo nano feeds.service |
|
| 137 | - | ``` |
|
| 138 | - | ||
| 139 | - | Paste in the following code: |
|
| 140 | - | ||
| 141 | - | ```bash |
|
| 142 | - | [Unit] |
|
| 143 | - | # describe the app |
|
| 144 | - | Description=Feeds |
|
| 145 | - | # start the app after the network is available |
|
| 146 | - | After=network.target |
|
| 147 | - | ||
| 148 | - | [Service] |
|
| 149 | - | # usually you'll use 'simple' |
|
| 150 | - | # one of https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type= |
|
| 151 | - | Type=simple |
|
| 152 | - | # which user to use when starting the app |
|
| 153 | - | User=YOUR_USER |
|
| 154 | - | # path to your application's root directory |
|
| 155 | - | WorkingDirectory=/home/YOUR_USER/feeds |
|
| 156 | - | # the command to start the app |
|
| 157 | - | ExecStart=/home/YOUR_USER/feeds/target/release/feeds |
|
| 158 | - | # restart policy |
|
| 159 | - | Restart=always |
|
| 160 | - | ||
| 161 | - | [Install] |
|
| 162 | - | # start the app automatically |
|
| 163 | - | WantedBy=multi-user.target |
|
| 164 | - | ``` |
|
| 165 | - | ||
| 166 | - | > [!NOTE] |
|
| 167 | - | > Make sure you update `YOUR_USER` with your own user info, and make sure the paths are correct! |
|
| 168 | - | ||
| 169 | - | 3. Start up the service |
|
| 170 | - | ||
| 171 | - | Run the following commands to enable and start the service |
|
| 172 | - | ||
| 173 | - | ```bash |
|
| 174 | - | sudo systemctl enable feeds.service |
|
| 175 | - | sudo systemctl start feeds |
|
| 176 | - | ``` |
|
| 177 | - | ||
| 178 | - | Check and make sure it's working |
|
| 179 | - | ||
| 180 | - | ```bash |
|
| 181 | - | sudo systemctl status feeds |
|
| 182 | - | ``` |
|
| 183 | - | ||
| 184 | - | 4. Setup a Tunnel (optional) |
|
| 185 | - | ||
| 186 | - | From here you have a lot of options of how you may want to access the instance. One easy way to start is to use a Cloudflare tunnel and point it to `http://localhost:4555`. |
|
| 187 | - | ||
| 188 | - | ||
| 189 | 117 | ### Docker |
|
| 190 | 118 | ||
| 191 | 119 | 1. Clone the repo |
|
| 199 | 127 | ||
| 200 | 128 | ```bash |
|
| 201 | 129 | docker build -t feeds . |
|
| 202 | - | docker run -p 4555:4555 --env-file .env feeds |
|
| 130 | + | docker run -p 3000:3000 --env-file .env feeds |
|
| 203 | 131 | ``` |
|
| 204 | 132 | ||
| 205 | 133 | Or use `docker-compose` |
|
| 4 | 4 | context: ../.. |
|
| 5 | 5 | dockerfile: apps/feeds/Dockerfile |
|
| 6 | 6 | ports: |
|
| 7 | - | - "4555:4555" |
|
| 7 | + | - "3000:3000" |
|
| 8 | 8 | volumes: |
|
| 9 | 9 | - feeds_data:/app/data |
|
| 10 | 10 | env_file: |
| 334 | 334 | .map(|v| v.eq_ignore_ascii_case("true")) |
|
| 335 | 335 | .unwrap_or(false); |
|
| 336 | 336 | ||
| 337 | - | let base_url = std::env::var("BASE_URL").unwrap_or_else(|_| "http://localhost:4555".to_string()); |
|
| 337 | + | let base_url = std::env::var("BASE_URL").unwrap_or_else(|_| "http://localhost:3000".to_string()); |
|
| 338 | 338 | ||
| 339 | 339 | let state = Arc::new(AppState { |
|
| 340 | 340 | sessions: auth::new_session_store(), |
|
| 356 | 356 | .route("/static/{*path}", get(static_handler)) |
|
| 357 | 357 | .with_state(state); |
|
| 358 | 358 | ||
| 359 | - | let listener = tokio::net::TcpListener::bind("0.0.0.0:4555") |
|
| 359 | + | let host = std::env::var("HOST").unwrap_or_else(|_| "0.0.0.0".to_string()); |
|
| 360 | + | let port: u16 = std::env::var("PORT") |
|
| 361 | + | .ok() |
|
| 362 | + | .and_then(|v| v.parse().ok()) |
|
| 363 | + | .unwrap_or(3000); |
|
| 364 | + | let addr = format!("{}:{}", host, port); |
|
| 365 | + | let listener = tokio::net::TcpListener::bind(&addr) |
|
| 360 | 366 | .await |
|
| 361 | - | .expect("Failed to bind to port 4555"); |
|
| 367 | + | .unwrap_or_else(|_| panic!("Failed to bind to {}", addr)); |
|
| 362 | 368 | ||
| 363 | - | println!("Server running on http://localhost:4555"); |
|
| 369 | + | println!("Server running on http://{}:{}", host, port); |
|
| 364 | 370 | axum::serve(listener, app).await.unwrap(); |
|
| 365 | 371 | } |
|