From 4bc3d02cbe76105a2436e5a254905ffdbe27b24e Mon Sep 17 00:00:00 2001 From: mborne Date: Fri, 9 Jun 2023 08:21:31 +0200 Subject: [PATCH 1/4] phpunit - upgrade config --- phpunit.xml.dist | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fc64870..a506b5f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,30 +1,16 @@ - - - - - ./tests - - - - - - ./src - - - - + + + + ./src + + + + + ./tests + + + - From 349b6a358b1947a3b326ed4208c52a0cbb258406 Mon Sep 17 00:00:00 2001 From: mborne Date: Fri, 9 Jun 2023 08:23:02 +0200 Subject: [PATCH 2/4] bin/satis-gitlab - allow usage in docker image --- bin/satis-gitlab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/satis-gitlab b/bin/satis-gitlab index ad91a43..712c7ad 100755 --- a/bin/satis-gitlab +++ b/bin/satis-gitlab @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php Date: Fri, 9 Jun 2023 08:23:32 +0200 Subject: [PATCH 3/4] docker - experiment the built of a docker image --- .dockerignore | 4 ++++ Dockerfile | 13 +++++++++++++ docs/docker.md | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docs/docker.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dc00b9d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +/vendor/ +/output/ +/.git/ + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8971720 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM composer:latest + +# to experiment remote storage of public content +RUN curl https://rclone.org/install.sh | bash + +RUN mkdir -p /opt/satis-gitlab +WORKDIR /opt/satis-gitlab +COPY composer.json . +COPY composer.lock . +RUN composer install + +COPY . /opt/satis-gitlab +WORKDIR /opt/satis-gitlab diff --git a/docs/docker.md b/docs/docker.md new file mode 100644 index 0000000..909c4a7 --- /dev/null +++ b/docs/docker.md @@ -0,0 +1,38 @@ +# satis-gitlab - Usage with docker + +## Motivation + +Provide a docker image to use satis-gitlab to : + +* Create a static site with pages using GitLab-CI or GitHub actions +* Ease the built of a custom image with a custom update loop +* Allow remote storage (like S3) of generated content using [rclone](https://rclone.org/) + +## Build image + +```bash +docker build -t satis-gitlab . +``` + +## Create static site content + +```bash +docker volume create satis-data +docker run -v satis-data:/opt/satis-gitlab/public --env-file=../satis-gitlab.env --rm -ti satis-gitlab /bin/bash + +bin/satis-gitlab gitlab-to-config \ + --homepage https://satis.dev.localhost \ + --output satis.json https://github.com \ + --users=mborne $GITHUB_TOKEN + +git config --global github.accesstoken $GITHUB_TOKEN +bin/satis-gitlab build satis.json public +``` + +## Serve static site content + +```bash +docker run --rm -ti -v satis-data:/usr/share/nginx/html -p 8888:8080 nginxinc/nginx-unprivileged:1.25 +``` + + From 259f0f52d6784175215304c20aded7234cc9b112 Mon Sep 17 00:00:00 2001 From: mborne Date: Mon, 15 Jul 2024 13:21:07 +0200 Subject: [PATCH 4/4] chore: finalize Dockerfile and docs/docker.md --- .dockerignore | 1 + Dockerfile | 25 ++++++++++++++++++++++--- README.md | 1 - docs/docker.md | 26 ++++++++++++++++---------- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.dockerignore b/.dockerignore index dc00b9d..c8b5cce 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ /vendor/ /output/ /.git/ +/satis.json diff --git a/Dockerfile b/Dockerfile index 8971720..a9a1395 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,15 @@ FROM composer:latest -# to experiment remote storage of public content -RUN curl https://rclone.org/install.sh | bash +ARG UID=1000 +ARG GID=1000 +RUN addgroup --gid "$GID" satis \ + && adduser \ + --disabled-password \ + --gecos "" \ + --home "/home/satis-gitlab" \ + --ingroup "satis" \ + --uid "$UID" \ + satis RUN mkdir -p /opt/satis-gitlab WORKDIR /opt/satis-gitlab @@ -9,5 +17,16 @@ COPY composer.json . COPY composer.lock . RUN composer install -COPY . /opt/satis-gitlab WORKDIR /opt/satis-gitlab +COPY src/ src +COPY bin/ bin + +RUN mkdir -p /opt/satis-gitlab/config \ + && chown -R satis:satis /opt/satis-gitlab/config +VOLUME /opt/satis-gitlab/config + +RUN mkdir -p /opt/satis-gitlab/public \ + && chown -R satis:satis /opt/satis-gitlab/public +VOLUME /opt/satis-gitlab/public + +USER satis diff --git a/README.md b/README.md index 8999a7e..6bfb92f 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,6 @@ Some command line options provide a basic customization options. You may also us [default-template.json](src/MBO/SatisGitlab/Resources/default-template.json) - ## Testing ```bash diff --git a/docs/docker.md b/docs/docker.md index 909c4a7..e48761d 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -2,11 +2,10 @@ ## Motivation -Provide a docker image to use satis-gitlab to : +Provide a docker image for satis-gitlab to : * Create a static site with pages using GitLab-CI or GitHub actions * Ease the built of a custom image with a custom update loop -* Allow remote storage (like S3) of generated content using [rclone](https://rclone.org/) ## Build image @@ -17,22 +16,29 @@ docker build -t satis-gitlab . ## Create static site content ```bash -docker volume create satis-data -docker run -v satis-data:/opt/satis-gitlab/public --env-file=../satis-gitlab.env --rm -ti satis-gitlab /bin/bash - +# create satis-gitlab container +docker run \ + -v satis-data:/opt/satis-gitlab/public \ + -v satis-config:/opt/satis-gitlab/config \ + --env-file=../satis-gitlab.env \ + --rm -ti satis-gitlab /bin/bash + +# generate config/satis.json bin/satis-gitlab gitlab-to-config \ --homepage https://satis.dev.localhost \ - --output satis.json https://github.com \ - --users=mborne $GITHUB_TOKEN + --output config/satis.json https://github.com \ + --users=mborne $SATIS_GITHUB_TOKEN -git config --global github.accesstoken $GITHUB_TOKEN -bin/satis-gitlab build satis.json public +# generate public from config/satis.json with satis +git config --global github.accesstoken $SATIS_GITHUB_TOKEN +bin/satis-gitlab build config/satis.json public -v ``` ## Serve static site content ```bash -docker run --rm -ti -v satis-data:/usr/share/nginx/html -p 8888:8080 nginxinc/nginx-unprivileged:1.25 +# see http://localhost:8888 +docker run --rm -ti -v satis-data:/usr/share/nginx/html -p 8888:8080 nginxinc/nginx-unprivileged:1.26 ```