From b39e07232c99c37120eca2b6b3d8a2f0337e7ef5 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Sun, 27 Mar 2022 18:29:26 +0200 Subject: [PATCH] Add docker image --- .gitignore | 1 + Dockerfile | 10 ++++++++++ README.md | 17 ++++++++++++++++- build_docker.sh | 8 ++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100755 build_docker.sh diff --git a/.gitignore b/.gitignore index 6a66193..6c99cdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target .idea storage +image diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..90dd994 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM debian:bullseye-slim + +COPY pages_server /usr/local/bin/pages_server + +RUN mkdir /srv/web && chown 1000 /srv/web +USER 1000 + +ENV FILES_PATH /srv/web + +CMD "/usr/local/bin/pages_server" diff --git a/README.md b/README.md index 3ab4ba4..279e151 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,19 @@ PagesServer is a very lightweight static web server that offer two main features * Serve static content * Allow easy update of the whole website from a CI/CD system through a POST request, protected by a token & by IP filtering. -This project has been written in Rust. It is based on the Actix framework. \ No newline at end of file +This project has been written in Rust. It is based on the Actix framework. + +## Publishing / updating website +Make a +* `POST` request on `http:///_mgmt/replace_files`. +* Body: + * Multipart / Form-data body + * One field: `file` that contains a TAR archive of the website to publish +* Headers: + * `Token` (mandatory) : contains the push token that allow to post files + * `BaseURI` (optional) : defines the directory inside the tar archive to extract to storage directory + +## Try it +```bash +docker run --rm -ti -p 8000:8000 -v $(pwd)/storage:/srv/web --env UPDATE_TOKEN=CHANGEME pierre42100/pages_server +``` \ No newline at end of file diff --git a/build_docker.sh b/build_docker.sh new file mode 100755 index 0000000..23ee085 --- /dev/null +++ b/build_docker.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cargo build --release + +rm -rf image +mkdir image + +cp target/release/pages_server image +docker build image -f Dockerfile -t pierre42100/pages_server