Add Dockerfile

This commit is contained in:
Miroslav Vasilev 2023-10-26 17:44:54 +03:00
parent e610d5aceb
commit 418c842c01
5 changed files with 54 additions and 0 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/target
/build

33
Dockerfile Normal file
View file

@ -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"]

8
build.sh Normal file
View file

@ -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

View file

@ -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<Self, ConfigurationError> {
ConfigurationHandler::new_with_defaults(path, &PasteEaterConfig {
files_location: default_files_location(),

View file

@ -39,6 +39,14 @@ fn create_paste_handler() -> Result<PasteHandler, PasteEaterError> {
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))
}