diff --git a/.gitignore b/.gitignore index ea8c4bf..abba15c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/build \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3a43b3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM rust:1.73-slim-buster as rustbuild + +WORKDIR /paste-eater + +COPY ./Cargo.lock ./Cargo.lock +COPY ./Cargo.toml ./Cargo.toml +COPY ./src ./src + +RUN cargo build --release + +FROM node:lts as nodebuilder + +WORKDIR /app + +COPY /paste-eater-frontend . + +RUN yarn install --prefer-offline --frozen-lockfile --non-interactive --production=true + +RUN yarn build + +RUN rm -rf node_modules + +FROM rust:1.73-slim-buster +COPY --from=rustbuild /paste-eater/target/release/paste-eater ./paste-eater/ +COPY --from=nodebuilder /app/build ./paste-eater/paste-eater-frontend/build + +ENV ROCKET_ADDRESS 0.0.0.0 + +EXPOSE 8000 + +VOLUME /root/.config/paste-eater/data + +CMD ["./paste-eater/paste-eater"] \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..16a65b1 --- /dev/null +++ b/build.sh @@ -0,0 +1,8 @@ +rm -rf build + +cargo build --release +(cd paste-eater-frontend && yarn build) + +mkdir -p build/paste-eater-frontend/build +cp -r target/release/paste-eater build/ +cp -r paste-eater-frontend/build/* build/paste-eater-frontend/build \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index ca29201..080be4a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -95,6 +95,10 @@ impl ConfigurationHandler { } } + pub fn get_config_path(&self) -> &Path { + self.config_path.as_path() + } + pub fn new_with_path(path: &Path) -> Result { ConfigurationHandler::new_with_defaults(path, &PasteEaterConfig { files_location: default_files_location(), diff --git a/src/server/app.rs b/src/server/app.rs index cfd4f79..8751994 100644 --- a/src/server/app.rs +++ b/src/server/app.rs @@ -39,6 +39,14 @@ fn create_paste_handler() -> Result { let config_handler = ConfigurationHandler::new_with_args(&args)?; + println!("Using config at '{}'", config_handler.get_config_path().display()); + + let Ok(config) = config_handler.fetch_config() else { + return Err(PasteEaterError::new(&format!("Unable to retrieve configuration at '{}'", config_handler.get_config_path().display()))); + }; + + println!("Using config :\n{:?}", config); + Ok(PasteHandler::new(config_handler)) }