From 1845077b9b9b7ff7175926071fb0c9187a128ebd Mon Sep 17 00:00:00 2001 From: Sajjad Rad Date: Mon, 18 Oct 2021 00:20:18 +0300 Subject: [PATCH] fix: update README file --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 4246db4..455b94e 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,37 @@ The backend of https://lorem.space lives here. * `min-height`: minimum supported height (integer) * `max-height`: maximum supported height (integer) +### Run binary +To run built binary, visit the [release page](https://github.com/manasky/lorem-server/releases) & download your OS build file. Unzip the downloaded file & make sure about the file execution permissions, then run the app with the arguments in the terminal: + +* MacOS & Linux: `./lorem-server --host "127.0.0.1:8080" --dir "~/Pictures"` +* Windows: `lorem-server.exe -host "127.0.0.1:8080" -dir "C:\Users\USER\Pictures` ### Docker You can pull & run the public docker image from github package registry: `$ docker pull ghcr.io/manasky/lorem-server:latest` + +#### Run docker image: +To run the container you must pass the app arguments via the `.env` file. To this, create a file named `.env` & set the options in uppercase & snail case format. + +An example of .env file: +``` +HOST=0.0.0.0:8080 +DIR=/app/images +MIN_WIDTH=20 +``` +By this config, the app listens to port number `8080` on the host IP address and scan `/app/images/` path (from the container) for the images and limit the `width` size to a minimum of 20 pixels. + +##### Link directory +Your images directory must link to the container, to this you can use -v arguments while running the container. + +#### Run command + +`$ docker run --env-file=./.env -p 8080:8080 -v ~/Pictures:/app/images ghcr.io/manasky/lorem-server:latest` + +* `--env-file` sets the application environment variables path. here `.env` file exists in the current path. +* `-p 8080:8080` sets up a port forward. the application container will listen to the `8080` port (set in the .env file as `HOST`). this flag maps the container's port `8080` to port `8080` on the host (here, your localhost). +* `~/Pictures:/app/images` sets up a bindmount volume that links the directory `/app/images` from inside the app container to the directory `~/Pictures` on the host machine (here, your system). The app image directory is set in the `.env` file as `/app/images`, so here the `~/Pictures` is mounted to that. + + +After container running, the app will scan `/app/images` which is mounted to the directory `~/Pictures` of your system & serves the HTTP server on `127.0.0.1:8080`. Visit `127.0.0.1:8080/image` for start. \ No newline at end of file