Compare commits

..

3 commits

Author SHA1 Message Date
8ca7aad3c3 docs: Expand docker docmentation
All checks were successful
Rust / build (push) Successful in 7m44s
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 1m50s
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
2024-09-03 20:17:59 +01:00
d923e831f0 build(docker): enable passing arguments when running via docker
All checks were successful
Rust / build (push) Successful in 6m19s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 2m0s
2024-09-03 20:08:40 +01:00
5e0cf270dd fix: shutdown properly on error
All checks were successful
Rust / build (push) Successful in 9m7s
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 2m2s
2024-09-03 20:08:12 +01:00
5 changed files with 80 additions and 19 deletions

1
Cargo.lock generated
View file

@ -1127,6 +1127,7 @@ dependencies = [
"test-log", "test-log",
"thiserror", "thiserror",
"time", "time",
"tokio",
"toml", "toml",
"tracing", "tracing",
"tracing-error", "tracing-error",

View file

@ -28,4 +28,5 @@ RUN apt-get update && \
USER 1000 USER 1000
COPY --from=builder /app/target/release/git-next /usr/local/bin COPY --from=builder /app/target/release/git-next /usr/local/bin
ENTRYPOINT [ "/usr/local/bin/git-next", "server", "start" ] ENTRYPOINT [ "/usr/local/bin/git-next" ]
CMD [ "server", "start" ]

View file

@ -51,6 +51,7 @@ toml = { workspace = true }
# Actors # Actors
actix = { workspace = true } actix = { workspace = true }
actix-rt = { workspace = true } actix-rt = { workspace = true }
tokio = { workspace = true }
# boilerplate # boilerplate
bon = { workspace = true } bon = { workspace = true }

View file

@ -576,6 +576,58 @@ world = { repo = "user/world", branch = "master", main = "master", next = "upcom
The token is created [here](https://github.com/settings/tokens/new) and requires the `repo` and `admin:repo_hook` permissions. The token is created [here](https://github.com/settings/tokens/new) and requires the `repo` and `admin:repo_hook` permissions.
## Docker
`git-next` is available as a [Docker image](https://git.kemitix.net/kemitix/-/packages/container/git-next/).
```shell
docker pull docker pull git.kemitix.net/kemitix/git-next:latest
```
### Docker Compose
Here is an example `docker-compose.yml`:
```yaml
services:
server:
image: git.kemitix.net/kemitix/git-next:latest
container_name: git-next-server
restart: unless-stopped
environment:
RUST_LOG: "hyper=warn,info"
ports:
- 8080:8092
volumes:
- ./:/app/
```
Note: this assumes the `git-next-server.toml` has a `listen.http.port` of
`8092` and that you are using a reverse proxy to route traffic arriving at
`listen.url` to port `8080`.
### Docker Run
This will run with the `server start` options:
```shell
docker run -it -v .:/app/ git.kemitix.net/kemitix/git-next:latest
```
To perform `server init`:
```shell
docker run -it -v .:/app/ git.kemitix.net/kemitix/git-next:latest server init
```
To perform repo `init`:
```shell
docker run -it -v .:/app/ git.kemitix.net/kemitix/git-next:latest init
```
TUI support is not available in the docker container. See [kemitix/git-next#154](https://git.kemitix.net/kemitix/git-next/issues/154).
## Contributing ## Contributing
Contributions to `git-next` are welcome! If you find a bug or have a feature Contributions to `git-next` are welcome! If you find a bug or have a feature

View file

@ -20,7 +20,7 @@ use git_next_core::git::RepositoryFactory;
use color_eyre::{eyre::Context, Result}; use color_eyre::{eyre::Context, Result};
use kxio::{fs::FileSystem, network::Network}; use kxio::{fs::FileSystem, network::Network};
use tracing::{error, info}; use tracing::info;
use std::{ use std::{
path::PathBuf, path::PathBuf,
@ -46,6 +46,7 @@ pub fn init(fs: &FileSystem) -> Result<()> {
Ok(()) Ok(())
} }
#[allow(clippy::too_many_lines)]
pub fn start( pub fn start(
ui: bool, ui: bool,
fs: FileSystem, fs: FileSystem,
@ -97,7 +98,6 @@ pub fn start(
use crate::server::actor::messages::SubscribeToUpdates; use crate::server::actor::messages::SubscribeToUpdates;
use crate::tui; use crate::tui;
let (tx_shutdown, rx_shutdown) = channel::<String>();
let tui_addr = tui::Tui::new(tx_shutdown.clone()).start(); let tui_addr = tui::Tui::new(tx_shutdown.clone()).start();
server.do_send(SubscribeToUpdates::new(tui_addr.clone().recipient())); server.do_send(SubscribeToUpdates::new(tui_addr.clone().recipient()));
server.do_send(ShutdownTrigger::new(tx_shutdown)); server.do_send(ShutdownTrigger::new(tx_shutdown));
@ -116,18 +116,26 @@ pub fn start(
} else { } else {
server.do_send(ShutdownTrigger::new(tx_shutdown.clone())); server.do_send(ShutdownTrigger::new(tx_shutdown.clone()));
server.do_send(FileUpdated); server.do_send(FileUpdated);
info!("Server running - Press Ctrl-C to stop...");
actix_rt::spawn(async move { info!("Server running - Press Ctrl-C to stop...");
let _ = signal::ctrl_c().await; tokio::select! {
info!("Ctrl-C received, shutting down..."); _r = signal::ctrl_c() => {
let _ = tx_shutdown.send(String::new()); info!("Ctrl-C received, shutting down...");
}); }
if let Ok(message) = rx_shutdown.try_recv() { _x = async move {
let _ = shutdown_message_holder_exec loop{
.write() if let Ok(message) = rx_shutdown.try_recv() {
.map(|mut o| o.replace(message)); let _ = shutdown_message_holder_exec
} .write()
.map(|mut o| o.replace(message));
break;
}
actix_rt::task::yield_now().await;
}
} => {
info!("signaled shutdown");
}
};
} }
// shutdown // shutdown
@ -147,10 +155,10 @@ pub fn start(
#[cfg(feature = "tui")] #[cfg(feature = "tui")]
if ui { if ui {
ratatui::restore(); ratatui::restore();
eprintln!("Server: {err:?}");
} }
error!(?err, "server"); if !err.is_empty() {
return Err(color_eyre::eyre::eyre!(format!("{err}"))); return Err(color_eyre::eyre::eyre!(format!("{err}")));
}
} }
// check for error from file watcher thread // check for error from file watcher thread
@ -159,9 +167,7 @@ pub fn start(
#[cfg(feature = "tui")] #[cfg(feature = "tui")]
if ui { if ui {
ratatui::restore(); ratatui::restore();
eprintln!("File Watcher: {err:?}");
} }
error!(?err, "file watcher");
return Err(color_eyre::eyre::eyre!(format!("{err}"))); return Err(color_eyre::eyre::eyre!(format!("{err}")));
} }