chore: init repository
This commit is contained in:
parent
de8d7ccf82
commit
470f8aa8ea
|
@ -0,0 +1,23 @@
|
|||
image: docker:latest
|
||||
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
|
||||
build-main:
|
||||
stage: build
|
||||
script:
|
||||
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
|
||||
- docker push "$CI_REGISTRY_IMAGE"
|
||||
only:
|
||||
- main
|
||||
|
||||
build-branch:
|
||||
stage: build
|
||||
script:
|
||||
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
|
||||
except:
|
||||
- main
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
FROM debian:stretch-slim
|
||||
|
||||
ENV AGATE_VER 2.5.2
|
||||
|
||||
ENV GEMINI_DOMAIN example.com
|
||||
ENV GEMINI_GIT_REPO https://gitlab.com/valvin/gemini-agate-image
|
||||
ENV GEMINI_GIT_PATH /app/data
|
||||
ENV GEMINI_CONTENT_FOLDER content
|
||||
ENV GEMINI_CERT_PATH /certs
|
||||
ENV GEMINI_LANG fr-FR
|
||||
|
||||
RUN apt update && apt install -y openssl git wget \
|
||||
&& apt clean && rm -rf /var/lib/apt/lists/*
|
||||
RUN mkdir /app
|
||||
RUN wget https://github.com/mbrubeck/agate/releases/download/v${AGATE_VER}/agate.x86_64-unknown-linux-gnu.gz -O /app/agate.gz \
|
||||
&& cd /app && gunzip agate.gz && chmod +x agate
|
||||
|
||||
COPY entrypoint.sh /app/entrypoint.sh
|
||||
|
||||
EXPOSE 1965/tcp
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
CMD ["run"]
|
22
README.md
22
README.md
|
@ -1,2 +1,24 @@
|
|||
# Gemini Agate Image
|
||||
|
||||
This image allowes to publish static content locate in a git repository on Gemini. Based on Agate gemini server.
|
||||
|
||||
This images takes these environment variables:
|
||||
|
||||
| --- | --- | --- |
|
||||
| variable | description | default value |
|
||||
| `GEMINI_DOMAIN` | domain name of the capsule | example.com |
|
||||
| `GEMINI_GIT_REPO` | url of the git repository containing content | `https://gitlab.com/valvin/gemini-agate-image` |
|
||||
| `GEMINI_CONTENT_FOLDER` | folder inside the git repository which contains the content | `content`|
|
||||
| `GEMINI_GIT_PATH` | path in which git repository will be cloned | `/app/data` |
|
||||
| `GEMINI_CERT_PATH` | path which contains certificates. this path has to be a volume if not new certs will be generated | `/certs` |
|
||||
| `GEMINI_LANG` | langage of the content | `fr-FR` |
|
||||
|
||||
image take those commands:
|
||||
|
||||
* none or `run` : launch agate after initialization process
|
||||
* `update`: update repository content
|
||||
|
||||
initialization process is:
|
||||
* check if cert are present in `GEMINI_CERT_PATH` if not it creates it
|
||||
* clone or update the content repository
|
||||
* launch agate
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#!/bin/sh
|
||||
create_new_cert(){
|
||||
if [ ! -d "${GEMINI_CERT_PATH}" ]; then
|
||||
mkdir ${GEMINI_CERT_PATH}
|
||||
fi
|
||||
openssl req -x509 -newkey rsa:4096 -keyout ${GEMINI_CERT_PATH}/key.rsa -out ${GEMINI_CERT_PATH}/cert.pem \
|
||||
-days 3650 -nodes -subj "/CN=${GEMINI_DOMAIN}"
|
||||
}
|
||||
|
||||
clone_repository(){
|
||||
git clone ${GEMINI_GIT_REPO} ${GEMINI_GIT_PATH}
|
||||
}
|
||||
|
||||
update_repository(){
|
||||
if [ ! -d "${GEMINI_GIT_PATH}" ]; then
|
||||
echo "Cloning repository in ${GEMINI_GIT_PATH}"
|
||||
clone_repository
|
||||
else
|
||||
cd ${GEMINI_GIT_PATH}
|
||||
git pull
|
||||
fi
|
||||
}
|
||||
|
||||
run_agate(){
|
||||
/app/agate --content ${GEMINI_GIT_PATH}/${GEMINI_CONTENT_FOLDER} \
|
||||
--key ${GEMINI_CERT_PATH}/key.rsa \
|
||||
--cert ${GEMINI_CERT_PATH}/cert.pem \
|
||||
--addr [::]:1965 \
|
||||
--addr 0.0.0.0:1965 \
|
||||
--hostname ${GEMINI_DOMAIN} \
|
||||
--lang ${GEMINI_LANG}
|
||||
}
|
||||
|
||||
default(){
|
||||
if [ ! -f "${GEMINI_CERT_PATH}/cert.pem" ]; then
|
||||
echo "No certs found in {GEMINI_CERT_PATH}. Creates new certificate."
|
||||
create_new_cert
|
||||
fi
|
||||
|
||||
if [ ! -d "${GEMINI_GIT_PATH}" ]; then
|
||||
echo "Cloning repository in ${GEMINI_GIT_PATH}"
|
||||
clone_repository
|
||||
else
|
||||
update_repository
|
||||
fi
|
||||
|
||||
echo "Starting agate for gemini://${GEMINI_DOMAIN}"
|
||||
run_agate
|
||||
}
|
||||
|
||||
if [ "$#" -eq "1" ]; then
|
||||
if [ "$1" = "run" ]; then
|
||||
default
|
||||
elif [ "$1" = "update" ]; then
|
||||
update_repository
|
||||
fi
|
||||
else
|
||||
echo "unknown command. launching default"
|
||||
default
|
||||
fi
|
Loading…
Reference in New Issue